Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi All,

I have problem how to formulate optimization problem with additional parameters.
For example let objective function is as follow:

    return sin(x) + cos(x) + Delta;
end proc;

In Matlab we can formulate the following optimization problem:

Delta = 10;
options = optimset('Algorithm','interior-point');
x = fmincon(f,0.1,[1;2],[],[],[],[],[],[],options);


function y = ObjF(x,Delta)
    y = sin(x) + cos(x) + Delta;

In above example I can pass additional parameters (Delta) to objective function an then I can start optimization
to find solution. How to define above problem in Maple ? How to pass additional  parameters  befor we starat the optymalization?



When a list is so big, full combination can not be calculated in limited time

is there any skill to split into small combinations when use with combination packages?

originally I can use for loop to do this 

but it need to refactor code in order to write well in generic style. 

Is there another skill to use combination package instead of for loop

#my testing for wildcard to one
#after testing, it loop a very long time and not stop
ppp := [[0,0,0,x],[0,0,1,0],[0,1,0,0],[1,0,0,0]]:
check1 := [seq(0,ii=1..nops(ppp))];
ttt1 := [[0,0,0,1],[0,0,1,0],[0,1,0,0],[1,0,0,0]]:
mmmeaght1 := [seq(0,ii=1..nops(ppp[1]))]:
bbb1 := [seq(0,ii=1..nops(ppp[1]))]:
emap := [(xx) -> if [xx < 0 assuming x > 0] then 0 else 1 end if, (xx) -> evalf(1/(1+exp(xx)))]:
MM(ppp, ttt1, mmmeaght1, bbb1, check1, emap);

when test wildcard variable for input, would like to assume x > 0 then

i try assuming x > 0 , got error


I am practicing with some diff equations. I am having problem solving for one of the constants. I am having a pproblem assigning a value to derivatives or 2nd derivatives. What is a good general technique is this type of situation?




omega^2 = g/l

omega^2 = g/l


Eq1 := diff(Theta(t), t, t) = -omega^2*Theta(t)

diff(diff(Theta(t), t), t) = -omega^2*Theta(t)


ics := Theta(0) = 0, (diff(Theta(t), t))(0) = Vmax, (diff(Theta(t), t, t))(0) = 0

Theta(0) = 0, (diff(Theta(t), t))(0) = Vmax, (diff(diff(Theta(t), t), t))(0) = 0


SHM := dsolve({Eq1, ics})


SHM := dsolve({Eq1})

{Theta(t) = _C1*sin(omega*t)+_C2*cos(omega*t)}


SHM := dsolve({Eq1, Theta(0) = 0})

Theta(t) = _C1*sin(omega*t)



diffSHM := diff(SHM, t)

diff(Theta(t), t) = _C1*omega*cos(omega*t)



(Theta(t))(0) = 0, (diff(Theta(t), t))(0) = V

(Theta(t))(0) = 0, (diff(Theta(t), t))(0) = V











I was trying to write a procedure that would compute a simple linear equation using the Extended Euclidean Algorithm. I was thinking of a procedure like the following:

solveEeaMatrix := proc (a::list, b::list) 
 local c::list;  
 c := a -iquo(a[1],b[1])*b;  
 while (c[1] <> gcd(a[1],b[1]) do 

I am basically stuck at this part as

1) I don't know how to setup a multi-dimensional array that could dynamically grow(as a possible solution).

2) I can't come up with a recursive function that could possibly take care of this.

In short, if I am given for example an equation like: 84*x+203*y = 14

I will transform it into 2 linear equation as follow:
row0 := [203, 0, 1] row1 := [84, 1, 0] Subsequently, I will perform the following:

c := a -iquo(a[1],b[1])*b;  

Where aand b are both lists and arguments of the procedure and cbeing another list and a local variable.

But I don't know how to do the following programmatically:

row3 := row1-iquo(row1[1], row2[1])*row2;
row4 := row2-iquo(row2[1], row3[1])*row3;
row5 := row3-iquo(row3[1], row4[1])*row4;
and so on ...                  

Any hint would be appreciated.

I want to calculate the intersection between three circles.
I know that in this case i can calculate intersection of only the first and second equation, but I need this for a interactive component.

The command "intersection"[GEOMETRY] work only with 2 circles.

I did this but it doesn't work.

It doesn't give me an error,but  nothing happens.

eq1: x^2+y^2-6600*x-4400*y+15717900 = 0
eq2: x^2+y^2-6820*x-4180*y+15989800 = 0
eq3: 1.966975428*10^7+x^2+y^2-7480*x-4840*y = 0

Thanks, Enrico

I used the command line betwen two poin, and i saw the graphic.

The line passes for my two point, but i I would like it started in the first point and finished in the second.

So unlike this:

Thanks, Enrico

guys, need your help. i've been trying to find 9 pamater which are psi1,psi2,psi3,m1,m2,m3,sigma1,sigma2,sigma3. I need to minimize one function. i have datas and several contraints. i will share this with you guys. Really need your help and i'll appreciate any suggestion. Thanks



this is my objective function:

fungsikerugian := sum((1-(1-(psi1*exp(-((x+1)/m1)^(m1/sigma1))+psi2*(1-exp(-((x+1)/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x+1-m3)/sigma3)))/(psi1*exp(-(x/m1)^(m1/sigma1))+psi2*(1-exp(-(x/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x-m3)/sigma3))))/a(x))^2, x = 0 .. 111);

these are my contraints

a := psi1+psi2+psi3 = 1;
b := 0 <= exp(-((x+1)/m1)^(m1/sigma1));
c := 1 >= exp(-((x+1)/m1)^(m1/sigma1));
d := 0 <= 1-exp(-((x+1)/m2)^(-m2/sigma2));
e := 1 >= 1-exp(-((x+1)/m2)^(-m2/sigma2));
f := 0 <= exp(exp(-m3/sigma3)-exp((x+1-m3)/sigma3));
g := 1 >= exp(exp(-m3/sigma3)-exp((x+1-m3)/sigma3));
h := 0 <= exp(-(x/m1)^(m1/sigma1));
i := 1 >= exp(-(x/m1)^(m1/sigma1));
j := 0 <= 1-exp(-(x/m2)^(-m2/sigma2));
k := 1 >= 1-exp(-(x/m2)^(-m2/sigma2));
l := 0 <= exp(exp(-m3/sigma3)-exp((x-m3)/sigma3));
m := 1 >= exp(exp(-m3/sigma3)-exp((x-m3)/sigma3));
n := 0 <= 1-(psi1*exp(-((x+1)/m1)^(m1/sigma1))+psi2*(1-exp(-((x+1)/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x+1-m3)/sigma3)))/(psi1*exp(-(x/m1)^(m1/sigma1))+psi2*(1-exp(-(x/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x-m3)/sigma3)));

o := 1 >= 1-(psi1*exp(-((x+1)/m1)^(m1/sigma1))+psi2*(1-exp(-((x+1)/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x+1-m3)/sigma3)))/(psi1*exp(-(x/m1)^(m1/sigma1))+psi2*(1-exp(-(x/m2)^(-m2/sigma2)))+psi3*exp(exp(-m3/sigma3)-exp((x-m3)/sigma3)));
i use this to solve that but seems to not going anywhere
NLPSolve(fungsikerugian, {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o}, assume = nonnegative);

Hello people in mapleprimes,

I am using maple 2016's standard UI.
And, I write save command in the ending place there.

And, while I write a code, whenever I think I had better put a name of an expression on a list in another .mpl file, to refer it later, I scroll down the cursor to the ending of the worksheet, and write the name of the expression, and again I bring the cursor back to the place where I wrote an expression whose name I wrote among the arguments of save.
  But, this is a little inconvenient. I have to find the original place where I had been before I moved to the end of the worksheet. But, on the other hand, using a bookmark seems complicated. Isn't there any better way to go to the place of the save command, which is the end of the worksheet, and to go back to the original place soon.

I hope you will give any hint to me. Thanks in advance.


When I do

seq(a||i,i=1..3); Maple returns   a1, a2, a3

But  seq(a__i,i=1..3);  returns a__i, a__i, a__i

Is there a way to make the second example also return  a__1,a__2,a__3 ?

thank you,
Maple 2016.2


I am not a math major, so may be I am missing something here. But for this ode:

(diff(y(x),x))^2=4 * y(x)

There ought to be (I think) 2 solutions (other than the singular one y(x)=0), due to the square root. i.e the ode becomes

   diff(y(x),x)= +-  2* sqrt(y(x))

So for the + case, there is one solution, and for the - case, there is another solution. But Maple dsolve only gives one solution (again, ignoring the singular solution for now):

eq:=(diff(y(x),x))^2=4 * y(x);

     y(x) = _C1^2-2*_C1*x+x^2

In Mathematica, it gives both solutions

ode = (y'[x])^2 == 4 y[x];
DSolve[ode, y[x], x] // Simplify
    {  {y[x] -> (1/4)*(-2*x + C[1])^2},   {y[x] -> (1/4)*(2*x + C[1])^2}}

Both Maple and Mathematica solutions are correct ofcourse. But my question is why did not Maple give both (non-singular) solutions? and it only gave one?

Maple 2016.2




Dear All, 

I am trying to use define_external to use a C dll from inside MAPLE. The C dll exports a function that has a argument of type function pointer which has a return type of pointer. The function itself returns pointers.  

Pointers are needed as return types as the C function needs to return arrays. 

When I try to pass the C function, as maple procedure as the argument, it errs saying "Error, (in rk4_vec) number expected for float[8] parameter, got proc () option remember; table( [( 1 ) = HFloat(1.0), ( 2 ) = HFloat(-0.0) ] ) 'procname(args)' end proc"

rk4_vec is as follows: 

rk4_vec := define_external("rk4vec", 't0' :: float[8], 'm' :: integer[4], 'u0' :: ARRAY(1..2,datatype=float[8]), 'dt' :: float[8], 'f' :: PROC('t' :: float[8], 'm' :: integer[4], 'u' :: ARRAY(1..2,datatype=float[8]), 'RETURN' :: REF(float[8])), 'RETURN' ::REF(float[8]), "WRAPPER", LIB="rk4.dll");

rk4vec in C looks like this: 

double *rk4vec ( double t0, int m, double u0[], double dt, 
  double *f ( double t, int m, double u[] ) )

I am passing as :

rk4vec_test_f := proc(t, n, u)
local uprime :: REF(float[8]);
#uprime := Array(n);
uprime(1) := u(2);
uprime(2) := -u(1);
return uprime;
end proc;

I have tried the RETURN type on the define_external call as : float[8], ARRAY(1..2, datatype=float[8]) , but that didnt work either. I got the idea of using REF from times2 example on this link.

Any guidance in this matter is highly appreciated. 

Attached are the C file, the dll, maple worksheet. Tested on Windows, with 64-bit, Maple 2016 standard.


Funny, I can't seem to find a list of all available units in the help file.

Is there not a listed table of units somewhere?

**edit add**  conversion of units I mean.  ie.  meters, miles, gallons, litres, Pa, etc...

I wish to solve for k interms of x, e is a constant in the equation k=x+e*sin(k). Using the solve function, i got 

RootOf(_Z-x-e*sin(_Z)) and using the function allvalues(RootOf(_Z-x-e*sin(_Z))) still gave the same expression in _Z. Please is there a way out because I need the value of  as a substitute to another equation. Any help will be highly appreciated.

Ì am trying to convert these two files to maple but i have so far failed. I am new to maple and its still unfamiliar. How do convert these two ( APO.txt; APOh.txt) text documents to maple?

1 2 3 4 5 6 7 Last Page 1 of 1220