Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@acer You are quite right. The following splits a plot structure containing a single curve, so is less general than the evalindets idea in that respect. Also individual curve options (like thickness and color are gone):

restart;
u:=sqrt(x^2-5)+3;
plot(u,view=0..15,thickness=6); p:=%:
M:=plottools:-getdata(p)[-1];
S:=ListTools:-Split(hastype,convert(M,listlist),undefined):
plots:-display(plot~([S]),p);

You don't need the p in the last line except for keeping the view option.

#Here is an updated version that seems to work well:

R:=proc(p) local f;
   f:=proc(curve)
      evalindets(curve,Or(listlist,Matrix),m->ListTools:-Split(hastype,convert(m,listlist),undefined))
   end proc;
   evalindets(p,specfunc(anything,CURVES),f);
end proc;

R(p); #Returns the plot hoped for

@acer You are quite right. The following splits a plot structure containing a single curve, so is less general than the evalindets idea in that respect. Also individual curve options (like thickness and color are gone):

restart;
u:=sqrt(x^2-5)+3;
plot(u,view=0..15,thickness=6); p:=%:
M:=plottools:-getdata(p)[-1];
S:=ListTools:-Split(hastype,convert(M,listlist),undefined):
plots:-display(plot~([S]),p);

You don't need the p in the last line except for keeping the view option.

#Here is an updated version that seems to work well:

R:=proc(p) local f;
   f:=proc(curve)
      evalindets(curve,Or(listlist,Matrix),m->ListTools:-Split(hastype,convert(m,listlist),undefined))
   end proc;
   evalindets(p,specfunc(anything,CURVES),f);
end proc;

R(p); #Returns the plot hoped for

Here is another way of removing HFloat(undefined) (as unfortunately seems necessary in Maple 16.02):

restart;
u:=sqrt(75-3*x^2);
plot(u); p:=%:
evalindets(p,Matrix,m->remove(hastype,convert(m,listlist),undefined));

#Turning the data matrix into a listlist makes it easier to remove undefined elements.
#To catch cases where the data (or some of it) in fact is already a listlist as in
http://www.mapleprimes.com/questions/142416-Problems-With-DEplot
#we could do
evalindets(p,Or(Matrix,listlist),m->remove(hastype,convert(m,listlist),undefined));

Here is another way of removing HFloat(undefined) (as unfortunately seems necessary in Maple 16.02):

restart;
u:=sqrt(75-3*x^2);
plot(u); p:=%:
evalindets(p,Matrix,m->remove(hastype,convert(m,listlist),undefined));

#Turning the data matrix into a listlist makes it easier to remove undefined elements.
#To catch cases where the data (or some of it) in fact is already a listlist as in
http://www.mapleprimes.com/questions/142416-Problems-With-DEplot
#we could do
evalindets(p,Or(Matrix,listlist),m->remove(hastype,convert(m,listlist),undefined));

@Axel Vogt Amazingly simple! And thank you!

@Axel Vogt Amazingly simple! And thank you!

@sanaz Why not settle for a numerical solution?

de := diff(x(t), t, t)+30*x(t)+.1*x(t)^3 = 29*cos(t);
#Series solution to order 15 (highest term order 14):
resser14:=dsolve({de, x(0) = 0, D(x)(0) = 0},x(t),series,order=15);
pol14:=convert(rhs(resser14),polynom);
resnum:=dsolve({de, x(0) = 0, (D(x))(0) = 0},numeric);
#The numerical solution seems to me so much more interesting than a series solution:
plots:-odeplot(resnum,[t,x(t)],0..10);
#odeplot allows you to show both together, if you so desire:
plots:-odeplot(resnum,[[t,x(t)],[t,pol14]],0..1,view=0..5);

#You may also take a look at
resser16:=dsolve({de, x(0) = 0, D(x)(0) = 0},x(t),series,order=17);
pol16:=convert(rhs(resser16),polynom);
plots:-odeplot(resnum,[[t,x(t)],[t,pol14],[t,pol16]],0..1,view=-5..5,legend=["Numerical","pol14","pol16"]);


@sanaz Why not settle for a numerical solution?

de := diff(x(t), t, t)+30*x(t)+.1*x(t)^3 = 29*cos(t);
#Series solution to order 15 (highest term order 14):
resser14:=dsolve({de, x(0) = 0, D(x)(0) = 0},x(t),series,order=15);
pol14:=convert(rhs(resser14),polynom);
resnum:=dsolve({de, x(0) = 0, (D(x))(0) = 0},numeric);
#The numerical solution seems to me so much more interesting than a series solution:
plots:-odeplot(resnum,[t,x(t)],0..10);
#odeplot allows you to show both together, if you so desire:
plots:-odeplot(resnum,[[t,x(t)],[t,pol14]],0..1,view=0..5);

#You may also take a look at
resser16:=dsolve({de, x(0) = 0, D(x)(0) = 0},x(t),series,order=17);
pol16:=convert(rhs(resser16),polynom);
plots:-odeplot(resnum,[[t,x(t)],[t,pol14],[t,pol16]],0..1,view=-5..5,legend=["Numerical","pol14","pol16"]);


It would probably help if you gave us the differential equation from which you obtain f(x).

As you give us f(x) above you end with  + ...  indicating that there are more terms (infinitely many, I suspect).

This is just a continuation of

http://www.mapleprimes.com/questions/142296-Pade-Approximation

Whether what you write is correct or not surely depends on what you intend to do.

You haven't answered the questions put by Carl Love and MacDude and now repeated by me:
Why approximate a series truncated to 3 terms (now a polynomial of degree 6 called f) by a more complicated expression e?

You are talking about finding a pade approximation to the original function. But you don't tell us what the original function is.

It doesn't happen with 1D-input (Maple input).

( Your expressions are not strings in the Maple sense (unless of course expression1:="Hello world"; ). )

@Alejandro Jakubi Just tried the same. I think you are right.

@Alejandro Jakubi Just tried the same. I think you are right.

There seems to be a syntax error. Copying it I got "Error, `;` unexpected".

Could you upload a worksheet instead?

@Thomas Richard Actually even

simplify(s) assuming a>0;

works.

First 184 185 186 187 188 189 190 Last Page 186 of 231