Preben Alsholm

13743 Reputation

22 Badges

20 years, 310 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

In the line assigning 'zeros'there are 3 typos. It ought to be

zeros := [RootFinding:-Analytic(eq161,alpha,re=0..10,im=0..10,digits=8)];

However, I didn't get anything in a reasonable time in Maple 15, but did in Maple 12.

Instead I did as follows.

eq:=eq161/alpha^4:
solve(eq=0,alpha);
evalf(%);
eval(eq,alpha=%);
evalf(%);
#One nontrivial solution found!

#The 3d plot suggests that there are only real or purely imaginary solutions.

plot3d(eval(ln(abs(eq)),alpha=x+I*y),x=0..10,y=0..10,axes=boxed);

#Your expression has symmetry properties, which imply that if alpha is a solution so is I*alpha (and -alpha and -I*alpha). Thus we may restrict ourselves to real positive values of alpha.

plot([Re(eq),Im(eq)],alpha=0..10,-10..10,thickness=2);
#Attempting 'Analytic') on the following narrow rectangle exceeded my patience, so I restricted it as seen below.
#RootFinding:-Analytic(eq,alpha,re=0..10,im=-0.1..0.1);
RootFinding:-Analytic(eq,alpha,re=0..1,im=-0.1..0.1);
eval(eq,alpha=1/2);
RootFinding:-Analytic(eq,alpha,re=1..2,im=-0.1..0.1);
RootFinding:-Analytic(eq,alpha,re=4..5,im=-0.1..0.1);
RootFinding:-Analytic(eq,alpha,re=7..8,im=-0.1..0.1);

Here are two ways.

#First a general use of 'animate' (see help page for animate):

animate(odeplot,[LS1,dvars,t=0..T,axes=frame,numpoints=2400,color=blue,orientation=[-20,75],title="Lorenz Attractor"],T=0.1..55,frames=100);

#The second method is simpler, but relies on the fact that the plot procedure is odeplot.

odeplot(LS1,dvars,t=0..55,axes=frame,numpoints=2400,color=blue,orientation=[-20,75],title="Lorenz Attractor",frames=100);



You could use 'selectremove' instead of 'select'.

L:=map(i->[selectremove](has, i, g[]), [op(Ex)]);
Base:=map2(op,1,L);
Cf:=map2(op,2,L);
#Other versions:
curry([selectremove],has)~([op(Ex)],g[]);
map(curry([selectremove],has),[op(Ex)],g[]);
op~(1,L);
op~(2,L);

Within the maximal interval of definition the solutions are the same.

This is Maple 15.

eq:=diff(y(x),x)=x^2*y(x)^4;
res:=dsolve({eq,y(1)=1});
odetest(res,{eq,y(1)=1});
simplify(res) assuming x^3<2;
plot(rhs(res),x=-2..2^(1/3),0..5);

In your picture the parenthesis following the exponential is missing. (Post a text version!)

The main variables ought to be {x,k[1],k[2]} if I understand your intention.

s:='s':
y:=exp(-6*x)*(k[1]*sin(4*x)+k[2]*cos(4*x)):
match(0=diff(y,x,x)+B*diff(y,x)+C*y,{x,k[1],k[2]},'s');
s;

#Result {B = 12, C = 52}

Your variable myPlot is a sequence of plots, thus only the first plot in the sequence is used by getdata and the rest are considered extra arguments (options) but are ignored, since they don't have the form 'element'= ....

You could do

getdata~([myPlot]);

to get a list of lists of plot data.

I did the following with the example from the help page for getdata.

data:=getdata~([p1,p2]);
ExportMatrix("F:/Maple/test1.txt",op([1,-1],data),delimiter=",");
ExportMatrix("F:/Maple/test2.txt",op([2,-1],data),delimiter=",");



You get

eval(rhs(ode1),{H(z)=h,z=0});
                 0.7812500000 - 0.5075770687 I

which explains the error message:


Error, (in HH) cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

Your first example is not surprising as in fact (as you are suspecting) a and b point to the same location in memory (try addressof(a); addressof(b);)

In your second example you can again try addressof(a); addressof(b);

I also think it is interesting that after assigning y:=2, only the y in a is immediately evaluated to 2.

The evaluation of y in b is done if you just do b[2];

On the vector itself you can do eval~(b);

indets(minimum[2],`=`);
subs(%,x);

You don't give all the code for norma, but the problem is exhibited in this simple example:

f:=x->if x<Pi/2 then sin(x)^2 else cos(x) end if;
int(f(x),x=0..2*Pi);

#In this simple case using piecewise instead is a good idea

fp:=x->piecewise(x<Pi/2,sin(x)^2,cos(x));
int(fp(x),x=0..2*Pi);

A plot using implicitplot:

eq:=(x^2+y^2)^2=x^2-y^2;
plots:-implicitplot(eq,x=-2..2,y=-2..2,gridrefine=2,scaling=constrained);

Converting to polar coordinates:

simplify(eval(eq,{x=r*cos(theta),y=r*sin(theta)}));
R:=solve(%,r);

The curve is now parametrized by theta  r = r(theta)

plots:-polarplot(R[2],theta=0..2*Pi);

You don't say in which form your imported data are kept (matrix, vector, sequence, or list). If a list, sequence, or vector the following should work.

I fabricate some data (here just a sequence S):


S:=seq(rand(1..9)(),k=1..365):

If I understand your intention correctly then you just do:

seq(evalf(y)/S[x], x = 1..365);

If you would rather like to operate on the previously computed sequence Y below then you could use elementwise division:

Y:=seq(evalf(y), x = 1..365):
Y/~S;



The first version:

mul(x[2]-x[j],j in {$1..4} minus {2});

The second and more general version:

m:=i->mul(x[i]-x[j],j in {$1..N} minus {i});
N:=4:
m(2);
N:=10:
m(2);

You shouldn't use a float in your test. You get roundoff error.

Try

subbedBackIn := eval(myDeterminant, solutions[5]); # put solution back into original equation
expand(%);
simplify(%);

Numerically you can get an answer by using dsolve only, but the solution is found only between 0 and 1/2:

resNum:=dsolve({diff(y(t),t) = k*(y(t)-10), y(0)=70, y(1/2)=50},numeric,output=listprocedure);
K,Y:=op(eval([k,y(t)],resNum));
K(.3);
plot(K,0..1,-1..0);
plot(Y,0..1);
#More natural is it to do the following, variants of which you have probably already tried.
resEx:=dsolve({diff(y(t),t) = k*(y(t)-10), y(0)=70});
solve(eval(resEx,{y(t)=50,t=1/2}),{k});
eval(resEx,%);

First 130 131 132 133 134 135 136 Last Page 132 of 160