Preben Alsholm

13471 Reputation

22 Badges

20 years, 298 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

frequency := [1 = 6, 2 = 7, 3 = 91, 4 = 10];
(`[]`@op)~(frequency);

#To understand what is going on you can take a look at the outputs of the following two commands. f~ means elementwise use of f and @ is used for composition.
op~(frequency);
`[]`~(frequency);

A version more easily understood perhaps is

map(eq->[lhs(eq),rhs(eq)], frequency);

_Z is just the name used in RootOf for the unknown. The answer from solve in this case is really just a rewriting of the question. This may seem silly, but Maple can work with RootOf expressions in several ways.

Besides that, you should use exp(-x) instead of e^(-x) if you are using the exponential function.

I have been sorting the output according to the sizes of the eigenvalues using the following procedure, which also contains a description:

EigenSort:=proc(ev::Vector,P::Matrix,
krit::procedure:=((s,t)->evalb(
evalf(Re(s)<Re(t)) or evalf(Re(s)=Re(t)) and evalf(Im(s)>=Im(t)) )))
local n,EV,SEV,L,krit2;
description "Sorts output from Eigenvectors(A). As an optional third argument can be given the sorting procedure. The default procedure sorts according to the real parts of the eigenvalues. For a pair of complex conjugates the one with positive imaginary part is taken first.
The default procedure uses evalf before compairing.";
uses LinearAlgebra;
n:=Dimension(ev);
EV:=convert(<ev|<seq(i,i=1..n)>>,listlist);
krit2:=(s,t)->krit(op(1,s),op(1,t));
try
SEV:=sort(EV,krit2);
catch:
error cat(procname," cannot sort the given input");
end try;
L:=map2(op,2,SEV);
<seq(ev[L[i]],i=1..n)>,Matrix([seq(Column(P,L[i]),i=1..n)]);
end proc:


Describe(EigenSort);
A:=LinearAlgebra:-RandomMatrix(2);
EV1:=LinearAlgebra:-Eigenvectors(A);
EV2:=EigenSort(EV1);

Assuming that the image part of your code is

N:=t->( (1/N0-1)*exp(-2*r*t)+1)^(-1/2);

then N0 =1 would give you the constant function 1. Also try other values of N0.

DEtools[linearsol] finds (according to its help page) "solutions of a first order linear ODE". Thus you shouldn't expect any success since your ode1 is 2nd order.

However, dsolve finds solutions for ode1 as well as for the one obtained by your proposed change of variables:

ode1 := diff(y(x),x$2) + (lambda-x^2)*y(x) = 0;
eval(ode1,y(x)=exp(-x^2/2)*y1(x));
isolate(%,diff(y1(x),x,x));
ode2:=simplify(%);
dsolve(ode2);
dsolve(ode1);

If for some reason you only have the plot then you can use plottools:-getdata to get the data as in this example.

res:=dsolve({diff(y(t),t)=x(t),diff(x(t),t)=-y(t),x(0)=0,y(0)=1},numeric);
p:=plots:-odeplot(res,[x(t),y(t)],0..2*Pi):
p;
plottools:-getdata(p);
M:=%[-1];
plot(M,style=point);
M[1..5,1..2];

Notice, however, that from this plot in the phase plane you don't have information about the times the points were visited. If you need to save data it is clearly best not to extract from plots but do as shown by Georgios in his answer. 

I have uploaded an answer to your previous question in the form of a worksheet. It is by no means perfect, but does give results in reasonable time it seems to me.

MaplePrimes12-09-21F.mw

As a start try the somewhat unrelated loop:

eps:=.0001:
for N from 1 while abs(evalf(ln(1+1/N))) >=eps do end do:
N;

Notice that no job is done between "do" and "end do".

What type do the elements have? If they are floats or rational numbers there ought not be a problem. But if not huge symbolic expressions could easily build up.

Did you not use double quotes? As in

printf("The expected value is %12.8f",evalf[20](Pi));

When f is a known function of 6 variables you can define the procedure Z2 by
Z2:= subs(Eq75,f(t,phix(t), phiy(t), phiz(t), thetax(t), thetay(t))):

Then you can try Z2(ts);

There are a lot of programs out there. But here is a simple start.

All you need to do is change the definition of f and define any relevant constants, in the example below that would be k, x0, xm, N.
The first plots using complexplot accept real as well as complex data.

restart;
with(plots):
f:=x->k-x^2;
k:=0.7+.2*I:
#k:=1.42:
x0:=.5: #Initial value
xm:=5: #Maximal abs(x) allowed
S:=x0:
N:=200: #Number of iterations
to N while abs(x0)    x0:=evalf(f(x0));
   S:=S,x0;
end do:

Ns:=nops([S]):
complexplot([S],style=point,symbol=solidcircle,symbolsize=15);
display(seq(complexplot([S[1..n]],
style=point,symbol=solidcircle,symbolsize=15),n=1..Ns),insequence=true);

#For real data only:
display(plot(ListTools:-FlattenOnce([seq([[S[i-1],S[i]],[S[i],S[i]]],i=2..Ns)])),
plot([f(x),x],x=min(S[1..Ns])..max(S[1..Ns]),color=[red,blue]));
pf:=plot([f(x),x],x=min(S[1..Ns])..max(S[1..Ns]),color=[red,blue]):
pa:=display(seq(plot(ListTools:-FlattenOnce([seq([[S[i-1],S[i]],[S[i],S[i]]],i=2..n)])),n=2..Ns),insequence=true):
display(pa,pf);

I had success with this in Maple 16:

restart;
V:=Vector(datatype=float[8]);
for i to 300 do V(i):=evalf(Pi/i) end do:
V;
W:=Vector(datatype=anything);
for i to 300 do W(i):=cat("Entry #",i) end do:
W;
W(300);

but mserver.exe stopped working when in a fresh worksheet I tried

restart;
W:=Vector(datatype=string);
for i to 5 do W(i):=cat("Entry #",i) end do:

 

I have been using &* for that purpose:

a&*LinearAlgebra:-RandomMatrix(2,2);
eval(%,`&*`=`*`);

It could as well have been &p or &m or &. or whatever you like. See the help:
?&

If you extend 'value' like this:

`value/&*`:=proc() `*`(args) end proc:

then you can do like this:

p:=a&*LinearAlgebra:-RandomMatrix(2,2);

value(p);

First 115 116 117 118 119 120 121 Last Page 117 of 158