Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@mary120 Here is how you can do that:
 

restart;

Digits:=15:
V:=n^2*((T[e]+T[i])/T[e])*((((n-1)*(1+1/(2*delta[p]))))-ln(n)-ln(n/(2*delta[p])));
W:=eval(V,{T[e]=6/5,T[i]=1/100,n=n(x)}); # Omit delta[p]
ode:=diff(n(x),x)^2+2*W=0;
############################

############################
eval(convert(ode,D),{n(x)=1});
ICS:=solve(eval(%,x=0),{D(n)(0)});
ic:=n(0)=1;
ODE:=diff(ode,x);
## Using the parameters option to dsolve/numeric:
RESpar:=dsolve({ODE,op(ICS[1]),ic},numeric,parameters=[delta[p]]);

RESpar(parameters=[delta[p]=1/5]); # # Setting the parameter
plots:-odeplot(RESpar,[x,n(x)],-10..10); p1:=%: 
RESpar(parameters=[1/4]);# You can omit the name of the parameter when setting it.  
plots:-odeplot(RESpar,[x,n(x)],-10..10,color=blue); p2:=%:
plots:-display(p1,p2);
## A procedure that helps doing the above:
Q:=proc(dp,{range::range:=-10..10}) if not dp::realcons then return 'procname(_passed)' end if;
   RESpar(parameters=[dp]); # Setting the parameter
   plots:-odeplot(RESpar,[x,n(x)],range,_rest)
end proc;
# Simple input:
Q(1/5);
Q(1/4,color=black,range=-5..5,linestyle=3);
## An animation in delta[p]:
plots:-animate(Q,[delta[p],range=-5..5],delta[p]=0.1..0.49);
plots:-animate(Q,[delta[p],range=-5..5,color="DarkGreen"],delta[p]=0.1..0.49,trace=24);

Here is the first plot displaying p1 and p2:

And here is the animation with trace:

@Joe Riel I suppose that what TechnicalSupport wanted to define was:
 

find_vars_in_proc:=proc(f :: procedure, $)
  return {op(2, eval(f))};
end proc;

 

@Anthrazit That line from the help page 'Initially Known Names' is the exact same as in Maple 12 and probably goes back even longer. OK a comma in Maple 12 has been changed to a period later.
The statement is:
" Pi     math constant pi (pi); use Pi for calculations.   
           evalf(Pi) is approximately 3.14159265... "

I think the point is that the lower case pi is used first, and then it has to be pointed out that Pi is the actual name of the mathematical constant in Maple.

@tomleslie I don't think that conversion to radians in Maple 2022 takes place in general (and it didn't in Maple 2021 either).
Maple 2022 appears to have a problem when using Units:-Simple:-`<` where one of the arguments is zero.
The code for Units:-Simple:-`<` was different in Maple 2021 and worked fine.

 

with(Units[Simple]);
alpha:=45*Unit(degree);
beta:=30*Unit(degree);
evalb(alpha>beta); # true
evalb(Pi/4>Pi/6);  #Not decided as expected
evalb(alpha>0); #  0<Pi/4 in Maple 2022, but true in Maple 2021

I would consider this a bug in Units:-Simple:-`<` in Maple 2022.

@Anthrazit Apparently min and max work, but not `<`.

restart;
with(Units[Simple]);
alpha:=45*Unit(degree);
if alpha=0 then "alpha=0" elif max(0,alpha) = alpha then "alpha>0" end if;

So you could define LessThan like this:

LessThan:=proc(x,y)
       if x-y=0 then return false end if;
       if min(x-y,0)=x-y then true else false end if
end proc;

@harry4939 Save your worksheet. Then use the icon with fat green arrow pointing up in the MaplePrimes editor  to upload the worksheet.
I uploaded my worksheet Test.mw, which was made in Maple 2022.0. No problems.
Test.mw

 

An approach that doesn't begin by solving for the derivative, but differentiates the ode and thereby turns it into a second order ode:
 

restart;

Digits:=15:
V:=n^2*((T[e]+T[i])/T[e])*((((n-1)*(1+1/(2*delta[p]))))-ln(n)-ln(n/(2*delta[p])));
W:=eval(V,{T[e]=6/5,T[i]=1/100,delta[p]=1/5,n=n(x)});
ode:=diff(n(x),x)^2+2*W=0;
############################
eval(convert(ode,D),{n(x)=1});
ICS:=solve(eval(%,x=0),{D(n)(0)});
ic:=n(0)=1;
ODE:=diff(ode,x);
RES1:=dsolve({ODE,op(ICS[1]),ic},numeric);
plots:-odeplot(RES1,[x,n(x)],-10..10);
RES2:=dsolve({ODE,op(ICS[2]),n(0)=1},numeric);
plots:-odeplot(RES2,[x,n(x)],-10..10);
#############################

The first plot:

You forgot to attach the worksheet showing the result from Maple 11.

@acer Thank you! Measuring time[real] I got 16 minutes on my computer.

@acer For how long does RootFinding:-Isolate have to run to produce the results in your worksheet?
I'm using
`Maple 2022.0, X86 64 WINDOWS, Mar 8 2022, Build ID 1599809`

on a reasonably fast and rather new computer.

@acer I executed your worksheet in Maple 12 and I got this dreaded result from NLPSolve:

sol := NLPSolve(bandpeak(Zstub), Zstub=Z[1]..Z[N],
                      method=sqp, initialpoint = [Zstub=Z[2]]);
Warning, no iterations performed as initial point satisfies first-order conditions
               [0.375277160248564, [Zstub = 5.02596984406875]]

whereas in Maple 2022 I get

sol := NLPSolve(bandpeak(Zstub), Zstub=Z[1]..Z[N],
                      method=sqp, initialpoint = [Zstub=Z[2]]);
Warning, limiting number of evaluations reached
...................................many of these Warnings
Warning, limiting number of evaluations reached
   [0.111740781972696004, [Zstub = HFloat(43.9058440724061)]]

I tried your worksheet and didn't get any errors.
`Maple 2022.0, X86 64 WINDOWS, Mar 8 2022, Build ID 1599809`

@Carl Love I'm always being put off (to use a polite expression) by the use of plural pronouns for a situation, where it is quite obvious a singular version should have been used.
Instead of your statement:
" The member @nm has a long-standing habit of deleting their own Questions"
I would simply have said: The member @nm has a long-standing habit of deleting his own Questions.
By this I'm not implying that nm is a male (I don't know), but just using the time honored usage in such cases.

@Mac Dude Could you give us an example?

I have an old one of my own:
 

restart;
Digits:=15:
sys := {6*exp(x+y)/(1+exp(x+y))+exp(2*y)/(1+exp(2*y)) = 2,
            5*exp(2*x)/(1+exp(2*x))+2*exp(x+y)/(1+exp(x+y)) = 1}:
plots:-implicitplot(sys,x=-10..10,y=-10..10);
S:=solve(sys);
evalf(S[1]);
fsolve(sys,S[1]); # returns unevaluated
fsolve(sys,{x=-1.2..-1, y=-.1..0.1}); #OK

But that one is not new, even Maple 12 has that behavior.

@opus64 In the help page for isolate you also find this statement:

"For direct solutions of equations, solve may be more efficient than isolate, which is intended, primarily, for use in an interactive Maple session." (my emphasis).
The code for isolate can easily be seen:
 

restart;
showstat(isolate,1..6); # we need only look at the lines 1 through 6.
eq:=P=A+(z+x1/2/z); # Using x1 instead of x
## In the code expr and x will be:
expr:=eq; x:=z+x1/2/z;
has(expr,x); # Line 3, answer false
type(x,`^`);   # Line 4, answer false

'has' is builtin, so you cannot see its code:
op(3,eval(has)); # option builtin
but the help page for has states:

"The has(f, x) function returns true if f contains the expression x;  otherwise false is returned.
The expression f contains x if and only if a subexpression of f (as defined by Maple's op function) is equal to x." (my emphasis)

 

First 15 16 17 18 19 20 21 Last Page 17 of 229