Rouben Rostamian

MaplePrimes Activity


These are questions asked by Rouben Rostamian

Vector calculus is very nicely handled in Maple's Physics package:

with(Physics[Vectors]):

The gradient of a scalar field in Cartesian coordinates

Gradient(f(x,y,z));

(diff(f(x, y, z), x))*_i+(diff(f(x, y, z), y))*_j+(diff(f(x, y, z), z))*_k

The gradient of a scalar field in cylindrical coordinates

Gradient(f(rho,phi,z));

(diff(f(rho, phi, z), rho))*_rho+(diff(f(rho, phi, z), phi))*_phi/rho+(diff(f(rho, phi, z), z))*_k

But the gradient of a vector field is not available:

Gradient(_rho*f(rho,phi,z) + _phi*g(rho,phi,z) + _k*h(rho,phi,z));

Error, (in Physics:-Vectors:-Nabla) Physics:-Vectors:-Gradient expected a scalar function, but received the vector function: _rho*f(rho, phi, z)+_phi*g(rho, phi, z)+_k*h(rho, phi, z)

I suppose this is because the gradient of a vector field needs to be
expressed in terms a basis consisting of the dyadic products  of the basis vectors

as in _i  _j, _rho_phi, etc., which does not seem to be implemented.

 

That said, it is quite possible that this is already done and I have missed it in
the documentation since the Physics package is so huge.  But if it's truly not there,
it would be a very useful feature to add.  Calculating gradients of vector fields

is central to continuum mechanics (including elasticity and fluid mechanics).

They are easy to represent in Cartesian coordinates but their calculation in the

frequently needed cylindrical and spherical coordinates are nontrivial and can use

Maple's help.

 

Here is a division-by-zero bug in a solution produced by pdsolve.  Admittedly, this sort of problem can be difficult to avoid in a CAS, but here it is, in case there is a chance to get it fixed somehow.

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

pde := diff(u(x,y,t),t,t) = diff(u(x,y,t),x,x) + diff(u(x,y,t),y,y);

diff(diff(u(x, y, t), t), t) = diff(diff(u(x, y, t), x), x)+diff(diff(u(x, y, t), y), y)

bc := u(x,0,t)=0, u(x,1,t)=0, u(0,y,t)=0, u(1,y,t)=0;

u(x, 0, t) = 0, u(x, 1, t) = 0, u(0, y, t) = 0, u(1, y, t) = 0

ic := u(x,y,0) = x*y*sin(Pi*x)*sin(Pi*y),  D[3](u)(x,y,0)=0;

u(x, y, 0) = x*y*sin(Pi*x)*sin(Pi*y), (D[3](u))(x, y, 0) = 0

pdsol := pdsolve({pde, bc, ic});

"pdsol:=u(x,y,t)=(&sum;) (&sum;)-(2 sin(n Pi x) sin(n1 Pi y) cos(Pi sqrt(n^2+n1^2) t) ({[[Pi^2,n=1],[-(8 n ((-1)^n+1))/((n-1)^2 (n+1)^2),1<n]]) n1 ((-1)^n1+1))/(Pi^4 (-1+n1)^2 (n1+1)^2)"

eval(pdsol, infinity=4);
value(%);

"u(x,y,t)=(&sum;) (&sum;)-(2 sin(n Pi x) sin(n1 Pi y) cos(Pi sqrt(n^2+n1^2) t) ({[[Pi^2,n=1],[-(8 n ((-1)^n+1))/((n-1)^2 (n+1)^2),1<n]]) n1 ((-1)^n1+1))/(Pi^4 (-1+n1)^2 (n1+1)^2)"

Error, (in SumTools:-DefiniteSum:-ClosedForm) summand is singular in the interval of summation

 

 

 

Download pdsolve-bug.mw

 

 

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

This one works as expected:

solve({x + y = 5, x - y = 3});

{x = 4, y = 1}

This one fails:

solve({x(0) + y(0) = 5, x(0) - y(0) = 3});

That shouldn't fail.  According to ?solve,details, under the Description

heading, it says that the unknown may be a name or a function.  Note that

type(x(0), function);

true

so there seems to be a contradiction.  Nevertheless, there is a workaround:

solve({x(0) + y(0) = 5, x(0) - y(0) = 3}, {x(0), y(0)});

{x(0) = 4, y(0) = 1}

 

Now try with fsolve().  This one works as expected:

fsolve({x + y = 5, x - y = 3});

{x = 4., y = 1.}

This one fails:

fsolve({x(0) + y(0) = 5, x(0) - y(0) = 3});

But the previous workaround does not help:

fsolve({x(0) + y(0) = 5, x(0) - y(0) = 3}, {x(0), y(0)});

I can temporarily rename the variables to plain symbols, or perhaps

freeze/thaw them.  But is there a simpler workaround?

 

 

Download fsolve-problem.mw

 

Maple's gamma constant appears to misbehave.

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

evalf(gamma);     # this one is expected

.5772156649

evalf(gamma(0));  # this one may be explained

.5772156649

evalf(gamma(1));  # how to explain this one?

-0.7281584548e-1

Things get more puzzling.  Let's declare gamma as local:

local gamma:

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

evalf(gamma);     # this is good

gamma

evalf(gamma(0));  # expected an unevaluated gamma(0) here!

.5772156649

evalf(gamma(1));  # expected an unevaluated gamma(1) here!

-0.7281584548e-1

 

Download gamma-puzzle.mw

 

Consider the family of functions "{`f__n`   : -infinity< n<infinity}," where the index n is
integer, and f__n; proc (R) options operator, arrow; R end proc.   It is known that diff(f__n(x), x) = `f__n-1`(x) for all n.

 

I want to convey that information to Maple.  For instance, given the input
diff(f[3](x),x), Maple should return f__2(x).  Similarly:
diff(f[3](x), x$2)                   should return   f__1(x)
f[4](x)*diff(f[3](x),x)^5   should return   f__4(x)*f__2(x)^5

What is a good way of doing that?

 

1 2 3 4 5 6 7 Last Page 1 of 11