Maple 2022 Questions and Posts

These are Posts and Questions associated with the product, Maple 2022

I would like to be able to use python's matplotlib from Maple. I am doing the following currently

with(Python)
Start('home' = "/opt/anaconda3/lib/python3.9", 'path' = "/opt/anaconda3/lib/python3.9/site-packages")
ImportModule("matplotlib as mpl")

and the error I get back is

Error, (in Python:-ImportModule) ModuleNotFoundError: No module named 'matplotlib'
['Traceback (most recent call last):\n', '  File "<string>", line 1, in <module>\n', "ModuleNotFoundError: No module named 'matplotlib'\n"]

The string I passed into path is the directory where matplotlib seems to be located as far as I can tell. I looked this up in my IDE Spyder, but using the command print(matplotlib__file__).

UPDATE: but actually if I open a new worksheet and execute 

with(Python)
Start('home' = "/opt/anaconda3/lib/python3.9", 'path' = "/opt/anaconda3/lib/python3.9/site-packages")

The error is that 

Error, (in Python:-Start) unable to start Python: could not create process, mpython

So Maple isn't finding Python apparently.

I tried for 'home' also "/opt/anaconda3/bin", did not work.
 

I have a fairly simple worksheet with a 56x2 matrix M1 which I am trying to export to Excel with the following 

ExcelTools:-Export( M1, "C:/Temp/M1.xlsx", 1, "B2")

This causes the following message to appear

After that the program is frozen and totally unresponsive.  The only way to proceed is end the task in Task Manager..

I am trying to upload the worksheet but am not sure if I have succeeded

Download Calculation_of_pH_from_known_values_of_Vb.mwCalculation_of_pH_from_known_values_of_Vb.mw

I created a Github repository with files to reproduce the example that my question is based on.

I am using Grid:-Run to compute a 10000x3 matrix in each of 100 parallel runs. I then average the 100 matrices to obtain a final 10000x3 matrix, which I saved to an .m file.

It contains a variable called with the matrix.

Each row of the matrix is a 3d point, and the entire matrix represents a trajectory on a sphere. I'd like to display an animation of this trajectory. Now, my question is not about how to do this, but rather about the memory requirements necessary to do so.

I can plot trajectories with, say, 1000 points, but apparently 10000 requires too much memory.

The Github repository I linked to contains an example of all of this.

The worksheet matrixTest.mw reads the matrix from the .m file and reads some procedures defined in the .mpl file that are used for creating the animation data.

Then, a call to the procedure animateMatrices basically calls plots:-display to display the matrix as an animation.

I've been able to display the first 5000 rows of the matrix.

What type of memory is running out when I try to display the animation of the full 10000 rows?

Here is a screenshot of my Activity Monitor right before I get the

Error, out of memory error while processing result

This question is based on the following worksheet I created specifically to show my question: Animation_Test.mw

Unfortunately, MaplePrimes gives me an error when I try to insert the contents here directly.

Basically my question is about the syntax of plots:-display.

I have a sphere

sphereDisplay := plottools:-sphere([0, 0, 0], 1, transparency = 0.9);

and something which is the result of calling plots:display on a sequence of two other other plots:-display.

arrowAndTrailDisplay := plots:-display(seq(plots:-display(computeArrowPlotFrame(m, t, red), computeTrailPlotFrame(m, t, windowSize, red)), t = times), insequence = true)

You can see in the attached worksheet what computeArrowPlotFrame and computeTrailPlotFrame are, but they are basically lists of plot structures. arrowAndTrailDisplay is thus an animation containing two different sequences of frames.

I wish to have Maple plot the sphere and the animation together. This works as expected (a static sphere and the animation of an arrow and a trail of the path of the tip of the arrow)

plots:-display([sphereDisplay, arrowAndTrailDisplay]):

but the following does not work as expected (instead it plots each frame separately)

plots:-display([arrowAndTrailDisplay])

adding insequence=true to the latter makes it work. But my question is why do I have to add that? I can't understand, from syntax standpoint why the former plots arrowAndTrailDisplay as an animation but the latter does not.

Hello everyone,

I am trying to solve a system of six equations through a matrix and a vector. The matrix is 6x6, so the function "LinearSolve" should find a solution 

The matrix is

Matrix(6, 6, [[1., -1., 1., -1., 1., -1.], [1., 1., 1., 1., 1., 1.], [-2., 1.618033989, 30.94427190, -153.8246851, 371.1559479, -572.9674774], [-2., 0.6180339876, 22.94427191, -41.15905356, -37.04759741, 149.3606798], [-2., -0.6180339876, 13.05572810, 22.82468509, -20.15594802, -81.03252254], [-2., -1.618033989, 5.055728096, 28.15905368, 68.04759752, 104.6393203]])

and the vector associated with the system is

Vector[column](6, [-1/3, -1, 0, 0, 0, 0])

I am trying to solve this system with

a := LinearSolve(M3, v);

but it stays evaluating.

I have solved a similar system (5x5) with this function (LinearSolve) and it took less than a second, so I dont understand why it takes so long in this case.

Thank you in advance.

During my reaserch on diffusion I am arrived at the integral with argument

exp(-1/sqrt(x^2 + 1)) which Maple is not able to solve.

If some experts in solving integrals is able to solve it please keep me informed.

The file in Maple 2022 is below

primes_integral_diffusion.mw

in the context of solving an ode, sometimes the constant of integration that will satisfy an initial condition is +infinity or -infinity.

But Maple's solve does not find such solutions to the constant of integration. It only can solve for finite value if it can.

When this happens, I manually try taking the limit as the constant of integration goes to +- infinity, until I get an equation where both sides are the same or fail, and then give up.

I was wondering if there is a way or different command/package which will find solution such as infinity (which is valid solution to constant of integration).

Here are two examples

ode:=diff(y(x),x)=1/(LambertW(-exp(-1+_C1+x))+1);
ic:=[diff(y(x),x)=1,x=0];
eq2:=eval(ode,ic);
solution_for_constant := solve(eq2,_C1,'allsolutions'=true,'tryhard'=true);

Maple can not solve for _C1. It gives

But when trying manually few values, I find that _C1=-infinity satisfies the equation

limit(rhs(eq2),_C1=0);
limit(rhs(eq2),_C1=1);
limit(rhs(eq2),_C1=-1);
limit(rhs(eq2),_C1=infinity);
limit(rhs(eq2),_C1=-infinity);

The above shows that _C1 = -infinity is the constant of integration. Another simpler example

eq:=exp(-1 + _C1) = 0;
solution_for_constant:=solve(eq,_C1) assuming real;
limit(lhs(eq),_C1=-infinity)

The above shows that _C1=-infinity is solution for exp(-1+C_1)=0.  which one can see by just looking at it as exp(-infinity)=0.  Adding assumptions did not help.I also tried symbolic option.

I am not familar with SolveTools package, may there is something there.

So for now, my code just try the limit until it finds solution or gives up.

Any suggestions if Maple itself can find such solutions?

Maple 2022.2

if isolate fail, then it returns back the input equation. But if solve failed to solve for the variable in question, it returns either NULL or empty list, or empty set (depending on the input). So it is easy to check if it failed or not.

How does one check that isolate failed? Should I check the left side of what isolate returns is the variable I am solving for? For an example,

sol:=isolate(-2*y-cos(y)+x+sin(x)-_C1 = 0,y)

returns back -2*y-cos(y)+x+sin(x)-_C1 = 0

Is the following the correct way to check if isolate solved the equation or not:

sol:=isolate(-2*y-cos(y)+x+sin(x)-_C1 = 0,y);
if lhs(sol)=y then
   print("it solved it. Soltion is ",sol);
else
   print("Failed to solve it. Try solve command now ");
fi;

Just wanted to make sure as help for isolate does not mention anything about what happens if isolate can't solve the equation.

Maple 2022.1

Hi,

Since a couple of years ago,  SQLite has been enriched with a bunch of new math functions not existing in previous versions: acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi. 

Examples: In SQLite version 3.39.4 2022-09-29 15:55:41 we can invoke:

sqlite> select pi();
3.14159265358979

sqlite> select power(2, 3);
8.0

sqlite> select floor(2.35);
2.0

Package Database[SQLite] in Maple 2022.2 does not recognize these functions.

In oldest versions of Sqlite3 we were able to add these functions after loading an external extension with sqlite3 api function load_extension() (see  https://sqlite.org/contrib/download/extension-functions.c), but his option is blocked in Maple:

dbName := "d:/sq3_maple/etc.db":
sq3Extension := "d:/sq3_maple/extensions.sq3":

with(Database[SQLite]);
[Attach, Bind, ClearBindings, Close, ColumnCount, ColumnNames, 
  Execute, Fetch, FetchAll, FetchRow, Finalize, Open, Opened, 
  Prepare, RESULT_BUSY, RESULT_DONE, RESULT_ROW, Reset, Step]

conn := Open(dbName):
Execute(conn, sprintf("SELECT load_extension('%s')", sq3Extension));
Error, (in Database:-SQLite:-Execute) not authorized

Am I missing something? Any way to add these functions to SQLite in current version of Maple?

Thanks in advance.

César Lozada

PS: SQLite is updated in Mathematica 13.1

 

 

 

with(Physics)

diff(x(t), `$`(t, 2)) = a(t)

diff(diff(x(t), t), t) = a(t)

(1)

dsolve(diff(diff(x(t), t), t) = a(t), arbitraryconstants = subscripted)

x(t) = Int(Int(a(t), t), t)+c__1*t+c__2

(2)

a(t) = 1.*Unit('m'/'s'^2), c__1 = 2*Unit('m'/'s'), c__2 = 3*Unit('m')

a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m)

(3)

subs(a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m), x(t) = Int(Int(a(t), t), t)+c__1*t+c__2)

x(t) = Int(Int(1.*Units:-Unit(m/s^2), t), t)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(4)

value(%)

x(t) = (1/2)*t^2*Units:-Unit(m/s^2)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(5)

NULL

Warning, units problem, not enough information to unambiguously deduce the units of the variables {t}; proceeding as if dimensionless

How can I provide the information to Maple that the unit of t is s?

 

Update: Temporarily disabling the warning would also be an option for the above case.

 

Download Unit_of_t.mw

Hello:

I've changed my laptop this week and I'd like to know how to install Maple with my account in the new one.

Thanks in advance.

Sergio Sanz.

Hi senior, I am using Maple 2022 version. I am facing a issue regrading opening of maple worksheet. If connected with wifi then maple worksheet will open and work properly, while i disconnected the internet, maple crashed and pop up a message to activate license again..

Is there an assumption or some other way I can tell Maple to avoid such errors when using odetest, as I get many of them.

I think the solution Maple gives is correct. But odetest generates these strange innternal error that it does not know the sign of a complex number.

restart;
ode:=x^2*diff(y(x), x$2) + (cos(x)-1)*diff(y(x), x) + exp(x)*y(x) = 0;
sol:=dsolve(ode,y(x),series):
odetest(sol,ode,series,point=0);

Error, (in odetest/series) need to determine the sign of I*3^(1/2)

I've seen such error many times before and it is still not fixed in release after release.

I am using Maple 2022.1 on windows 10.

simplify is a procedure in Maple that have as parameter an assumption ¿Have the assumption a default value? For example, if we consider the following code:

restart;
f:= (x^3 - 27) / (x^2 - 3 * x):
print(f = simplify(f));

The output of that code assume that denominator is not zero, so I think the procedure have a default value for assume parameter.

When displaying two tubeplots together, we may specify their colors at will, as long as they are different colors!  For instance, specifying red and green works correctly, but specifying red and red results in red and black!

See the attached worksheet.  Interestingly, when displaying the contents of the worksheet on this website, the colors are rendered correctly!  So don't go with what you see on this web page; look inside the worksheet instead.

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

with(plots):

Two intersecting tori colored red and green -- works as expected:

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2),
style=surface, color=[red,green]);

When we set both colors to red, one of the surfaces is painted black!  Why?

Please note: This website displays the colors corectly as red and red.  But

within the worksheet the colors are read and black.

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2),
style=surface, color=[red,red]);

Specifying colors as red/red within the tubeplots still produces red/black!

display(
        tubeplot([cos(t), 0, sin(t)], t=-Pi..Pi, radius=0.2, color=red),
        tubeplot([cos(t), sin(t), 0], t=-Pi..Pi, radius=0.2, color=red),
style=surface);

Download mw.mw

PS: As a workaround, we may replace the red & red specification with
COLOR(RGB, 1, 0, 0) and
COLOR(RGB, 1, 0, 0.01)
which are different enough to make Maple happy, but produce essentially the same red color.

3 4 5 6 7 8 9 Last Page 5 of 39