MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

I have a Maple program that fits a nonlinear function with 9 parameters to a dataset that contains multiple records; each record gets fitted separately. The records are ordered by a certain experimental variable (an angle of a target). The initial parameters for each fit are the solutions of the previous fit; in this case I get relatively good initial estimates and not too much trouble fitting. I use Statistics:-NonLinearFit to do the actual fitting.

Since this is a bit time consuming and I need to do this a fair amount of times, I'd like to see if I can't speed his up by employing parallel programming.

One way to speed up a fit is to compute the sum of residuals in parallel; is there a way to do this in Maple?

Another way would be to run several fits at the same time. The problem I have with that in this case is that I use the results of the previous fit as starting values for the next fit. I might be able to increase the stride of this scheme; i.e. for 4 processes, use the result of fit 1 as starting point for fit 5; fit 2 for fit 6 etc. But before I embark on this non-trivial change; can Statistics:-NonLinearFit even be used in this way (i.e. is it thread safe)?? My fitting function is an actual function (as opposed to a procedure with local variables) so I don't think the function itself would cause trouble.

I could also contemplate the Grid package; except that I am concerned about the overhead moving the data over to each node (although it would all sit on one machine with 4 processors).

I realize that I may have to do some experimentation by myself, but if there is any experience out there I'd like to know about it...

Mac Dude

Everytime I re-run a workfile, I get several extra editing lines inbetween my own command lines. Have I missed something in my settings?

Best regards
Emilijan Vuletici


Use DEplot to sketch a direction field for my_deq and the solution curve for the initial condition T(0) = 88 C. Assign your plot to my_plot.

*Note: my_deq is the differential equation 


My input:


ODE2:=(Diff(T(t), t) = 1/59*(18-T(t)));

DEplot( ODE2, T(t), t=-4..4, {[T(0)=88]}, y=0..100);


Error Received: 

Error, (in DEtools/DEplot/CheckInitial) the 'number' option must be specified before initial conditions


The only thing I can find about this error is the input isn't in the form of a differential equation... But I'm pretty sure it is.


Basically I have to find omega by solving determinant of the following matrix:

M := Matrix(4, 4, {(1, 1) = 0, (1, 2) = -1, (1, 3) = 0, (1, 4) = 1, (2, 1) = -EI*beta^3, (2, 2) = -m*omega^2, (2, 3) = EI*beta^3, (2, 4) = -m*omega^2, (3, 1) = EI*sin(147*beta)*beta+k_r*cos(147*beta)+I*c_r*omega*cos(147*beta), (3, 2) = EI*cos(147*beta)*beta-k_r*sin(147*beta)-I*c_r*omega*sin(147*beta), (3, 3) = -EI*sinh(147*beta)*beta+k_r*cosh(147*beta)+I*c_r*omega*cosh(147*beta), (3, 4) = -EI*cosh(147*beta)*beta+k_r*sinh(147*beta)+I*c_r*omega*sinh(147*beta), (4, 1) = -EI*cos(147*beta)*beta^3+sin(147*beta)*k_h, (4, 2) = EI*sin(147*beta)*beta^3+cos(147*beta)*k_h, (4, 3) = EI*cosh(147*beta)*beta^3+sinh(147*beta)*k_h, (4, 4) = EI*sinh(147*beta)*beta^3+cosh(147*beta)*k_h}):

The remaining values are:


What is the proper way to deal with this problem numerically. Or maybe it is even possible to get a reasonable analytical expression?

Maple evaluates




It would be nice if Maple could simplify this to 1/8*Pi*ln(2). If you evalf the integral and use "identify" then Maple does return 1/8*Pi*ln(2).

MMa directly returns 1/8*Pi*ln(2), which seems preferable.

Hello everyone.

I have a vector field in 2d-cartesian coordinates which I would like to convert to a "normal" function, that is f(x, y) where when you put x and y in, you get the magnitude of the vector at that point.

Example vector field:

This one is very hard to handle by hand which is why I want to use Maple for it.

I tried VectorCalculus[Norm] but it gave me this:

my int is in below.

my int has hyperbolic and trigonal parts thus when they are multiplied , Maple is not able to integrate!


Now, How can I solve this integral?

thank you for help

my int is:




eq1 := m*(diff(diff(w(x, t), t), t))+diff(diff(EIy*(diff(diff(w(x, t), x), x))+(EIz-EIy)*(diff(diff(w(x, t), x), x))*(theta(x)+phi(x, t))^2, x), x)-Pz = 0

l := 16; m := .75; EIy := 0.2e5; EIz := 0.400e7; GJ := 0.1e5; mj := .1; Pz := 5000; Mz := 0; theta := proc (x) options operator, arrow; 0 end proc

w := proc (x, t) options operator, arrow; q[1](t)*(cosh(1.8751*x/l)-cos(1.8751*x/l)+(-1)*.734096*(sinh(1.8751*x/l)-sin(1.8751*x/l)))+q[2](t)*(cosh(4.6941*x/l)-cos(4.6941*x/l)+(-1)*1.01847*(sinh(4.6941*x/l)-sin(4.6941*x/l)))+q[3](t)*(cosh(7.8548*x/l)-cos(7.8548*x/l)+(-1)*.999224*(sinh(7.8548*x/l)-sin(7.8548*x/l))) end proc

phi := proc (x, t) options operator, arrow; q[4](t)*sqrt(2)*sin(1.5708*x/l)+q[5](t)*sqrt(2)*sin(4.7124*x/l)+q[6](t)*sqrt(2)*sin(7.8540*x/l) end proc


f[1] := int(lhs(eq1)*(cosh(1.8751*x/l)-cos(1.8751*x/l)-.734096*(sinh(1.8751*x/l)-sin(1.8751*x/l))), x = 0 .. l)


hello, I put in the code:

> with(plots), with(ColorTools), with(LinearAlgebra), with(RandomTools), with(ExcelTools);
> A := `<|>`(`<,>`(1, 2, 0, 2, 3, 4, 3, 4, 7, 9, 5, 3, 4, 6, 7, 8, 3), `<,>`(0, 4, 7, 2, 2, 2, 4, 5, 6.5, 7, 5, 3, 2, 5, 9, 0, 1), `<,>`(1, 5, 2, 0, 4, 1, 2, 3, 4.3, 7, 8, 5, 3, 2, 9, 6, 4)); J := convert(Import("testB1.xlsx", "Cartesian", "E2:G18"), matrix);
Error, (in convert/matrix) expecting array, rtable or list
> B := matrix([[1], [.2], [.1], [.8], [.5], [.6], [.8], [.764], [.234], [0.4e-1], [.89], [.36], [.687], [.627], [.689], [.328], [.139]]); H := convert(Import("test.xlsx", "Cartesian", "D2:D18"), matrix);
Error, (in convert/matrix) expecting array, rtable or list
> C := [seq(Color([H[i, 1], 0, 0]), i = 1 .. RowDimension(A))];


And i get the error message everytime I try import m data list and I dont understand why. Any help would be appreciated. Thank you



eq:=diff(y(x),x) - y(x)^2 - x*y(x) - x + 1;

Gives an error "(in fprintf) string expected for string format". The problem seems when the math contains "erf"? Both examples below fail with result that contains this.

Maple 18, on windows 7.

Another example:

eq:=diff(y(x),x) + a*y(x)*(y(x)-x) - 1;

Another example, which seems to fail for different reason

eq:=diff(y(x),x) + a*x*y(x)^3+b*y(x)^2;

I've been using a maple package (written by another author) on earlier versions of Maple.  Recently I have been trying to rewrite it so it's a bit more Maple 16+ friendly (since I've read that Maple is not forward-compatible). However, I have been experiencing similar strange behavior in both the original and my current version: 

After saving the module to my personal library, I load with(MyPackage). Most functions work fine (all but a handful out of dozens).  However, some functions won't be recognized (e.g., Coproduct(...) will return itself Coproduct(...)).  

HOWEVER, when I execute the code in the module in its own Maple worksheet, all functions are recognized and work perfectly.  I look at the difference in the code between the functions that work upon loading the package (using with(MyPackage) command in a separate sheet) and those that don't, and there is no difference.

I'm assuming I'll just have to cut and paste the hundreds of lines of code for my package into each sheet I'd like to use it in, since I haven't been able to find others experience this problem in the knowledge base.  I'm hoping someone will be able to help out, however.

hi all.

I have wrore the following program for optimization with bernstein and block pulse hybrid functions.

the program have some errors which i can't understand.



macro(LA= LinearAlgebra):

HybrFunc:=proc(N, M,  tj)               # N=Number of subintervals,  M=Number of functions in subintervals
local B, n, m;

global b;

for n from 1 to N do
for m from 0 to M-1 do

B := (i,m,t) -> C(m,i)*(1-t)^(m-i)*t^i:

b[n,m]:=unapply(piecewise(t>=(n-1)*tj/N and t<n*tj/N, B(m,2,N*t-(n-1)*tj), 0), t):

Array(1..N, 0..M-1, (n,m)->b[n,m](t)):

end proc:

HybrFunc(3, 3, 1);

                                       # End Of Definition
g2(t):=t;            #*exp(t-1):                      # Any other function can be replaced here

g1(t):=add(add(c[n,m]*b[n,m](t), m=0..2), n=1..3);
Optimization[Minimize](sqrt(int((g2(t)-g1(t))^2, t=0.. 1)));
plot([g2(t),g1(t)], t=0..1, 0..5, color=[blue,red],thickness=[1,3],discont, scaling=constrained);

Array(1 .. 3, 0 .. 2, {(1, 0) = piecewise(0 <= t and t < 1/3, (1-3*t)^2, 0), (1, 1) = piecewise(0 <= t and t < 1/3, (6*(1-3*t))*t, 0), (1, 2) = piecewise(0 <= t and t < 1/3, 9*t^2, 0), (2, 0) = piecewise(1/3 <= t and t < 2/3, (2-3*t)^2, 0), (2, 1) = piecewise(1/3 <= t and t < 2/3, (2*(2-3*t))*(3*t-1), 0), (2, 2) = piecewise(1/3 <= t and t < 2/3, (3*t-1)^2, 0), (3, 0) = piecewise(2/3 <= t and t < 1, (3-3*t)^2, 0), (3, 1) = piecewise(2/3 <= t and t < 1, (2*(3-3*t))*(3*t-2), 0), (3, 2) = piecewise(2/3 <= t and t < 1, (3*t-2)^2, 0)}, datatype = anything, storage = rectangular, order = Fortran_order)

g2(t) := t

"g1(t):=c[1,0] ({[[(1-3 t)^2,0<=t and t<1/3],[0,otherwise]])+c[1,1] ({[[6 (1-3 t) t,0<=t and t<1/3],[0,otherwise]])+c[1,2] ({[[9 t^2,0<=t and t<1/3],[0,otherwise]])+c[2,0] ({[[(2-3 t)^2,1/3<=t and t<2/3],[0,otherwise]])+c[2,1] ({[[2 (2-3 t) (3 t-1),1/3<=t and t<2/3],[0,otherwise]])+c[2,2] ({[[(3 t-1)^2,1/3<=t and t<2/3],[0,otherwise]])+c[3,0] ({[[(3-3 t)^2,2/3<=t and t<1],[0,otherwise]])+c[3,1] ({[[2 (3-3 t) (3 t-2),2/3<=t and t<1],[0,otherwise]])+c[3,2] ({[[(3 t-2)^2,2/3<=t and t<1],[0,otherwise]])"

Error, (in Optimization:-NLPSolve) complex value encountered

Error, invalid left hand side in assignment


Download Bernestien1.mws

 I'll be so grateful if any one can help me.

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

can i compute this integral so that the answer does not have any complex part ? i just want the integral returns me real function or number .
 i also use evalf(int ... ) and evalf(Int ... ) and two different answers were given ! what is wrong ?
tnx for help in advance .


int(log(sec(x)+ tan(x)),x);



evalf(Int(log(sec(x)+ tan(x)),x=0..10));



evalf(int(log(sec(x)+ tan(x)),x=0..10));






Solve Integral...

July 12 2014 vhha1972 10
1 4

Hi there,

I am trying to do a Fourier transform of the function

f(t) = 3*cos(2000*Pi*t)

I use Fourier transform definition to solve the following integral in Maple:

Int(3*cos(2000*Pi*t)*exp(-(I*2)*Pi*f*t), t = -infinity .. infinity)

I get the answer as "undefined".

The correct answer is:






Is it possible to solve linear matrix inequality in Maple?
For example, using Matlab and yalmip we can easily
solve Lyapunov equation
    A'P + P * A <0, P> 0

Is it possible to solve this equation in the Maple?




we have an exam next week and I want to know

how I can write (fordo) in maple for numerical integration

in different methods such as trapezoid , newton cotes and so on.


5 6 7 8 9 10 11 Last Page 7 of 1032