awass

271 Reputation

10 Badges

17 years, 181 days

MaplePrimes Activity


These are questions asked by awass

From the help pages for the Gram Schmidt command:

The number of Vectors returned is the dimension of the vector space spanned by V.  In particular, if the Vectors in V are not linearly independent, fewer Vectors than the number in V are returned.


That is not what happens when floating point numbers are involved, for example:

>restart;
>with(LinearAlgebra);
>a := Vector([1, 2, 3]); b := Vector([1, -2, 3]); c := Vector([3, 2, 1]); d := Vector([5, 1, -3]); e := Vector([0, 1.01, -3]);
>GramSchmidt([a, b, c, d, e]);

This returns 3 vectors as it should BUT
>GramSchmidt([b, c, d, e, a]) returns 5 vectors (one of which is essentially 0).  That is definitely a bug.
 

Here is a simple little procedure that does not work

et :=proc(x) 

description   "this is a variant of evalf that gets rid of almost 0 nos.(rounding error) and shortens the display to 2 `digits"`;  

if  abs(x) < 10^((-14))  then 0 else  evalf(x,2) end if     end proc;


Error, unable to delimit strings/identifiers


and here is the same procedure that works because I added the # before the description.

et :=proc(x)

# description   "this is a variant of evalf that gets rid of almost 0 nos.(rounding error) and shortens the display to 2 `digits"`;  

if  abs(x) < 10^((-14))  then 0 else  evalf(x,2) end if     end proc;

 

In the help pages they do not say that the description must be hidden by the # sign (nor do they mention that quotes should be used although they are used in the examples.

 

What am I missing?

 

 

 

I was pleased to observe that in Maple 2018 one can use dsolve to get solutions of matrix ODEs, e.g., X'(t)=A(t) X(t). The command is the obvious dsolve({diff(X(t),t)=A(t).X(t), X(0)=Xo}).

I was then surprised that Maple balked at the commands dsolve({diff(X(t),t)=A(t).X(t), X(0)=Xo},numeric) and dsolve({diff(X(t),t)=A(t).X(t), X(0)=Xo},numeric,{x(t),y(t)}).  Is there some error on my part?

Can anyone explain this?
> if  3 = 0 mod 3 then print(good) else print(bad) end if;
                        bad

> if  0 = 3 mod 3 then print(good) else print(bad) end if;
                       good
 

I have a procedure, se, that takes 2 real numbers as arguments and returns a list of 3 real numbers,
so, for example,
se(1.2,2.7)=[-5.85,3.24,3.9].
(The exact nature of that procedure should not be important for plotting purposes.) 

The command   >plot3d(se(x,y),x=0..2,y=-2..3);  returns a surface plot as hoped.   
(I had some doubt because the help page suggests one needs 3 functions or procedures [f,g,h] to get a 3 d plot rather than one procedure that generates a list of 3 values but Maple 2017.3 came through). 
I have another procedure , td,that takes 2 real numbers as arguments and returns a list of 3 real numbers,  ;
so, for example,
td(2.7, 3.4)=[3.4, .594943507924521, -.111391393034295].

(Again, the exact nature of that procedure should not be important for plotting purposes.) 
The command   > plot3d(td(x,t),x=0..2,t=0..3);  returns the error message: 

Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got a = x

For some reason, plot3d is going back to the body of the procedure, td, rather than just accepting the values it provides.

Knowing that quotes can sometimes solve this sort of problem I then tried:
plot3d('td(x, t)', x = 0 .. 2, t = 0 .. 3);
only to get

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

I am not sure what plot3d is complaining about. The procedure I believe has all the information it needs in the form it needs it.
I then tried another workaround.

I set td1(x,t) :=td(x,t)[1], td2(x,t) :=td(x,t)[2], td3(x,t) :=td(x,t)[3] and tried :
plot3d([td1(x, t), td2(x, t), td3(x, t)], x = 0 .. 3, t = 0 .. 2);
to get
Error, (in dsolve/numeric/process_parameters) parameter values must evaluate to numeric, got a = x
Again, for some reason, plot3d is going back to the body of the procedure td.

Finally, I tried:
plot3d('[td1(x, t), td2(x, t), td3(x, t)]', x = 0 .. 3, t = 0 .. 2);
 
and I got the plot I wanted.

I am very happy to have a working file but I do not understand what worked and why. The nest time I have such a problem I will have to resort to the mysterious syntax manipulations again and hope that I hit on a combination that works.

For completeness I include the procedure bodies for  se and td below but I think that is irrelevant information.

se := proc (x, y) [x^2-y^2, x*y, x+y] end proc;


td := proc (x, tt)
local des, ff, fpfp; global ans;
ans(parameters = [a = x]);
des := ans(tt); ff := rhs(des[2]); fpfp := rhs(des[3]); [tt, ff, fpfp]
end proc;
 and
ans:=dsolve(ic,numeric,parameters=[a]):  where ic is an ode (I used several with the same result) with initial condition involving a.;

Can anybody explain what is happening?

 

1 2 3 4 5 6 7 Page 3 of 9