Preben Alsholm

13728 Reputation

22 Badges

20 years, 243 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

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,%);

A reason for Li(1) not being in the remember table for Li could be that Li is an analytic function having branch cuts along the intervals (-infinity,0) and (0,1) and that  Li(z) is not continuous onto the branch cuts from either above or below. (see the help page for Li).

If you try the following lines you will see this discontinuity illustrated near z = 1 when looking at things numerically. The results from 'series' (and 'limit') seem to be  wrong, however.

restart;
with(plots):
eps1:=.001:
complexplot(Li(1+eps1*exp(I*t)),t=0..2*Pi,thickness=3);
animate(complexplot,[Li(1+eps1*exp(I*t)),t=0..T,thickness=3],T=0..2*Pi);
limit(Li(1+r*exp(I*t)),t=Pi,right) assuming r>0;
limit(Li(1+r*exp(I*t)),t=Pi,left) assuming r>0;
eps2:=.00001:
evalf(Li(1+eps1*exp(I*(Pi+eps2))));
evalf(Li(1+eps1*exp(I*(Pi-eps2))));
series(Li(1+r*exp(I*t)),t=Pi,3);
S3:=convert(%,polynom);
evalf(eval(S3,{r=eps1,t=Pi-eps2}));
evalf(eval(S3,{r=eps1,t=Pi+eps2}));

The following works, but does it serve your needs?

Parameters2 := [ s = 1 ];
Functions2 := [ U = 'proc(c) global s; piecewise(s=1,log(c),(c^(1-s)-1)/(1-s)) end proc' ];
eval(eval(U(c), Functions2), Parameters2);
First 130 131 132 133 134 135 136 Last Page 132 of 160