Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@mriedel It's not really another issue. It is the issue. The command residue works by simply calling series. Check out the simplistic code with showstat(residue).

@Markiyan Hirnyk It isn't possible for Maple to produce an animation without a fixed number of frames and hence cycling. So don't blame vv's code for this defect.

@mriedel Maple has no trouble converting r to algebraic form. What it has trouble with is simplifying that algebraic form to something which is recognized as a pole of the expression.

rr:= convert(r, radical);

     rr := 2^(1/4)*((1/2)*sqrt(2-sqrt(2))+(1/2*I)*sqrt(2+sqrt(2)))

evalf(residue(z^2/(z^4 + 2*z^2 + 2)^2, z= rr));

     Float(infinity)-Float(infinity)*I

I see in the MSE link that you have given a simplication r1 => r. I don't see a simplification r => r1, which is what is needed for residue to work.

@vv Vote up.

But I think that it'll be much smoother and much more like the original with much less reconfiguring of E and F. I completely removed the the line

if rand(1..10)()=1 then FE() fi;

and I got a fine animation for the 200 frames. So, I'd make the 10 much larger. I'd also set the maximum number of entries of E and F that can change on any iteration at about 1/3.

An alternative would be to change a very small fraction of E and F on every iteration. I'm implementing this idea right now.

 

@mskalsi Most of my worksheets are short, so I don't need to use the feature much. However, I have my global setting such that it always asks me to select a server, just in case.

@Markiyan Hirnyk Ah, I didn't know that, Vote up, because now Explore seems betters than an animation.

What do you want to know about cmaple? It's on-board help page is very thorough.

@Thomas Dean Yes, plot and plot3d commands (and maybe a few other plotting commands) use, when possible, something called evalhf instead of evalf. The evalhf tends to be 20-30 times faster. The h stands for hardware.

Here's how evalhf can be applied to the current example:

restart:
st:= time():
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m):
f:= unapply(abs(y), m):
n := 500: ## sample size
M := <seq(2.*idx/n,idx=1..n)>: ## m
Y := map[evalhf](f,M)+~Statistics:-Sample(Normal(0,3), n)^+: ## signal + noise
time()-st;

restart:
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m):
f:= (x) -> abs(subs(m=x,y)):
n := 500: ## sample size
M := <seq(2.*idx/n,idx=1..n)>: ## m
Y := map[evalhf](f,M)+~Statistics:-Sample(Normal(0,3), n)^+: ## signal + noise

                             0.062
Error, unable to evaluate built-in function `subs` in evalh

See? The evalhf is very restricted in the commands that it can use. They're listed at ?evalhf,fnclist.

@samira moradi Use command Export, ExportMatrix, or ExcelTools:-Export. They all get the job done one way or another.

@Thomas Dean The notation A:-B is definitely superior, more robust, and clearer to read, and less ambiguous than A[B]. It's a shame that the latter is emphasized in the help pages. There is a rare situation where A[B] is required: When B isn't literally the name of an export of module but is an expression which evaluates to the name of an export.

I took your code, commented out most lines, and wrote under those lines my suggested improvements:

restart:
with(Statistics):
y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m);
## fix complex values
#f := (x) -> abs(evalf(subs(m=x,y)));
f:= unapply(abs(y), m);

n := 500;

## mean 1, std dev 0.5
#X := RandomVariable(Normal(1, .5)):
M := Sample(Normal(1,.5), n):
#Y := [seq(f(M[idx]),idx=1..n)]:
Y:= f~(M):

#A:=[seq(idx,idx=1..n)]:
#plot(A,M,style=point,symbol= circle, symbolsize= 1,title="Values of M");
Statistics:-Histogram(M, title= "Values of M", frequencyscale= absolute);
#plot(A,Y,style=point,symbol= circle, symbolsize= 1,title="Values of Y");
Statistics:-Histogram(Y, title= "Values of Y", frequencyscale= absolute);
plot(Y,M,style=point,symbol= circle, symbolsize= 1,title="M vs Y");
#DataSummary(M); DataSummary(Y);
DataSummary~([M,Y])[];
#Data:=Matrix(n,2,[seq([Y[idx],M[idx]][],idx=1..n)]):
Data:= <Y,M>^+:

plot(
     [[y, m, m= 0..2], Data], labels= ['y', m],
     style= [line, point], color= [red, black],
     symbol= point, symbolsize= 1
);

@Markiyan Hirnyk Sorry, you're right, I used the word hyperplane incorrectly. I meant a nontrivial affine subspace.

@Thomas Dean To generate the Data, I extracted the point data from the first plot and added a Normal(0, .1) to each second coordinate. Like this:

y := int(1/(-0.4016e-1*m^(2/3)-0.211e-3*m^(5/3)), m):
P:= plot([y, m, m= 0..2]):
Data:= op([1,1], P):
Data[..,2]:= Data[..,2] + Statistics:-Sample(Normal(0,.1), op([1,1], Data))^+:

That's all there is to it.

 

@Ronan See ?use, ?object,operators, ?ProgrammingGuide,chapter09.

@Markiyan Hirnyk Agreed. In some ways Explore is better than an animation (flexibility). The animation is automatic and exportable.

@vv Iterator overwrites the same Array on each iteration rather than generating a new Array. So it seems likely that the indices would be returned in the same order on each iteration. Only a kernel programmer could say for sure.

First 414 415 416 417 418 419 420 Last Page 416 of 709