nm

11353 Reputation

20 Badges

13 years, 12 days

MaplePrimes Activity


These are questions asked by nm

One can write 

restart;
alias(C=binomial);
C(4,2);

or

restart;
C:=binomial;
C(4,2);

and then both work the same. In the first case, the replacement of "C" by "binomial" is done at parsing time before evluator gets hold of the code, while in the second case, the replacement is done at run-time (evaluation).

So alias will be more efficient and more safe, I assume.

Is that all there is to it, or are there other more subtle and important reasons to use alias vs. :=  when one want to bind long name to smaller ones to save on typing.

 

I am newbie in Maple, and trying to understand when to use operator `if` as I see in some code vs. normal if. This is in context if using map()

I noticed I can write

A:=[seq(i,i=1..10)];
f:=x->x^2;
map(x->`if`(x<5,f(x),NULL),A);

or

map(x->if x<5 then f(x) fi,A);

And they both work the same. When should one use `if` vs. if? with the case of `if` I had to give a third argument NULL for the else part, while with using direct "if", I did not have to give the "else" part.

Also, suppose I want to use  IF .. THEN .. ELIF ... FI, then how would this be done using the operator syntax? in normal "if", I can write

A:=[seq(i,i=1..10)];
f:=x->x^2;
map(x->if x<5 then f(x) elif x=5 then x else x-1 fi,A);

Actually if I understand better when `if` is meant to be used vs. where the normal "if", I might understand more its use. 

 

ps. I did look at the help here but did not see it recommend when to use over the other (unless I overlooked it)

 

 

 

 

Is this a  false positive, where Maple is solving an ODE which is supposed to be unsolvable?

Accoding to http://www.maplesoft.com/compare/mathematica_analysis/Comparison_Maple_Mathmatica_DEs_Kamke.pdf and considering ODE 13

Maple 18.01 does give an answer for the above ODE. I verfied the ODE from the book as well. The answer returned by Maple is very large, but it does solve it in 195 CPU seconds. Therefore the question is: Is this a false result? Or is the above document have an error in it and ODE 13 is actually solvable?

restart;
ode:=diff(y(x), x$2)-(a*y(x)^2+b*x*y(x)+c*x^2+alpha*y(x)+beta*x+gamma)^(-3/2);
sol:=dsolve(ode,y(x)) assuming a::NonZero; #I get an answer with or without this assumption. The book has the assumption
odetest(sol,ode);

btw,

 odetest(sol,ode)

gives an error as well. May be this is related to the issue or not. Not sure now.

For some reason, Maple does not use \frac{}{} for things like 1/2 that can occur in an expression

restart;
expr:=1/2;
latex(expr);

            1/2

This make the generated code not good looking. For example using this in Maple:

latex(diff(y(x), x)+y(x)*cos(x)-(1/2)*sin(2*x) = 0);

produces this latex when proccessed:

When the latex is put inside a display in the document.  This is terrible. Is there a way to tell Latex to use \frac{}{} for fractions?

 

I have few ode's which are solved by dsolve, but I am not able to get a zero from odetest(sol,ode). I tried the implicit option on the one which returns implicit solution, but I still do not get zero. I tried useInt as well.

Is there something else to do to verify the solution? My understanding is that if Maple returns a solution from dsolve, there there should be a way to get odetest() to verify the solution, but I could be wrong. Here are few examples, I have more if needed. This is Maple 18.01 on windows 7

restart;
MathematicalFunctions:-Version();
#       "C:\Program Files\Maple 18\lib\DEsAndMathematicalFunctions18.mla", `2014, July 25, 21:22 hours`
unassign(`print/ODESolStruc`):
ode1:=diff(y(x), x)+2*tan(y(x))*tan(x)-1:
ode2:=2*(diff(y(x), x))-3*y(x)^2-4*a*y(x)-b-c*exp(-2*a*x):
ode3:=(x^2+1)*(diff(y(x), x))+(y(x)^2+1)*(2*x*y(x)-1):
ode4:=x^7*(diff(y(x), x))+(2*(x^2+1))*y(x)^3+5*x^3*y(x)^2:
ode5:=(y(x)-x)*sqrt(x^2+1)*(diff(y(x), x))-a*sqrt((y(x)^2+1)^3):

sol1:=dsolve(ode1,y(x)):
sol2:=dsolve(ode2,y(x)):
sol3:=dsolve(ode3,y(x)):
sol4:=dsolve(ode4,y(x)):
sol5:=dsolve(ode5,y(x)):

odetest(sol1,ode1,implicit);  #not zero
odetest(sol2,ode2);             #not zero
odetest(sol3,ode3,implicit);  #not zero
odetest(sol4,ode4,implicit);  #not zero
odetest(sol5,ode5,implicit);  #not zero

First 188 189 190 191 192 193 194 Last Page 190 of 199