Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Note: It seems in the course of writing this question I found the answer, but I am still interested in any tips on the best workflow to update a library. Here is the original post (annotated ex post in bold):

I have successully created my own package in Maple. I basically used LibraryTools:-Create to create an .mla file and then I used LibraryTools:-Save, passing in the name of my package and the path to the .mla file. I did this in a worksheet.

I can import it with the command with(MyPackage).

I'd like to add code to the package.

I have a package defined in as

module MyPackage()
  option package;
  export MyModule;

  module MyModule()
    (...)
  end;
 end;

I would like to add a procedure to be exported inside the package.

I tried to add the procedure, save the file, and then use LibraryTools:-Save again, but the error I get is 

Error (in MyPackage) attempting to assign to 'MyPackage' which is protected. Try declaring local 'MyPackage'; see ?protect for details.

I tried to unprotect the name 'MyPackage' but this gives another error

Error, on line %1, unexpected end of input. Error while reading '%1' (this turned out to be a missing semicolon on the Save command, which was the last command in the mpl file. The error messags are quite unhelpful)

Note: As I mentioned before, I did the initial saving of the package from a worksheet (the package code was in a code editing region in the worksheet). In the current attempt to add the new procedure, I copied the code to an .mpl file so I could edit it in a code editor (VSCode). At the end of this file I added the commands to LibraryTools:-Save the package again to the same .mla file as before.

My attempt to unprotect the name "MyPackage" involved simply adding unprotect('MyPackage') as the first line in this .mpl file.

I then used the command read to execute the mpl file from within a worksheet.

What am I doing wrong, and what is the recommended workflow to be able to work on a package?

If I try to update a simple variable in the .mla file it seems to work.

EDIT: The problem seems to be the use of the named module initially, ie module MyPackage().

If I try the whole process again (write a simple package and save it to the mla file) but this time I use the syntax

MyTestPackage = module()

then I can update it no problem (at least for a simple package that I just wrote; for the actual package with my real code I still get even though Maple is able to read the mpl file without a problem, apparently there is still some issue while trying to save. 

Error, on line %1, unexpected end of input. Error while reading '%1'   (turns out it was the missing semicolon)

In summary: don't used named module syntax.

Hello guys.
I want to solve Laplace's equation for a triangle plate, subject to the following boundary conditions:

For the contour y = x, u(x,y) =20

For the contour y = -x+2, u(x,y) =100

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

Regards,

Oliveira

Hi maple users 

I am working with the PDE solver.

i am receiving a following error

"unable to compute solution for t>HFloat(0.0):" 

Kindly do the needful how to rectify this error.

dumm.mw

HHow do i correct "error, illegal use of an object as a name"

Dear maple user i am facing difficulty to plot the graph   for different values  of parameter M=2,4  and fixing t=j=0 to 2 and   y=i=0 to 4 on x axis and U on y axis. I am unable to plot 2D . I am enclosing the codes and sample graphs. 

restart; 
# Parameter values:
 Pr:=0.71:E:=1:A:=0:Sc:=0.02: K:=1:

a := 0: b := 1: N := 9:
h := (b-a)/(N+1): k := (b-a)/(N+1):

 lambda:= 1/h^2:  lambda1:= 1/k^2:
# Initial conditions
for i from 0 to N do 
  U[i, 0] := h*i+1:
end do:


for i from 0 to N do 
  T[i, 0] := h*i+1:
end do:
for i from 0 to N do 
  C[i, 0] := h*i+1:
end do:

# Boundary conditions
for j from 0 to N+1 do 
  U[0, j] := exp(A*j*lambda); 
  U[N+1, j] := 0;
  T[0, j] := j*lambda1; 
  T[N+1, j] := 0;
  C[0, j] := j*lambda1; 
  C[N+1, j] := 0 
end do:


#Discretization Scheme
for i to N do 
  for j from 0 to N do 
    eq1[i, j]:= lambda1*(U[i, j+1]-U[i, j]) = (Gr/2)*(T[i, j+1]+T[i,j])+(Gr/2)*(C[i, j+1]+C[i,j])+(lambda^2/2)*(U[i-1,j+1]-2*U[i,j+1]+U[i+1,j+1]+U[i-1,j]-2*U[i,j]+U[i+1,j])-(M/2)*(U[i,j+1]+U[i,j]) ;
    eq2[i, j]:= lambda1*(T[i, j+1]-T[i, j]) = (1/Pr)*(lambda^2/2)*(T[i,j+1]-2*T[i,j+1]+T[i+1,j+1]+T[i-1,j]-2*T[i,j]+T[i+1,j])+(E*lambda^2)*((U[i+1,j]-U[i,j])^2);
    eq3[i, j]:= lambda1*(C[i, j+1]-C[i, j]) = (1/Sc)*(lambda^2/2)*(C[i,j+1]-2*C[i,j+1]+C[i+1,j+1]+C[i-1,j]-2*C[i,j]+C[i+1,j])+(K/2)*((C[i,j+1]+C[i,j]))  
  end do
end do:


#
# Determine the unknowns in the system
#
  `union`(  seq(seq( indets( eq1[i,j], name), i=1..N), j=0..N),
            seq(seq( indets( eq2[i,j], name), i=1..N), j=0..N),
            seq(seq( indets( eq3[i,j], name), i=1..N), j=0..N)
          );
#
# And how many unknowns
#
   numelems(%);
#
# And the number of equations
#
  numelems(eq1)+numelems(eq2)+numelems(eq3);

#
# So if one supplies values for 'Gr' and 'M', and
# (assuming the equations are consistent), one ought
# to be able to get values for C[1..9, 1..10],
# T[1..9,1..10], and U[1..9,1..10]
#
# As an example below, choos Gr=1.0 and M=2, then the
# following obtains a 'solution` afer a minute or so
#
  fsolve( eval( [ seq(seq(eq1[i,j], i=1..N),j=0..N),
                  seq(seq(eq2[i,j], i=1..N),j=0..N),
                  seq(seq(eq3[i,j], i=1..N),j=0..N)
                ],
                [Gr=1.0, M=2]
 )
        );


 

 

 

Hi got this set of error using the Plot package. Anyone here know what they mean? 

Hello community. I'm trying to use Maple for some study.
My goal is to get the Wiener-Hopf equation in matrix form like in the book (eq 3.56).
So at first i need the gradient of eq 3.53, the result is eq 3.55 (nabla is not printed) .
Could you please provide an example of this operation, if it is possible, thanks.


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

Hello everyone!

I use this procedure to open my inbox:

>restart;
ShellExecute := define_external('ShellExecuteA', hwnd::(integer[4]), lpOperation::string, lpFile::string, lpParameters::string, lpDirectory::string, nShowCmd::integer[4], 'RETURN'::integer[4], LIB = "C:\\WINDOWS\\SYSTEM32\\shell32.dll"):
OpenBrowser := proc(someURL::string := "http://")

ShellExecute(0, " ", someURL, " ", " ", 1); NULL;

end proc:

Case 1:  I entered the correct email address of my friend who sent me the mail

>OpenBrowser("https://mail.google.com/mail/u/0/?tab=rm&ogbl#inbox/xxxxxxGqRZXPKXGzrrSrfHscdNWspRJF");

As a result, the content of the message I received was opened with full information.

Case 2:  When I enter an arbitrary email address that is not my friend, the result is that no content is displayed.

>OpenBrowser("https://mail.google.com/mail/u/0/?tab=rm&ogbl#inbox/yyyyyyGqRZXPKXGzrrSrfHscdNWspRJf");

On the email there is only the message: The conversation you requested could not be loaded.

May I ask:  Is there any Maple command to return true in case 1 and to return false in case 2 ?

Thank you very much for your help !

As you can see in the figure below, 

it shows a very strange "font",

you can obviously see very weird spacing even inside one word...

Who knows what's wrong???

Thanks a lot.

B/R

Jankel

Good day,

I am looking for some guidance with the Syrup toolbox

I have a netlist that was generated with the Altium designer Spice simulator (XSpice based), I was able to import it into LTSpice and verrify the results.

I want to move it into maple to make use of the modellica code generation.

I then began modifying the netlist in order to meet the netlist syntax of Syrup. One of the most prominant change I needed to make was the arbitrary input nodes for my Voltage dependant Voltage sources. 

Therefore, for any line that implies arbitrary sources such as:

E_U8_E1 U8_N208620 LO
+ VALUE { IF(V(U8_N208706, 0) > 0.5, 5, -5) }

was changed to:

V1    16   17 1vdc

E_U8_E1 U8_N208620 LO 16 17
+ VALUE { IF(V(U8_N208706, 0) > 0.5, 5, -5) }

This, of course, is a non ideal workaround which brings me to question 1,

Is there a way to define a arbitrary source with the Spice parser in Syrup?

Once these changes were made, it seems the Solve function in Syrup can parse the netlist without issue, however when it gets to the Solve portion it throws the following error:

Solve("file://C:/Users/msavoy/Documents/Spice_cct/inverter_newfet_nonot.cir", 'tran');
Solve: Analyzing SPICE deck "The Apple" (ignoring this line)
Error, (in Syrup:-Solve) invalid input: rcopy uses a 1st argument, A (of type anything), which is missing

Attached is a copy of the netlist, inverter_newfet_nonot.txtI am honestly at a lost as to what could be throwing the rcopy error

Furthermore, I wanted to test out the Modellica code generation in Syurp, it appears that it does not like having subcircuits, as running the test:

V 1 0 1
L1 1 2 L
C1 2 0 C
L2 2 3 L
C2 3 0 C
L3 3 4 L
C3 4 0 C
Vshort 4 5 0
Rt 5 0 1
.SUBCKT TEST A B C Y
V1 14 15 1
EINT YINT 0 14 15
+ VALUE {IF(V(A) > 0.5 && V(B) > 0.5 && V(C) > 0.5, 1, 0)}
RINT YINT Y 1
CINT Y 0 1n
.ENDS TEST
.end

provides the error of:

test_c := ToModelica("file://C:/Users/msavoy/Documents/Spice_cct/test_cct_RCL.txt", 'probes' = ["Rt.v"], 'parameters' = {C = 2, L = 1});
Error, (in Syrup:-ToModelica) invalid input: nodeToModelica expects its 1st argument, node, to be of type nonnegint, but received Y

Is it possible to define a sub circuit in a netlist that is to be converted to Modellica, or do all subcircuits need to be defined in their own file?

Thank you

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

Hello everyone,

I am trying to solve a system of 4 ODEs that describe a physical system, however, I get the message:

Error, (in dsolve/numeric/bvp) matrix is singular

Any help is much appreciated. The initial conditions are such that to find solution in steady state, that means, v(0)=v(period) and so on with all variables.

Download LLCcircuit_SteadyState_numerical.mw

Good day. 

I have been looking into the time series features in Maple and was eager to apply the models to one specific example containing 47 data points (attached).

When I run the ESM routine, Maple provides a forecast based on a (A,N,N) configuration. You will notice that the forecast for the following 12 data points is a constant value. I have also noticed this for several other data set examples and I would have expected the predictions to vary across the next 12 data points.

Does the (A,N,N) configuration in Maple automatically provide an optimal forecast and can anyone advise me on how to specify all possible combinations of (error, trend, season) models?

Thanks you for reading.

MaplePrimes_TS_Example.mw

First 11 12 13 14 15 16 17 Last Page 13 of 2025