Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 105 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Jaynorms: I just added 12 notes to my Answer above to explain the Maple-specific parts of the code.

@vv 

Yeah, I posted that too quickly. Even if it worked it'd be very inefficient; the time complexity is O(nops(A)*nops(B)). I think it should be possible to write a procedure that is O(nops(A)+nops(B)) times some logarithmic factors. Here are two possibilities. Both work for an arbitrary number of lists.

MultisetIntersect1:= (M::seq(list))->                                                         
     (T-> [seq(_[]$min(map(`?[]`, T, _)), _= indices(T[1]))])
          ((curry(table, 'sparse')@Statistics:-Tally)~([M]))
;

MultisetIntersect2:= (M::seq(list))->
     select(
          `in`,
          [seq(`$`(op(_[1])), _= ListTools:-Classify(lhs, op~(Statistics:-Tally~({M}))))],
          `intersect`(seq({_[]}, _= M))
     )
;

Note that ListTools:-Classify is essentially linear in time (and it's a very short and beautiful procedure to read), and that set membership checks (as opposed to list membership check) are logarithmic in time because sets are stored sorted.

What's the longer, easy procedure that you has in mind?

@vv 

For common multiplicity, it'd be

L:= (A::list,B::list)-> select(`in`, B, select(`in`, A, B));

You have contradictory substitutions such as delta[1,1]= 1 and delta[1,1]^2= 0. You'll need to clarify what you mean by those. Such alternative arithmetic may be possible in Maple, but I want a clarification of your meaning before I delve into it.

Regarding the third exercise, it's a Pythagorean spiral, not an Archimedean spiral.

Take heart Jaynorms: The procedures for your exercises 1, 2, and 3 can be written in 1, 2, and 3 lines respectively (I just did it), although I don't recommend that you try to make them that short. So, they're not that hard. For exercises 2 and 3, all the math that you need is in the respective Wikipedia pages.

Regarding 3: I found this much easier to do in polar coordinates:

plot(..., coords= polar);

The first argument of plot can be a list of points (or a list of lists of points), each point being a list of two numbers. So,

  1. Compute the endpoints of the radial arms in polar coordinates. The endpoint of the nth arm can be computed directly in polar coordinates; it doesn't need to be done relative to the previous arm.
  2. Plot a list of points to connect the endpoints.
  3. Plot a list of lists of points to connect each endpoint to [0,0].

Don't try to plot the triangles separately; that's harder.

 

@asa12 

If you execute 

f := a*b*d - b;
subs(a=2,subs(b=n, subs(c=1, subs(d=0, f))));

then of course f = -n. Is that what your Question is about?

You can send me email by using the button "More" at the bottom of this Reply. Pull down the list and select "Contact Author."

@Preben Alsholm Thanks for the correction, Preben and Kitonum. Yes, the continuity of the parametrization is important. And so is having a sufficiently large enough number of points plotted.

My guess is that you want a cone with an elliptical base, the ellipse having a given center c and eccentricity e, and the vertex being c+v where is what you call the axis vector. Is that right? And, if so, do you want that ellipse to be in the xy-plane with its axes parallel to the coordinate axes? 

It doesn't seem possible, unless n = 0. Would you please post a worksheet where this happens?

@shadi1386 

Are your f(x) values in flist exact values, measured values, or approximations? If they're measured or approximate, do you have some general guess for the mathematical form of f(x), such as rational function, exponential, exponential with sinusoidal fluctuations, etc.? And is that guess based on theoretical considerations or just on eyeballing the scatter plot?

The only difference that I see between the two expressions in your original Question is that the latter has a "partial" d where the former has a regular d. Computationally, this makes not a whit of difference, and it boggles me that no one has pointed that out yet. Thus, I can only assume that your only issue is not computational, but rather formatting a document for display. Is that correct?

@Wadyan 

What you are calling an n-dimensional plot is ordinarily called an (n+1)-dimensional plot. I will continue to use the n+1 designation.

Note that the ways that you're animating the 2- and 3-D plots are not at all analogous. In the 2-D case, you're animating by increasing the domain of the independent variable from left to right. In the 3-D case, you're animating by scaling (rather than truncating) the dependent variable.

Both of my animations below are done by generating the final frame as static base plot and then generating each frame as a manipulation of that base plot.

U:= RandomTools:-Generate(float(method= uniform, range= 0..1), makeproc):

frames:= 2^5:
points:= 2^9:
P2:= plot(x-> abs(x)*U(), -5..5, adaptive= false, numpoints= points):
Pts:= plottools:-getdata(P2)[3]:
plots:-display(
     [seq(plot(Pts[..round(f*points/frames), ..]), f= 0..frames)],
     insequence, thickness= 0
);

frames:= 2^5:
points:= 2^7: #2^7 in each (x,y) dimension. Total points = 2^14.
P3:= plot3d((x,y)-> abs(x)*U()+abs(y)^2*U(), -5..5, -5..5, grid= [points$2]):
plots:-display(
     [seq(plottools:-scale(P3, 1, 1, f/frames), f= 0..frames)],
     insequence,
     shading= zhue, axes= frame, transparency= .5, style= wireframe, thickness= 0
);

In a worksheet, feel free to increase the FPS (Frames Per Second) for either of these.

@Spartan 

I already anticipated your most-recent followup question, and I was adding a paragraph about builtin commands to my most-recent Reply and you were writing it. So, go look at that Reply again.

While diff itself is builtin, the code which controls the differention of most functions isn't. See, for example,

showstat(`diff/sin`);

@Spartan 

Diff is an inert function: It has no code; it's just a name. It serves as a placeholder for a differentiation operation which hasn't been performed, but which may be performed in the future. An inert function is converted to its active form by the command value. Other examples of predefined inert functions are Int, Eval, LimitSum, and Product. In each of those cases the active form is the corresponding lowercased command; however, it's neither necessarily true that an inert/active pair are capitalized/lowercased, nor that an inert function has any active form---indeed, most don't. (When they don't have active forms, they tend to be called unevaluated functions rather than inert functions, but this distinction has no practical significance.)

You can see that Diff is an inert/unevaluated function by doing eval(Diff). Since the result is simply Diff, it's inert.

Sometimes an inert function is used to achieve a certain prettyprinted display. In that case, there's a corresponding print procedure. In the case of Diff, the print procedure is `print/Diff`. The execution of the print procedure has no affect on the mathematical computation---it just affects the display. There are two ways that print procedures can be named: They can be named `print/...` (as with Diff), or, in the case of an object (a very recent invention), they can appear as a procedure named ModulePrint in the object's defining module.

There are a few hundred fundamental (and mostly low-level) commands that are builtin. These aren't written in Maple, and their code isn't viewable. The command diff is builtin. This can be detected by

showstat(diff);
Error, (in showstat) cannot debug built-in functions

However, int isn't builtin; it's written in Maple, and you can see its code.

 

@Markiyan Hirnyk Thank you for pointing out the error in my procedure. I had inadvertenty pre-evaluated the module's locals before testing the procedure, so I failed the see that in the general case they need to be evaluated inside the procedure. Please use the procedure in my most-recent Reply above.

Note that the corrected procedure is still ad hoc to the given module, which has no exports. With some minor updates, it'll handle exports and apply itself recursively to submodules.

First 457 458 459 460 461 462 463 Last Page 459 of 709