Items tagged with compile

Also available: compile

 Question:- can the procedure given below called "epi" be speeded up by compiling/ using evhf.If so how? My paple code is at the bottom.

First some background information.

Recently I ran into a difference in usage of a couple of elliptical functions between Maple and Mathematica.  This first case concerned EllipticalPi. The author of the blog kindly wrote  a Maple procedure to produce the same results as Mathematica’s  usage of ElllipticalPi.

I tested the basic integral that produces the EllipticPi    Ell := int(1/(1-nu*JacobiSN(t, k)^2), t)  answer      Ell := EllipticPi(JacobiSN(t, k), nu, k). They do not produce the same outcome. Plots are in the document .  They agree in one quarter only.

 I then ran into a difference in usage of  EllipticF. This time I was able to get to same outcome myself using Maple’s help.

“It is worth noting the difference between the Legendre normal form of the Incomplete Elliptic integral of the first kind (see A&S 17.2.7), in Maple represented by EllipticF(z,k) but for the splitting of the square root in the denominator of the integrand (see definition lines above), and the normal trigonometric form of this elliptic integral (see A&S 17.2.6), in Maple represented by the InverseJacobiAM function

That worked fine.

There is no mention in the help for usage implementation of EllipticPi as opposed to different usages as there is with EllipticF. I do not know if there is a way in Maple of achieving the same enactment as Mathematica in this case, without the Procedure I  was  given.



Elliptic Pi in Mathematica and Maple

Posted on 2017/02/202017/02/23 by arkajad

We use EllipticPi when we write exact solutions of rotation of a free asymmetric top. While solving Euler’s equations for angular velocity or angular momentum in the body frame we need Jacobi elliptic functions \cn,\sn,\dn,solving the differential equation for the attitude matrix involves EllipticPi function. As I have explained it in Taming the T-handle continued we need the integral

(1)   \begin{equation*}\psi(t)=c_1 t+c_2\int_0^t \frac{1}{1+c_3\,\sn^2(Bs,m)}\,ds.\end{equation*}

In Mathematica this is easily implemented as

(2)   \begin{equation*}\psi(t)=c_1 t+\frac{c_2}{B}\,\Pi(-c_3;\am(Bt,m)|m).\end{equation*}

However, as pointed out by Rowan in a comment to Taming the T-handle continued , the same formula does not work with Maple.

While the documentations of both Mathematica and Maple contain links to Abramowitz and Stegun Handbook of Mathematical Functions, they use different definitions. Here is what concerns us, from p. 590 of the 10th printing:

What we need is 17.2.16, while Maple is using 17.2.14. To convert we need to set x=\sn u,but such a conversion is possible only in the domain where \sncan be inverted. We can do it easily for sufficiently small values of u,but not necessarily for values that contain several quarter-periods.

The following Maple procedure does the job:

epi := proc (t::float, nu::float, k::float) local t2, n, dt, ep0, res; ep0 := EllipticPi(nu, k); t2 := EllipticK(k); n := floor(t/t2); dt := t-t2*n; if type(n, even) then res := Re(n*ep0+EllipticPi(JacobiSN(dt, k), nu, k)) else res := Re((1+n)*ep0-EllipticPi(JacobiSN(t2-dt, k), nu, k)) end if end proc

HAs an example here is the Maple plot for nu=-3, k=0.9:
plot(('epi')(t, -3.0, .9), t = -20 .. 20)

And here is the corresponding Mathematica plot:

The function epi(t,nu, k) defined above for Maple gives now the same result as EllipticPi(nu,JacobiAM(t,k^2),k^2) in Mathematica.

epi := proc (t, nu, k) local t2, n, dt, ep0, res; ep0 := EllipticPi(nu, k); t2 := EllipticK(k); n := floor(t/t2); dt := t-t2*n; if type(n, even) then res := Re(n*ep0+EllipticPi(JacobiSN(dt, k), nu, k)) else res := Re((1+n)*ep0-EllipticPi(JacobiSN(t2-dt, k), nu, k)) end if end proc;

Ell := int(1/(1-nu*JacobiSN(t, k)^2), t);
            Ell := EllipticPi(JacobiSN(t, k), nu, k)
k := .9;
                            k := 0.9
nu := -3;
                            nu := -3
plot([epi(t, nu, k), Ell], t = -8 .. 20);



I'm trying to compile a worksheet and save it on Mac OSX. The worksheet ends with this code:


> save `E:\\class work\\THERMODYNAMICS\\ThermoSoft\\Compiled\\SteamTables.m`;


The guide tells me to change the path to a user specified folder where the .m file will be saved.

Since the path name already given is a Windows path, I have to change that to a Mac path.

My problem is, that i don't know what I should write?

I have tried writing:

save `\\Macintosh HD\\Users\\Name\\Folder\\SteamTables.m`;

But it gives an error, and can't save the file. 

I recently got myself a 64 bit computer and have noticed that I cannot use the option compile=true in dsolve/numeric. Take the following simple example:

Error, (in dsolve/numeric/SC/preproc) unable to compile (rc=1), please try again, and if that fails verify your Windows compiler installation

I'm using Windows 10, but had the same problem with Windows 8.1 on the same machine.
The Compiler:-Compile examples in the help page all work.

What do I have to do to make the option compile=true work in dsolve/numeric?

You may safely assume that I don't know any technicalities about these things.


I am facing a problem with the c-code generation of maplesim models:

When I am trying to compile a multibody model that contains more than about 80 bodies I get an error "Error, (in GetCompiledProc) internal error: unable to find matching".

Using the code generation template it says "Error in Component cmdGenerateCode eith caption "Generate C code": (in DSN/Pantelides) internal error: unable to find matching"


Has anyone a solution to this?



Model: Ref_Model.msim

It is a simple systems of masses connected by spring/dampers.

I am using MapleSim 7.01

The error message occurs when I try to simulate the model in maplesim, too:

Using the Mark II engine
Simplifying system with 600 equations
Simplification removed 0 equations. Remaining equations: 600
Generating simulation code
DAE index reduction
DSN/RunSimulation: internal error: unable to find matching
(in DSN/RunSimulation) internal error occurred during simulation
Simulation failed.



Hello!  Hoping that Maple 16 is now better with function compilation, I have compiled the rather simple function that returns the complex value.  As I understand from the code below, Maple automatically assumes the arguments to be complex.  That's fine.

The compiler gcc gives some errors:

/var/tmp/sergey-2181/_m71f6dec6b3c75a742676f2dcb3fa1864.c: In function ‘_c71f6dec6b3c75a742676f2dcb3fa1864’:

Is there a way to stop maple at a particluar line in a worksheet> I frequently have to compile my worksheet from the beginning up to whatever line I'm writing on (which may be in the middle of the file).  RIght now I'm highlighting all lines above my current one and clicking the ! symbol.  Is there a command I can type, which will allow me to click on the !!! button but will stop computation at the line on which the command is written? Continuously highlighting...



I have to design a wheeled mobile robot for my bachelor-thesis. the robot should be controlled in Simulink. Therefore, I have to use the Simulink Component Block Generator. Outputs are: yaw angle/rate, absolute position in x/z and its derivatives, wheel angle and its derivative,steering angle. Inputs are one torque for steering and one torque for actuatuating for each wheel. -->6 torques (3 wheels). When I click on the "Generate and Compile...

Question is very simple:

if I write square root as  f^(1/2) , then the compile function gives a error: 

Error, (in Print) rational numbers and arithmetic are not yet supported

if I write it as sqrt(f) then compile works.

But Maple seems to internally always convert sqrt(f) to f^(1/2). So, I am constantly getting the above error!

Is there a workaround? I have an impression of very poorly written Compile function....


I have a strange issue:   I have a procedure with signum, square roots, I and float numbers. First I optimize it and then compile.  (or just run compile with option optimize=true).  As a result I get a error:

Error, (in TargetLanguageTools:-GetExprType) Analysis is not a command in the _EnvCGEngine package

Trying to understand, what is happening, I manually copy-paste the optimised procedure to the argument of compile. Then it works!!!

Hi all,

I'm currently running a parameter space search via Maple scripting. The pseudo-code goes something like this:


fopen text file to write data to;

initialize parameters (variable) x, y, and z;

for x number of iterations

   A:-Simulate(model.msim, with [parameters]);

   Update parameters with new values;

   Write to text file;

end do;

fclose(text file)

Wide set of expressions can convert to compiled functions. Expressions can even include definite integrals.
Hope it helps for others who want really speedup calculations in maple as much as possible for now.


Checked under 15.01 version

How to do subj? Straightforward way doesn't compile:


myint:= proc(u::float)::float;
return int(exp(x^6), x=0.0..u);
end proc:

createcomp:=proc (expr::evaln, exprfunc::evaln);
return Compiler:-Compile(exprfunc,optimize);
end proc:
s:=createcomp(global_expr, global_exprfunc);

"Error, (in Print) cannot translate value of lexically...


tryed to compile samples\OpenMaple\cmaple\omexample.c in MS Visual C++ Express 2010. Everything is OK but after running is writes "The program can't start because maplec.dll is missing from your computer..." Why? I've linked maplec.lib statically! Besides \Maple\\ in my library path where both maplec.dll and maplec.lib are. System - Win7 Home Premium +SP1

And so with this provocative title, "pushing dsolve to its limits" I want to share some difficulties I've been having in doing just that. I'm looking at a dynamic system of 3 ODEs. The system has a continuum of stationary points along a line. For each point on the line, there exist a stable (center) manifold, also a line, such that the point may be approached from both directions. However, simulating the converging trajectory has proven difficult.

I have simulated as...

1 2 Page 1 of 2