Carl Love

Carl Love

28035 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Carl Love In an earlier version of the code above, I forgot to include the binomial coefficients. The code above has been corrected.

@Racine65 If you want to get a teapot, consider using plots:-tubeplot rather than plots:-spacecurve. The radius of the tube can be set or parameterized.

@Chouette There's also evala(Normal(...)) and radnormal(...).

@acer It should be noted that parametric returns nested lists, which need to be flattened for most programmatic uses, so they're syntactically different from other solve return values. It's not a big deal here. However, the more-usual case is that you get a piecewise of nested lists, or even a nested piecewise of nested lists. They are awkward to deconstruct.

@ecterrab Could you please show how to apply it in this case, where the goal is to reduce the independent variables to simply y? I see that ?dchange has an example of reducing the number of independent variables, but I can't get anything to work in this case (which seems like a simple case, since my one line 

convert(simplify(eval(PDE2, u(t,x)= U(x-a*t)), {x-a*t= y}), diff)

does it). It would be preferable to have one command, dchange, to do it rather than my composition of convertsimplify, and eval.

@acer That the first workaround that you proposed -- adding a dummy variable to the solved-for set -- works provides a small bit of indirect evidence in favor of my theory. 

@Kitonum I think that a slight improvement would be continuity with respect to time. You can do this by making the t-range an integer multiple of the period.

@sand15 There's no need to normalize your random numbers to a 0..1 float scale. The integers generated by naked rand() are good enough, and more efficient.

@Magma In most cases, randomize() should only be used as a top-level command, and it should only be used once (per restart).

Kitonum's code is extremely inefficient. I will try to rewrite it.

@Magma Your results indicate that the output= permutation part isn't working. I'll come up with something else in a few minutes.

@Magma Try this:

RandPerm:= (n::nonnegint)-> sort(['rand()' $ n], 'output'= 'permutation'):
#Example:
RandPerm(9);

      [3, 1, 6, 7, 5, 9, 2, 8, 4]

I'm sure that my rand command will work in Maple 15, but I'm not sure about the output= permutation option to sort. Let me know if that works. If not, I can easily make a workaround.

@Kyle White Your account seems suspicious to me. If you don't say something meaningful about Maple within an hour, I'm flagging as a spammer.

@Carl Love It is very easy to modify the above code so that the curves are plotted in the complex plane parameterized for 0 <= k <= 1. All that's needed are two small changes to the odeplot; however, I made a few other simplifications to the overall code also.

restart:
Digits:= trunc(evalhf(Digits)):
gm:= 1/sqrt(1-V^2):
T:= w-k*V:
S:= w*V-k:
H:= numer(T*S^2*gm^3*3/2+I*S^2(1+I*27/4*T*gm)*gm^2-(1+I*27/4*T*gm)*(1+I*5*T*gm)*T*gm):
Vlist:= [
   Record("V"= 0.8, "color"= "Black", "plot"= ()),
   Record("V"= 0.9, "color"= "Red", "plot"= ()),
   Record("V"= 0.99, "color"= "Blue", "plot"= ())
]:
R:= [solve(H, w, explicit)]:
d:= nops(R): #number of roots
for v in Vlist do
   S:= dsolve(
      {   #odes:
          seq(eval(diff(r[i](k),k) = diff(R[i],k), V= v:-V), i= 1..d),
          #initial conditions:
          ([seq(r[i](0), i= 1..d)] =~ evalf(eval(R, [V= v:-V, k= 0])))[]
      },
      numeric
   );
   v:-plot:= plots:-odeplot(S, [seq([Re,Im](r[i](k)), i= 1..d)], k= 0..1, color= v:-color)
od:   
plots:-display([seq(v:-plot, v= Vlist)], size= [987,610]);

@mmcdara Here's another anomaly related to weights (but not to DataSummary). Compare

Median(X, weights= Y) 

with

Quantile(X, 0.5, weights= Y).

I guess it's somewhat a matter of opinion: Do you feel that those two should be equal? The help ?Quantile does explicitly describe the eight (!) formulas that can be used, but doesn't describe how weights are handled by any of those 8. And, in my opinion, none of the 8 are adequate for the weighted case.

@a_simsim Off the top of my head (someone please correct if I've forgotten some), Maple's only mutable structures are tables, rtables (which includes Vectors, Matrixes, and Arrays), modules (which includes objects and Records), and procedures (which includes arrow expressions such as x->x^2); all other structures, including containers such as sequences, lists, and sets, are immutable.

A benefit of an immutable structure is that only one copy can exist (per kernel) in memory, with all references being pointers to that single copy. Part of the process called automatic simplification is to match nascent structures with those already stored (in a master table called the simplification table) and eliminate duplicates. Thus, checking equality of immutable structures becomes as simple as comparing their addresses, and is thus very quick. All this happens in the background, but being aware of it helps one to write efficient code.

A drawback of an immutable structure is that any change made to it necessitates that the entire structure be recreated, no matter how large it is. So, one of the most-common causes of slow performance is to add elements one at a time to a sequence, list, or set. In almost all such cases, a table or Vector should be used instead.

The benefits and drawbacks of mutable structures are just the reverse of those of immutable structures: Modifying (or adding to) the structure is trivial, but equality comparisons are not, and duplicate copies consume memory.

First 279 280 281 282 283 284 285 Last Page 281 of 708