Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@Elisha Besides the spelling error pointed out by acer you need initial conditions for all your functions. Also you need to give all parameters values, i.e. these
 

indets({ode1, ode2, ode3, ode4, ode5},name) minus {t};

must be given values (as in your first worksheet).
## NOTE:
Your system can easily be solved exactly by dsolve, so as in the simple example given above you can compare the RK4 solution to the exact (as well as the RKF45 to the exact).

@vv I'm well aware of that, but the OP writes:
" I have used RKF45 to solve my ODE with Maple. now I am required to solve same ODE using RK4 for comparison of solution. "
Certainly a comparison can be made as I did, but surely one must be aware of the default settings of abserr and relerr in the case of the default method (rkf45).
## It may be illuminating to see the x-values for which the two methods compute f(x,y) in y'(x)=f(x,y(x)):
 

restart;
solproc:=proc(n,x,Y,YP)
  printf("x = %f\n",x);
  YP[1]:=Y[1];
  NULL
end proc;
h:=.1:
resRKF45:=dsolve(numeric,number=1,procedure=solproc, start=0, initial=Array([1]),procvars=[y(x)],output=Array([seq(h*i,i=0..20)]));
resRK4:=dsolve(numeric,number=1,procedure=solproc, start=0, initial=Array([1]),procvars=[y(x)],
   method=classical[rk4],stepsize=h,output=Array([seq(h*i,i=0..20)]));

Again I'm using default values for abserr, relerr, and method in resRKF45.

@mrbayat The problem most likely comes from imaginary values from ln.
You can try replacing ln by ln@abs, i.e. ln(x) by ln(abs(x)) as in:
 

dsys2:=eval(dsys,ln=(ln@abs));

Now, however, you will be pursuing a wild goose:
With Digits=10 you will be told to raise Digits to approximately 32. Then try Digits:=50 and you will be told to set Digits at approximately 67. Ok, then try again with Digits:=70 then the response is go to 87. Does it ever end?
 

Could you try uploading the file once again. I cannot get my Maple to understand it.
Thus save your worksheet in the normal way using Save or Save As and upload that file.
Upload the worksheet in the MaplePrimes editor using the fat green arrow.

As it is now it appears to be an html-file. It should be a Maple worksheet, thus it should be an .mw-file, which is an xml-file. In a text editor it is seen as starting with <?xml version="1.0" encoding="UTF-8"?>.

Did you submit an SCR?

@_Maxim_ The use of 0 < r < R works in 2D-input only.
In 1D you must write 0 < r, r < R.

Just a comment on the statement by Robert Lopez:
" At one time this quirk could break commands such as dsolve. I don't know if it still does .... ".

Although here is no assignment I tried the following code in Maple 8, Maple 12, Maple 15, and Maple 2017.
It works fine in Maple 15 and Maple 2017.
In Maple 8 neither the symbolic dsolve command nor the numeric worked. In Maple 12 the numeric dsolve worked, but the symbolic didn't.
 

ode:=diff(n(n[1]),n[1])=n(n[1]);
dsolve({ode,n(0)=1});
res:=dsolve({ode,n(0)=1},numeric);
res(1);

The less weird code that follows only failed for the symbolic dsolve command in Maple 8:
 

restart;
sys:=diff(n(t),t)=n[1](t)+n(t),diff(n[1](t),t)=n[1](t)-n(t);
dsolve({sys,n(0)=1,n[1](0)=0});
res:=dsolve({sys,n(0)=1,n[1](0)=0},numeric);
res(1);

The following code containing an assignment to n[2] breaks all of the versions mentioned, numeric as well as symbolic:
 

restart;
n[2]:=47;
ode:=diff(n(t),t)=n(t);
dsolve({ode,n(0)=1});
dsolve({ode,n(0)=1},numeric);

Although a name of a table (here n) only evaluates to the name (n), the command n(t) evalutes to
(table([2 = 47]))(t).

@_Maxim_ This works too:
 

radnormal((sqrt(1-I)*sqrt(1+I)-sqrt(2))*(t+1));

@J F Ogilvie You wrote:
"When I entered this logically correct assignment in Maple 2017.3 (classic interface)

    n := n[1] + n[2] + abs(m) + 1;

.... "
Now what does 'logically correct' mean here? If you are
"in the know"  as Robert Lopez calls it then it doesn't make much sense.
He also mentions that this has been with us since
Maple V Release 4 (I haven't checked).
Changing it would be another colossal waste of time that could be used elsewhere.
Just stick to using xxx__yyy as vv says.
 

@tsunamiBTP No, the problem lies with constants (like Pi, sqrt(2) or sin(2)) that are not of type numeric. The fraction 1/3 is of type numeric; Pi, sqrt(2), and sin(2) are not.
Actually I mentioned 22/7 as an example for which the substitution Pi=22/7 makes is return true for the original equation. I might as well have used Pi=1/3.
##
Secondly, this "remedy" of replacing Pi with an unassigned name works here, yes, but clearly we could construct examples of equations whose validity depends on Pi being Pi and not just a name.
##
So my point was just to point at the possible cause of the bug.
Basically, I don't think that you should trust is.

 

@tsunamiBTP Your new example doesn't differ in its essence from the simpler one you started with.
The following changes (in order) will give you true:

is(subs(Pi=pi,Y));
##
is(eval(y1 = y2, {Pi = pi, n = 10}));
##
is(eval(y1 = y2, {Pi = pi, n = 10})) assuming real;
##
is(combine(subs(Pi = pi, eq)));
############
You have value in a couple of places. No need for that. You are using sum (not Sum) and sum finds a symbolic sum.
As I was pointing out in my answer, theproblem seems to be the handling of constants that are not rationals like Pi and sqrt(2). I use pi as a name, it might as well have been another unassigned name.

A quite similar question was asked on MaplePrimes here:
https://mapleprimes.com/questions/223417-Physics--Math-With-Maple-DE-Numerically#answer244152

Notice that the OP (Joey Joe) had a dimensionally incorrect version of the Einstein version at first.

@vv I agree with your first 3 lines.
About the last point: I went to the help page
?Atomic variables
and found this gibberish:

Use a literal subscript to form a name that will not be interpreted as an index of any kind. For example, if you want to use both  x  and x[0]  in a worksheet as distinct names, use a literal subscript for
#mrow(msub(mi("a",mathcolor="#AF00AF"),mi("b",mathcolor="#AF00AF"))


Quite simple, right? It made me think that somebody goofed up the help page, but I'm afraid not.

 

@Muhammad Usman Your solve command in the worksheet HELP.mw actually returns a result.
You have commented out the other attempt to find Sols, thus the graph of P is using that solve command.
But since you have a system with floating point coefficients and the determinant is found to be something like
-3.4266188236700911852*10^(-318)
then it doesn't make sense to convert to rationals.
Consider this simple example:
 

restart;
A:=Matrix([[Pi,1],[sqrt(Pi)*Pi,sqrt(Pi)]]);
LinearAlgebra:-Determinant(A); #0
A2:=evalf(A);
LinearAlgebra:-Determinant(A2); # 0.
A3:=convert(A2,fraction);
LinearAlgebra:-Determinant(A3); # NOT zero

The point is that converting a floating point matrix to rationals often results in a nonsingular matrix although the original really was singular.
##
Instead you can for your system use LeastSquares from the LinearAlgebra package to find the vector x that minimizes A.x-b in the euclidean norm.

LS:=LeastSquares(A,b);
Norm(A.LS-b,2); #Roughly 0.3

and then do
 

res:=eval(theta,var =~convert(LS,list));
P2 := eval(res, t = 0.1e-2);
plot(P2, x = 0 .. R);

 

@tomleslie Yes, I have the same problem (in Maple 2017.3, Windows 10, 64 bit) that you refer to.
I get

Warning, problem appears to be unbounded
           [0, [xifp = 0, xifq = 0, xp = 0, xq = 0]]

but setting UseHardwareFloats:=false gives me the answer you get.

 

First 52 53 54 55 56 57 58 Last Page 54 of 231