## 6881 Reputation

16 years, 163 days

## MaplePrimes Activity

### These are answers submitted by Rouben Rostamian

I have used Maple in nothing but Linux for longer than I can remember and haven't had problems such as those that you have described.  Perhaps your Linux installation is broken?

That said, it is possible to run out of java heap memory if you are doing heavy-duty graphics.  In that case consider specifying a larger java heap on the command line, as in

```maple -x -j 65536 &
```

The default java heap is 512.

PS: My current Linux is Ubuntu 22.04.

I see several issues with your worksheet.

• You have three ordinary (not partial) differential equations in e1, e2, e3.  The command to solve ODEs is dsolve(), not pdsolve().
• It looks like the only unknown in your equations is z2(t).  Therefore each of e1, e2, e3 may be solved independently.  There is no guarantee that the z2(t) produced by one of these equations would agree with the z2(t) produced by the other.  Why are you solving the equations as a system?
• Each of your e1, e2, e3 involves a coefficient _C1.  Naming a symbol with a leading underscore is a bad idea.  Such symbols are reserved for use by Maple.  Your _C1 can potentially conflict with Maple's operation.

## Solution...

There may or may not be a solution, depending on some assumptions which you have not stated.

For instance, if you assume that x1_prime, x2_prime, and u are constants, then a solution exists and can be obtained through

```pde1 := x1_prime = diff(H(x1,x2),x1) + u*x1 + x2;
pde2 := x2_prime = x1 + diff(H(x1,x2),x2);
pdsolve({pde1,pde2});```

## If you are comfortable with C programmin...

If you are comfortable with C programming, you should be able to write your own implementation of KroneckerProduct() in C and compile it with the rest of your program.  When you call f() as exported by Maple, when it hits the call to KroneckerProduct(), it will execute your own version of that function.

The effective writing of such a KroneckerProduct() function will depend on your C programming skills, and some details that are missing in what you have written.  Here are some thoughts:

1. In your example, A, B, and their Kronecker product are single-column matrices.  If single-columns matrices are all you need, then the C program becomes significantly simpler because you may use one-dimensional arrays to represent them.
2. In your example, A and B have 3 rows each.  If 3-row matrices are all you need, then the C program becomes even simpler.
3. How familiar are you with the various C standards?  The C99 standard introduced variable length arrays, which can help with your program.  The previous standard, C89, recognizes only arrays whose sizes are known at the compile time.  Variable length arrays may be simulated in C89 through dynamic memory allocation with malloc() and related functions.  You need to decide which method you want to use.

## Needs better care...

• Look at your s[2].  On the left, you have E(t).  On the right you have E.  That should be E(t).  Also on the right you have lambda[2] and lambda[3].  Those should be lambda[2](t) and lambda[3](t).  Similar errors occurs in several other places.  Need to go over your input very carefully and fix those things.
• In s[5] you have lambda[1]*t.  That should be lambda[1](t).
• You have set tf := T, but you didn't say what T is.  Need to specify a numerical value for T.
• Don't apply Maple commands blindly.  You have defined fcns[1] := ... and ended that line with a colon.  Replace the colon with a semicolon to verify that Maple understands you correctly.  Similarly, you call dsolve with the arugment
`{seq(s[i], i = 1 .. 8), seq(lambda[i](tf) = 0, i = 1 .. 4), E(0) = E0, In(0) = In0, R(0) = R0, S(0) = S0}`

Before calling dsolve, enter that argument on a line of its own and examine what Maple prints very carefully to verify that what you are later passing to dsolve is in agreement with what you have in mind.

## Maybe this?...

I am not familiar with Mathematica, so I am just guessing from your example what the Cases command is expected to do.  It appears that it picks all instances of sin(...) in a given expression.  Here is how that is done in Maple:

expr := [sin(x)/(sin(2-x)+1)-12, sin(x/2)^2, cos(x)];
indets(expr, 'specfunc(sin)');

That yields {sin(x), sin(-2 + x), sin(x/2)}.

## Solution via finite differences...

This site is on the blink again and won't let me display my worksheet.   Here is the link to a worksheet that shows how to solve the system of PDEs through finite differences.

## Use this model as needed...

 > restart;
 > with(plots):
 > A1 := proc(t)         pointplot([t,t], symbol=solidcircle, symbolsize=50, color=red); end proc:
 > A2 := proc(t)         pointplot([t,t], symbol=solidcircle, symbolsize=50, color=blue); end proc:
 > display([         animate(A1, [t], t=-1..0),         animate(A2, [t], t=0..1) ], insequence);

## A bug in pdsolve()...

Your equations are uncoupled.  You may call pdsolve() to solve each of them separately.  That works on all versions of Maple that I have tried.

In principle, pdsolve() should be able to solve the two (uncoupled) equations together as a system, but that fails in Maple 2022 as we see in the attached worksheet.

Here is how things work on solving the system in various versions of Maple:

• Maple 2017 and 2018 return no solutions, and no errors;

• Maple 2019, 2020, 2021 return the correct solution;

• Maple 2022 fails on error.

 > restart;
 > kernelopts(version);

 > Physics:-Version();

Pdsolve gets the correct solution here:

 > pde1 := diff(u(x,t),t) = 0; ic1 := u(x,0) = f(x);

 > pdsolve({pde1,ic1});

Pdsolve gets also the correct solution here:

 > pde2 := diff(v(x,t),t) = 0; ic2 := v(x,0) = g(x);

 > pdsolve({pde2,ic2});

BUG: Pdsolve gets confused when solving the two (uncoupled) equations together:

 > pdsolve({pde1, pde2, ic1, ic2});

Error, (in pdsolve) invalid input: indets expects 1 or 2 arguments, but received 3

 >

The outcome of the discussion that followed this post was that Maple 2022's pdsolve() was not at fault after all.  The trouble was due to a not-up-to-date version of the Physics package on my machine, and it was resolved after upgrading to the latest version of the Physics package.

## Getting started...

I am not going to do the entire homework for you but here is something to get you started.

 > plot(8+8*sin(theta), theta=0..2*Pi, coords=polar, scaling=constrained);
 > plot3d(25 - x^2, x=0..5, y=1..8, view=[0..5,0..8,default]);
 > plots:-display(     plot3d([10*cos(t)*cos(s), 10*cos(t)*sin(s), 10*sin(t)], t=-arccos(6/10)..arccos(6/10), s=-Pi..Pi),     plot3d([6*cos(t), 6*sin(t), s], t=-Pi..Pi, s=-8..8), color=["Green","Red"], style=surface, scaling=constrained, lightmodel=light4);

## A suggestion for an alternative...

I have not examined the source of the error in your worksheet, but I would suggest using the facilities provided in the Physics[Vectors] package for encoding the Rodrigues formula rather than homogeneous transformation matrices, because the math works more naturally this way.  This worksheet shows how.

 > restart;
 > with(Physics[Vectors]):

Rodrigues'  formula:
Rotates the vector about the unit vecor  by the angle :

 > v__rot_ := v_*cos(alpha) + (k_ &x v_)*sin(alpha) + (k_ . v_)*(1 - cos(alpha))*k_;

Make that into a procedure: Usage:

 > R := unapply(v__rot_, v_, k_, alpha);

Example 1

Pick a unit vector:

 > 1*_i + 2*_j + 3*_k: k_ := % / sqrt(% . %);

Pick an arbitrary vector:

 > v_ := _i - 3*_j + 2*_k;

Pick a rotation angle:

 > alpha := Pi/6;

Find the rotated vector:

 > R(v_, k_, alpha): collect(%, [_i, _j, _k]);

 >

Example 2

Composite rotation

A unit vector:

 > k__1_ := k_;

Another unit vector

 > k__2_ := subs(_j=-_j, k__1_);

 > R(R(v_, k__1_, Pi/6), k__2_, Pi/4): collect(%, [_i, _j, _k], simplify);

 >
 >

## Solution...

 > restart;
 > kernelopts(version);

 > pd1 := diff(u(x,t),t) = diff(u(x,t),x,x) + (1-alpha)*u(x,t);

 > pd2 := diff(v(x,t),t) = mu*diff(v(x,t),x,x) + beta*v(x,t) + alpha*u(x,t);

 > ics := u(x,0) = Dirac(x), v(x,0) = 0;

Maple is unable solve the system sympolically on its own:

 > pdsolve({pd1, pd2, ics}) assuming t > 0, mu > 0;

but it can, with a little help.

The first PDE has only the unknown , so we solve it for :

 > sol1 := pdsolve({pd1,ics[1]}) assuming t > 0;

Then, substitute the result in the second PDE, and solve that for :

 > subs(sol1, pd2); sol2 := pdsolve({%, ics[2]}) assuming t > 0, mu > 0;

## Braces, brackets, and parentheses...

In several places you have used square brackets [...] and curly braces {...} for grouping your mathematical terms.  In Maple, the only delimiters that you can use for that purpose are the parentheses (...).

Adjust your code as necessary and write back if it still does not work.

## Simplify...

delvin, you should know that your equations are not comprehensible to people who are unfamiliar with numerals written in the Farsi/Persian script.  If you desire to reach the widest available help, make an effort to write your mathematics in symbols which most of the readers of this forum can understand.

 > restart;

You wish to perform your hand calculation in Maple.  Here is the original expression:

 > c := (-exp(4*d)*beta^2 + 4*alpha*exp(4*d) + beta^2 - 4*alpha)/(8*exp(2*d));

and here is the simplified form obtained by Maple:

 > convert(simplify(c), trigh);

That agrees with your hand calculation.

## This ought to do it...

 > restart;
 > g := x -> piecewise(x - 1/3 = 0, 1, 0);

 > g(3+1/3);

 > g(0+1/3);