Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@Johan159 When you use plot or plot3d on a function f your range(s) must be given as just ranges, not equations.
If your first argument is f(x,y) then you must use equations.
See the help for plot and plot3d.
 

f:= (x,y)-> 2*x^2 + 5*y^3 + 5;
plot3d(f,0..10,0..5);
plot3d(f(x,y),x=0..10,y=0..5);


Another thing to keep in mind: A function (like your f) evaluates just to a name.
If you write f; and press enter, you just get f (literally).
If you want to see its definition as a procedure do eval(f); (enter).

@Kitonum The numbers 5 and 6 should be either 5 and 5 or 6 and 6.
Take the general case:
 

convert(series(f(x),x=0, 6), polynom)+(D@@6)(f)(xi)*x^6/6!;

 

@tomleslie What you are comparing is not only a potential cputime/realtime/memory difference due to the different output types of dsolve, but you are comparing the effect of using plot and odeplot:
These tests show not much of a difference:
 

restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:
dsol1 := dsolve(sys, numeric):

CodeTools:-Usage(plots:-odeplot(dsol1, [[t, x(t)],[t, y(t)],[t, lambda(t)]], t=0..10)):

# memory used=1.20MiB, alloc change=0 bytes, cpu time=31.00ms, real time=33.00ms, gc time=0ns
#######################################################
restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:


dsol2 := dsolve(sys, numeric, output=listprocedure):
xf:=eval(x(t), dsol2):
yf:=eval(y(t), dsol2):
lf:=eval(lambda(t), dsol2 ):

CodeTools:-Usage( plots:-odeplot(dsol2, [[t, x(t)],[t, y(t)],[t, lambda(t)]], t=0..10)):
# memory used=1.20MiB, alloc change=0 bytes, cpu time=32.00ms, real time=40.00ms, gc time=0ns

The following test shows a substantial difference:
 

restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:
dsol1 := dsolve(sys, numeric):

CodeTools:-Usage([for i from 1 to 10^5 do dsol1(10^(-4)*i) end do]):
# memory used=0.77GiB, alloc change=288.01MiB, cpu time=8.75s, real time=7.32s, gc time=3.17s
#######################################################
restart;
sys:= { diff(x(t),t,t) = -2*lambda(t)*x(t),
         diff(y(t),t,t) = -2*lambda(t)*y(t)-Pi^2,
         x(t)^2+y(t)^2 = 1,
         x(0)=0, D(x)(0)=1/10, y(0)=-1, D(y)(0)=0
       }:


dsol2 := dsolve(sys, numeric, output=listprocedure):
xf:=eval(x(t), dsol2):
yf:=eval(y(t), dsol2):
lf:=eval(lambda(t), dsol2 ):

CodeTools:-Usage([for i from 1 to 10^5 do dsol2(10^(-4)*i) end do]):
# memory used=4.22GiB, alloc change=0.68GiB, cpu time=44.09s, real time=37.64s, gc time=11.70s

 

@Kitonum What you get with your code is not always positive:
 

T1 := remove(t -> is(op(1, t) = -1), [T]);
eval(T1,{R=1/6,ZETA=1});
evalf(%);

An illustration:
 

plots:-animate(plots:-complexplot,[T1,R=0..1,thickness=3,color=[red,blue],style=point,symbolsize=20],ZETA=-1..1);

@peace951 Here is the syntax. Notice that intentionally f, a, and b have not been given concrete values. That way you see the method used and the meaning of 'partition'.

restart;
Student:-Calculus1:-ApproximateInt(f(x),x=a..b,method=trapezoid,partition=1);
Student:-Calculus1:-ApproximateInt(f(x),x=a..b,method=midpoint,partition=1);
Student:-Calculus1:-ApproximateInt(f(x),x=a..b,method=simpson,partition=1);
Student:-Calculus1:-ApproximateInt(f(x),x=a..b,method=simpson,partition=2);


 

@AHSAN You won't be able to find a polynomial expression for sigma in terms of lambda, Q and k.
What you have in the RootOf expression, which I called S) is a polynomial of degree 12 in _Z (i.e. sigma).
That polynomial is extracted from S in this code:
 

p:=subs(_Z=sigma,op(1,S));
type(p,polynom(integer,[sigma,lambda,Q,k])); # true
degree(p,sigma); #12
degree~(p,[sigma,lambda,Q,k]); # [12,4,8,8]

So solving for sigma means solving a polynomial of degree 12.
You are better off doing as dharr suggests.

@AHSAN Yes in Maple 2019.2 and in Maple 2020.2 as well, you get the solution in termds of inert integrals when n = 2 or 3.
For n = 4 you get the same as in the general case with n replaced by 4.

Most likely there is nothing wrong with the solution found.
The problem in all its generality probably cannot be solved.
You could experiment with letting n = 2 like this:
 

dsolve(eval(ode, n = 2));

or even simpler:
 

dsolve(eval(ode, n = 1));

Then try n = 3 and n=4.

@ecterrab Have a nice vacation. Merry Christmas!

@ecterrab Edgardo, I certainly agree that:
" generally speaking, RootOf's don't mean 'wrong' or the like".
as you wrote.
But my statement about not being surprised was initially just the appearance of nested RooOfs. When I was still teaching that would have made my students scream in horror.

But as Carl says, if you try evaluating the solution at x = 0 you get an error because of ln(x).

 

 

@mmcdara I agree.

Next to returning a correct answer is returning unevaluated and after that any error.
#############
In view of this result:
dsolve(edo);
y(x) = RootOf(_Z^2 - exp(RootOf(x^2*(tanh(sqrt(_C1^2 + 4)*(2*_C2 + _Z + 2*ln(x))/(2*_C1))^2*_C1^2 + 4*tanh(sqrt(_C1^2 + 4)*(2*_C2 + _Z + 2*ln(x))/(2*_C1))^2 - _C1^2 - 4*exp(_Z) - 4))) - 1 + _Z*_C1)*x

it isn't surprising that the initial value problem fails.

@vv One solution to the double quote problem could be to use Find/Replace from the Edit menu replace " with ` (accent grave) on the faulty procedure (or on a copy of it).
Then apply Carl's procedure to that.
Actually this replacement wouldn't spoil printf or error statements, or descriptions.

The (very) old releases of Maple didn't have real strings but used accent grave (back quote).

@Carl Love Thank you Carl.

@a_simsim You are surely right about the serious lack of examples of all the many options for events.

Your initial use of the trigger t = [2000,500] in events made me make an example of a trigger of that type adapted to your situation by simply modifying EVTS.
The first version EVTS2 doesn't work right because that type of trigger fires for t = 2000+n*500, for any integer n not only positive ones.
Therefore I used a conditional action in EVTS3, where there is no action if t is not large enough.
This extension EVTS3 may not be relevant to your application, but was just meant to give one further example of using events.
MaplePrimes20-12-08_FlowProblem_EVENTSII.mw

@vv Maple apparently doesn't recognize diff(sin(x)*u(x,t),x) as a derivative when the execution of the integral is done because it is evaluated as  cos(x)*u(x, t) + sin(x)*diff(u(x, t), x).
So we have to prevent that evaluation. This could be done by using Diff instead of diff:
 

A:=int(Diff(sin(x)*u(x,t),x),x=-infinity..infinity, continuous);

The result returned is 'undefined'. Not an unreasonable respons, but not correct either.
Integrating from -R to R is a better idea:

A:=int(Diff(sin(x)*u(x,t),x),x=-R..R, continuous);
limit(A,R=infinity);

Then we run into the problem that simplify/side relations doesn't work even for this simpler looking version:

limit(sin(R)*u(R),R=infinity);
simplify(%,{limit(u(R),R=infinity)=0}); 


 

First 21 22 23 24 25 26 27 Last Page 23 of 229