Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 362 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

Are you the same person who asked this same Question on Stack Exchange last week? If you are, then I guess that you're not satisfied with the Answer that you got there---the same as Preben's Answer below: Use Arrays instead. Is that right? Then you really, really want to do this with actual lists, right? Well, it is possible, despite what someone told you on Stack Exchange. It's done by overloading the indexing operator, which is represented in prefix form as `?[]`. But before I go into all the details of that, I'd like to know why you can't do what you want to do with Arrays. Basically, I'd have to create an object which is as much like a regular list as you need it to be. (Indeed, the underlying structure will be an actual list.) So, I need to know what features of lists you'd be using so that I can implement them.

The OP uses constants as a global variable name. This is a pre-defined global variable that is, very unfortunately, not proctected. It amazes me that MapleSoft would do this with such an obvious name that someone might use as a variable. I don't know exactly what this global variable is for, but its predefined value is 

constants;

     false, gamma, infinity, true, Catalan, FAIL, Pi


Redefining constants doesn't seem to mess up the value of Pi, but constants must exist for some reason, so I wouldn't redefine it unless I was defining a new constant, and, in that case, I'd append to it, not totally redefine it. So, anyway, I wouldn't be at all surprised if this turned out to be the source of the mystery.

Update: I just changed the constants to Constants in the OP's code. It made no difference: Either way, I get the values that Tom reports, not the ones that the OP reports. Still, I recommend that constants not be used as a global variable name, even though that may cause no problem here.

 

@Vishal 

You're welcome. Did you finally get the plot? 

@brian bovril 

If you have a sum of terms Obj, and you want to extract the terms that have x, you can use

select(has, Obj, x);

This is not necessarily the same thing as the terms that have x and no other variable!

@Vishal 

The case of letters is important in Maple. What you have as pi should be Pi.

@Vishal 

The case of letters (as in uppercase/lowercase) is very important in Maple. The variable's name is UseHardwareFloats; you have useHardwarefloats.

@Vishal 

Using the same commands works for me:

UseHardwareFloats:= false:
plots:-complexplot(G, xx= -1e-13..1e-13);

Can you show the commands that you're using that aren't working?

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? 

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