nm

12383 Reputation

20 Badges

14 years, 103 days

MaplePrimes Activity


These are answers submitted by nm

Chop in Mathematica chops numerical value. The Chop in StringTools removes last character from string. These are not the same thing.

To use same Chop that Mathematica uses in Maple, use MmaTranslator:-Mma:-Chop  like this

It uses same tolerance as in Mathematica which is 10^(-10)

For $MaxNumber,$MinNumber you can use

Maple_floats(MAX_FLOAT); and Maple_floats(MIN_FLOAT);

For the other questions you could check these to see if they help

https://www.mapleprimes.com/questions/202952-How-To-Programmatically-Obtain-List

and

https://mapleprimes.com/questions/240152-List-All-Commands

There is probably better way than this in maple

X :=[2, 5, 7, 8, 9, 10];
Y :=[3, 9, 13, 15, 17, 19];
n:='n';
the_formula := CurveFitting:-PolynomialInterpolation(X, Y, n):
L:=MakeFunction(the_formula,n);

gives           
                  L := n -> 2*n - 1

Now you can do

L(2);
L(5);
L(7);
L(8);
L(9);
L(10);

> 

vec:=Vector(3, {(1) = 0, (2) = x*z/(sqrt(ell__1^2-2*ell__1*x+s^2+x^2+z^2)*(s^2+z^2))-z*ell__1/(sqrt(ell__1^2-2*ell__1*x+s^2+x^2+z^2)*(s^2+z^2))-x*z/((s^2+z^2)*sqrt(ell__2^2+2*ell__2*x+s^2+x^2+z^2))-z*ell__2/((s^2+z^2)*sqrt(ell__2^2+2*ell__2*x+s^2+x^2+z^2)), (3) = -s*x/(sqrt(ell__1^2-2*ell__1*x+s^2+x^2+z^2)*(s^2+z^2))+s*ell__1/(sqrt(ell__1^2-2*ell__1*x+s^2+x^2+z^2)*(s^2+z^2))+s*x/((s^2+z^2)*sqrt(ell__2^2+2*ell__2*x+s^2+x^2+z^2))+s*ell__2/((s^2+z^2)*sqrt(ell__2^2+2*ell__2*x+s^2+x^2+z^2))})

Vector(3, {(1) = 0, (2) = x*z/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))-z*`ℓ__1`/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))-x*z/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2))-z*`ℓ__2`/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2)), (3) = -s*x/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))+s*`ℓ__1`/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))+s*x/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2))+s*`ℓ__2`/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2))})

> 

my_simplify:=proc(Y)
   map(X->ListTools[Categorize]((t1, t2) -> evalb(denom(t1) = denom(t2)),convert(X,list)), [Y]);
   add(map(X->simplify(add(op(X))),%))
end proc:
new_vec:=map(Y->my_simplify(Y),vec);

Vector(3, {(1) = 0, (2) = (-`ℓ__1`+x)*z/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))+(-x-`ℓ__2`)*z/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2)), (3) = s*(`ℓ__1`-x)/(sqrt(s^2+x^2-2*x*`ℓ__1`+z^2+`ℓ__1`^2)*(s^2+z^2))+s*(x+`ℓ__2`)/((s^2+z^2)*sqrt(s^2+x^2+2*x*`ℓ__2`+z^2+`ℓ__2`^2))})

> 

simplify(new_vec-vec)

Vector(3, {(1) = 0, (2) = 0, (3) = 0})

Download maple_sol.mw

screen shot

Humm. Did you not ask this same thing in https://www.mapleprimes.com/questions/243707-Recalcitrant-Differential-Equation

and got a reply for it?

D(f@g)   works because f and g these are not defined, so maple can't take their derivatives.

But ln and cosh are known functions to maple so it can take their derivative . So it is evaluation issue.

To do what you want you can try freezing them

> 

restart;

> 

D(f@g)

(`@`(D(f), g))*D(g)

> 

expr:=D(%ln@%cosh)

(`@`(D(%ln), %cosh))*D(%cosh)

> 

InertForm:-Value(%);

(`@`(proc (z) options operator, arrow; 1/z end proc, cosh))*sinh

> 

D(ln@cosh)

(`@`(proc (z) options operator, arrow; 1/z end proc, cosh))*sinh

> 

%(x)

sinh(x)/cosh(x)

 

 

Download test3.mw

Replace y(x) by y and add assuming x>positive. 

opps, thanks to all comments below, fixed more.

Changed to only assuming x>0 since IC at negative y

> 

restart;

> 

ode := diff(y(x), x) = (4*y(x)^2 + x*y(x) + 1)/(4*x^2 + x*y(x) + 1)

diff(y(x), x) = (4*y(x)^2+x*y(x)+1)/(4*x^2+x*y(x)+1)

> 

ics := y(4/5) = -1/5

y(4/5) = -1/5

> 

sol:=dsolve([ode,ics], y(x), 'implicit')

-(7/4)*ln(28*x*(x-y(x))/(4*x^2+x*y(x)+1))+(7/20)*ln((28/3)*(5*x^2+1)/(4*x^2+x*y(x)+1))+(7/5)*ln(-(7/2)*(5*x*y(x)+1)/(4*x^2+x*y(x)+1))-(7/20)*ln(5*x^2+1)+(7/4)*ln(x)+(21/5)*ln(2)-((7/5)*I)*Pi+(7/20)*ln(3)+(7/5)*ln(5) = 0

> 

sol:=simplify(eval(sol,y(x)=y)) assuming x>0;

-(7/4)*ln((x-y)/(4*x^2+x*y+1))+(7/20)*ln(1/(4*x^2+x*y+1))+(7/5)*ln((-5*x*y-1)/(4*x^2+x*y+1))-((7/5)*I)*Pi+(7/5)*ln(5) = 0

> 

plots:-implicitplot(sol,x=0..3,y=-1..3,gridlines = true)

 

 

Download test3.mw

L:=[1/2, 1/3, 1/4];
`%+`(op(L))=`+`(op(L))

Maple can't find general solution for this ode, but it can find particular soltutions

ode:=(1+y(x))*diff(y(x),x$2)=1+x;
yp:=DEtools:-particularsol(ode,y(x));

map(X->odetest(X,ode),[yp])

[0,0]

 

plot(rhs~([yp]),x=-3..3)

 

 

How can the length of the result series be controlled? 

You can use the order=N option

sol:=dsolve([ode,IC],y(x),'series','order'=5);
sol:=dsolve([ode,IC],y(x),'series','order'=10);

 

 

A:=sqrt(2)/( sqrt(1-b^2)*sqrt(2+(-x-1)*b^2) );
subsindets(A,'`^`(anything, -1/2)', f -> 1/sqrt(simplify(op(1,f))));

The above simplifies sqrt(*) in denominators.   If you want to simplify sqrt(*) in numerator, change it to 

subsindets(A,'`^`(anything, 1/2)', f -> sqrt(simplify(op(1,f))));

And if you to do both on expression, simply do the above twice, one for the numerator and next for the denominator.

restart;

max_X:=8: max_Y:=5:

grid_points:= [seq(seq([n,m],n=0..max_X),m=0..max_Y)]:
H_lines := [ seq([ [0,y],[max_X, y] ], y = 0..max_Y) ]:
V_lines := [ seq([ [x, 0],[x, max_Y]], x = 0..max_X)]:
the_points := plots:-pointplot(grid_points, symbol=solidcircle, symbolsize=12, color=red):
p_lines  := plot([op(H_lines), op(V_lines)], color=blue, thickness=2):

plots:-display(the_points, p_lines, title="my grid", view=[0..max_X, 0..max_Y]);

You missed up your `t` in the loop.

Simplify add t:='t'; after the loop to clear it.

cpu_time:=time()-begin;
plots:-pointplot3d([seq(pt[j],j=0..n)],axes=normal,symbol=cross,symbolsize=8,color=red,labels=["t","x","y"],orientation=[-90,0]);
t:='t'; # MAKE SURE TO DO THIS
sys:=diff(X(t),t)=Y(t),diff(Y(t),t)=F(X(t),Y(t));
vars:={X(t),Y(t)}: 
ic:=X(0)=0.2,Y(0)=0.1:


Download A.mw

one way is

eq:=x^4-12*x-12=0;
solve(eq,x,'explicit');

Another way

sol:=solve(eq,x):
allvalues([sol]);

And if you want numerical values (easier to read) just use evalf as in

sol:=solve(eq,x):
allvalues([sol]);
evalf(%);

Notice the complex roots are conjugate of each others as would be expected.

change   DU(.99999) = -.3401375821   to   D(U)(.99999) = -.3401375821

good  catch. You've found internal Maple bug. The bug is in simplify not convert.

A:=convert(WhittakerW(7/3,1,hypergeom([1],[2],z)),trig);

And now

try: 
    simplify(A);
catch: 
end try;

Error, (in expand/sin) too many levels of recursion

These internal Maple bugs can not be cought using try/catch by design. 

I'll report it for Maplesoft now so they could try to fix it before 2026 is supposed to be released next month.

1 2 3 4 5 6 7 Last Page 1 of 21