Carl Love

Carl Love

28130 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@acer I agree totally. Indeed, I almost added "However, I agree with Acer that that's not a good reason to avoid restart," but I didn't want to put words in your mouth.

Still, there may be other more-valid reasons to unassign all variables (or all variables of a certain type), and the above command is not-at-all obvious: Angle brackets are the only brackets that work.

@tomleslie Maple doesn't seem to have a problem plotting (in 2-D) things that get infinitely steep if you include the coordinateview option (or view option). For 3-D plots, it's a different story.

@dharr I think that coordinateview = [0..2, 0..Pi] may be closer to the OP's wishes.

By multiplying cos(t) and sin(t), you are converting to Cartesian coordinates. You don't want to do that if you're using the polarplot command. On the other hand, if you change your polarplot to simply plot and get rid of the coordinateview option (possibly replacing it with the view option), then you'll get a plot of a parametrized parabola in Cartesian coordinates.

@Rouben Rostamian  Yes, the solution produced by dsolve is much better analytically. But I tried several approaches, and I could not derive it myself.

On the other hand, I was able to derive my expression just using mental algebra.

@dharr Yes, I knew that entries didn't necessarily return the elements in order. And I knew that indexing to extract from the tables would make them take even longer. Sorry that I didn't mention that; I simply said "There are several other possibilities for the indexing." You see, I knew that the table methods were already slower than the Vector method, so I saw no need to go further because my point was to prove that the Vector method was faster.

@Axel Vogt But this Question isn't about plotting an inverse function. It's about plotting an implicitly defined function (with branch cuts).

Please learn how to enter expressions. The rules are the same for most computer languages. In particular, learn the order of operations so that you don't use extra parentheses! You used 26 pairs of parentheses in your expression. Only 6 are required. Extra parentheses make it difficult to balance the parentheses when you make the inevitable typo. The order of operations is the same as you learned in high-school algebra.

Some specific rules:

  1. A numeric coefficient followed by a variable requires an explicit multiplication sign. Thus, 4*T[g].
  2. A single variable name or a nonnegative constant never needs to be surrounded by parentheses (unless it's the argument of a one-argument function).
  3. When a variable name has a subscript (or index), the subscript is considered part of the name. Thus rule 2 applies to subscripted names also.
  4. When a name has both a subscript and an exponent, the subscript comes first, and no parentheses are needed. This follows from rule 3. Thus, T[0]^2.
  5. Sometimes a negative constant requires parentheses, such a delta/(-2). However, why not just make that -delta/2?
  6. Multiplication and division associate left to right, thus (a*b)/c a*(b/c) = a*b/c =a/c*b. So, use one of the latter two forms.

@acer Many thanks for taking time from your vacation to answer me. I'll refrain from asking Questions until you return.

Your expression is not real-valued (or even close to real-valued) anywhere in your parameter ranges. So, how do you want to proceed? plot just the real part? plot the real and imaginary parts separately? something else?

@hasselhof The horizontal axis of your plot doesn't have linear scaling. Is it logarithmic?

@hasselhof Unfortunately, for a nonlinear fit, Statistics:-Fit only finds a local minimum of the sum of the squares of the residuals. You can use option initialvalues to guide it to some extent, but there's no way to impose constraints. There is a Maple package called DirectSearch that has a program DataFit that attempts to find a global minimum. There is no algorithm that guarantees a global minimum. DirectSearch needs to be downloaded from the Maple Applications Center.

I see that you posted the data file, so I'll see if I can fit this.

@Kitonum Building a list in a for loop from a dynamic vector is a little bit faster than using a table or a remember table. Here are four ways to build a list in a for loop. There are several other possibilities for the indexing.

 

``

restart:

#List building using dynamic vector
P:= proc(n)
local R:= Vector(), k;
     for k to n do R(k):= k end do;
     [seq(k, k= R)]
end proc:

CodeTools:-Usage(P(2^22)):

memory used=432.55MiB, alloc change=255.09MiB, cpu time=4.68s, real time=4.68s

 


restart:

#List building using regular table
P:= proc(n)
local T,k;
     for k to n do T[k]:= k end do;
     [entries(T, 'nolist')]
end proc:

CodeTools:-Usage(P(2^22)):

memory used=0.57GiB, alloc change=398.43MiB, cpu time=5.21s, real time=5.26s

 


restart:

#List building using remember table
P:= proc(n)
local R,k;
     for k to n do R(k):= k end do;
     [seq(R(k), k= 1..n)]
end proc:

CodeTools:-Usage(P(2^22)):

memory used=0.63GiB, alloc change=457.24MiB, cpu time=8.06s, real time=8.06s

 


restart:

#List building using extracted remember table
P:= proc(n)
local R,k;
     for k to n do R(k):= k end do;
     [seq(k, k= op(4, eval(R)))]
end proc:

CodeTools:-Usage(P(2^22)):

memory used=0.60GiB, alloc change=426.57MiB, cpu time=5.69s, real time=5.72s

 

NULL

``

 

Download List_building.mw

Regarding _rest: This refers to arguments that are passed but not declared. It's equivalent to args[nargs+1..]. See ?using_parameters.

@Carl Love I ask again in case someone who knows the answer didn't notice the first time: What, if anything, is the difference between rtable_eval(A, inplace) and map[inplace](eval, A)?

Are you missing some parentheses in your formula? Do you mean

0.5*a*erfc(0.5*2^0.5*((-x+m1)/s1)) + (0.5-0.5*a)*erfc(0.5*2^0.5*((-x+m2)/s2))?

As you have it, m1, s1, m2, s2 can't be uniquely determined because common factors in the fractions can cancel. Besides, (-x+mu)/sigma looks normal; -x+mu/sigma doesn't.

First 469 470 471 472 473 474 475 Last Page 471 of 711