Maple 17 Questions and Posts

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

Hello

I'm doing some calculation reports in maple. These reports are to be submitted to various classification societies - which all have different requirements to the calculations.

I would like to make a report, where the class specific calculations would be append based on a selection of class in the main calculation.

How do I do this?

 

If I was using latex, matlab, APDL or something like that, I would do and *IF Class=class1, *INPUT class.calc, *ENDIF, but how to do this in maple?

Hi

I use Maple perhaps only one time per year and thus i'm a beginner with the product (even if i use it since 1996). I'm trying to make the following script work in Maple 17:

http://www.maplesoft.com/applications/view.aspx?SID=4268&ref=Feed&L=F

but i fail.... Some help will be appreciate

restart:

Eq1:=1/r*diff(r*diff(w(r),r),r)-(cos(z1))^2*(w(r)+1)-DP;

dsolve({Eq1});

bcs:=D(w)(0)=0,w(r2)=A1;

dsolve({Eq1,bcs},w(r)):

where z1, Dp, r2, A1 are constants.

 

Hi MaplePrime-ers!

I've been using the Maple(17) toolbox in Matlab(2012b) to quickly enumerate systems of equations by: (i) solving them symbolically, (ii) using unapply to make them functions, (iii) then supplying the points (driver equations) to get the system solution.  Speed is a must, because there may be 3 million+ systems to solve.  Symbolics is also very important because I am evaluating topology, so the structure of the equations may change, and therefore a functional approach will not work.

I have had success (seen in the first code snippet).  I would like similiar behaviour in the second code snippet, but sometimes I get 'solutions may be lost' as an error message,  or 'Error, (in unapply) variables must be unique and of type name'

The system of equations include:  Linear equations, 5th order polynomials, absolute functions, and pieceiwse functions.

Here is code with a topology that solves:

#Interconnection Equations
eq2[1] := FD_T + EM2_T = 0;
eq2[2] := ICE_T + GEN_T = 0;
eq2[3] := EM2_A + GEN_A + BAT_A = 0;
eq2[4] := -FD_W + EM2_W = 0;
eq2[5] := -ICE_W + GEN_W = 0;
eq2[6] := -EM2_V + GEN_V = 0;
eq2[7] := -EM2_V + BAT_V = 0;

#ICE
eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;

#BAT
eq_c[2] := BAT = 271;

#EM2
EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;
eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);
eq_c[4] := EM2_A = EM2_P/EM2_V;

#GEN
GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;
eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);
eq_c[6] := GEN_A = GEN_P/GEN_V;

#ASSUMPTIONS
assume(BAT_V::nonnegative);
assume(FD_W::nonnegative);

#FINAL EQUATIONS

sys_eqs2 := convert(eq2,set) union {eq_c[1],eq_c[2],eq_c[3],eq_c[4],eq_c[5],eq_c[6]};

#Selecting which variables to solve for:

drivers2:= { ICE_T,ICE_W,FD_T,FD_W};
symvarnames2:=select(type,indets(convert(sys_eqs2,list)),name);
notdrivers2:=symvarnames2 minus drivers2;


#Symbolic solve

sol2:=solve(sys_eqs2,notdrivers2) assuming real:
symb_sol2:=unapply(sol2,convert(drivers2,list)):


#Enumerate (there will generally be about 40, not 6)

count := 0;
for i1 from 1 to 40 do
     for i2 from 1 to 40 do
          for i3 from 1 to 40 do
               for i4 from 1 to 40 do
                    count := count + 1;
                    solsol2(count) := symb_sol2(i1,i2,i3,i4);
               od;
          od;
     od;
od;
count;



This works great!  I would like simliar output in my second code snippet, but this time with more inputs to symb_sol.  However, if I try and change the interconnection equations a little, and add a piecewise function, and another driver... (differences in bold)

#Interconnection Equations
eq1[1] := FD_T+EM2_T = 0;
eq1[2] := ICE_T+GBb_T = 0;
eq1[3] := GEN_T+GBa_T = 0;
eq1[4] := EM2_A+GEN_A+BAT_A = 0;
eq1[5] := -FD_W+EM2_W = 0;
eq1[6] := -GEN_W+GBa_W = 0;
eq1[7] := -ICE_W+GBb_W = 0;
eq1[8] := -EM2_V+GEN_V = 0;
eq1[9] := -EM2_V+BAT_V = 0;

#ICE
eq_c[1] := ICE_mdot_g=((671.5) + (-21.94)*ICE_T + (0.1942)*ICE_W + (0.5113)*ICE_T^2 + (-0.01271)*ICE_T*ICE_W + ( -0.0008761)*ICE_W^2 + (-0.006071)*ICE_T^3 + (9.867e-07)*ICE_T^2*ICE_W + (5.616e-05)*ICE_T*ICE_W^2 + (1.588e-06)*ICE_W^3 + (3.61e-05)*ICE_T^4 + (8.98e-07)*ICE_T^3*ICE_W + (-2.814e-07)*ICE_T^2*ICE_W^2 + (-8.121e-08)*ICE_T*ICE_W^3 + ( -8.494e-08 )*ICE_T^5 + (-2.444e-09)*ICE_T^4*ICE_W + (-9.311e-10)*ICE_T^3*ICE_W^2 + ( 5.835e-10)*ICE_T^2*ICE_W^3 ) *1/3600/1000 * ICE_T * ICE_W;

#BAT
eq_c[2] := BAT = 271;

#EM2
EM2_ReqPow_eq := (-148.3) + (4.267)*abs(EM2_W) + (12.77)*abs(EM2_T) + (-0.0364)*abs(EM2_W)^2 + ( 1.16)*abs(EM2_W)*abs(EM2_T) + (-0.258)*abs(EM2_T)^2 + ( 0.0001181)*abs(EM2_W)^3 + (-0.0005994)*abs(EM2_W)^2*abs(EM2_T) + ( 0.0001171)*abs(EM2_W)*abs(EM2_T)^2 + (0.001739 )*abs(EM2_T)^3 + (-1.245e-07 )*abs(EM2_W)^4 + ( 1.2e-06)*abs(EM2_W)^3*abs(EM2_T) + ( -1.584e-06)*abs(EM2_W)^2*abs(EM2_T)^2 + ( 4.383e-07)*abs(EM2_W)*abs(EM2_T)^3 + (-2.947e-06)*abs(EM2_T)^4;
eq_c[3] := EM2_P = piecewise( EM2_T = 0, 0, EM2_W = 0, 0, EM2_W*EM2_T < 0,-1 * EM2_ReqPow_eq, EM2_ReqPow_eq);
eq_c[4] := EM2_A = EM2_P/EM2_V;

#GEN
GEN_ReqPow_eq:= (-5.28e-12) + ( 3.849e-14)*abs(GEN_W) + (-71.9)*abs(GEN_T) + (-1.168e-16)*abs(GEN_W)^2 +(1.296)*abs(GEN_W)*abs(GEN_T) + (2.489)*abs(GEN_T)^2 + (1.451e-19)*abs(GEN_W)^3 + (0.0001326)*abs(GEN_W)^2*abs(GEN_T) + (-0.008141)*abs(GEN_W)*abs(GEN_T)^2 + (-0.004539)*abs(GEN_T)^3 +(-6.325e-23)*abs(GEN_W)^4 + (-2.091e-07)*abs(GEN_W)^3*abs(GEN_T) + ( 3.455e-06)*abs(GEN_W)^2*abs(GEN_T)^2 + ( 2.499e-05)*abs(GEN_W)*abs(GEN_T)^3 + (-5.321e-05)*abs(GEN_T)^4;
eq_c[5] := GEN_P = piecewise( GEN_T = 0, 0, GEN_W = 0, 0, GEN_W*GEN_T < 0,-1 * GEN_ReqPow_eq, GEN_ReqPow_eq);
eq_c[6] := GEN_A = GEN_P/GEN_V;

#GB
FiveSpeedGearbox_R := proc(ig)
local i ,eq;
i[1]:=3.32;
i[2]:=2;
i[3]:=1.36;
i[4]:=1.01;
i[5]:=0.82;
eq:= piecewise(ig=1,i[1],ig=2, i[2],ig=3,i[3],ig=4,i[4],ig=5,i[5],1);
return eq(ig);
end proc;


eq_c[7] := GBb_T = -1/GB_R * GBa_T;
eq_c[8] := GBb_W = GB_R * GBa_W;
eq_c[9] := GB_R = FiveSpeedGearbox_R(ig);

 

#System Equations
sys_eqs := convert(eq1,set) union convert(eq_c,set);

 

 #Solve for variables
symvarnames:=select(type,indets(convert(sys_eqs,list)),name);
drivers:= {ig, ICE_T,ICE_W,FD_T,FD_W};
not_drivers := symvarnames minus drivers;

#Assumptinons

assume(BAT_V::nonnegative);
assume(FD_W::nonnegative);

sol:=(solve(sys_eqs,not_drivers) assuming real);

symb_sol:=unapply(sol,convert(drivers,list)): ---> Error, (in unapply) variables must be unique and of type name

Subsequent parts don't work...

count := 0;
for i1 from 1 to 40 do
     for i2 from 1 to 40 do
          for i3 from 1 to 40 do
               for i4 from 1 to 40 do
                    for i5 from 1 to 40 do
                         count := count + 1;
                         solsol2(count) := symb_sol2(i1,i2,i3,i4,5);
                    od;
               od; 
          od;
     od;
od;
count;

While running the last line sol:, 1 of 2 things will happen, depending on the solver. Maple17 will take a long time (30+ minutes) to solve, then report nothing, or sol will solve, but will report "some solutions have been lost".

Afterwards, evaluating symb_sol(0,0,0,0,0) will return a viable solution (real values for each of the variables).  Whereas evaluating symb_sol(0,X,0,0,0), where X <> 0, will return and empty list [].

Does anyone know how to (i) speed up the symbolic solve time?  (ii) Return ALL of the solutions?

 

Thanks in advance for reading this.  I've really no idea why this isn't working.  I've also attached two worksheets with the code: noGB.mw   withGB.mw

 Adam

Please I need programme to solve this nonlinear couple ode with values of k_1 from 1.5 to 2.5 and eta from 0.0 to 2.0 real_work_3.mw Thanks for your help.

Hi all,

We're programming with Maple objects, and would like to have a Maple object that is appliable (i.e. acts as an operator).  We're really after partial differential operator (PDO) objects, but I give a simpler example below.  The problem is this: the ?ModuleApply proc needs to be non-static (so that each object has its own ?ModuleApply), and it may want to refer to the object instance, via ?thismodule.  Code like this works great when it is typed at the command line or read in from .mpl file, but it barfs as soon as saved to a .mla.  Why is that?  And is there an easy fix / workaround?

 

Here is an example worksheet, that creates a basic "compute mod p" object

BugThismoduleMLA.mw

The issue seems to be that, for code typed at command line, ?thismodule is resolved when I would expect, i.e. in the instance object; but saving to the .mla seems to cause ?thismodule to be resolved then-and-there, which means it resolves to the prototype object.  For this particular case there is an easy workaround, but we really want to refer to ?thismodule if possible.  Is there a way to do that?

BTW I'm running Maple 17.02 (sorry don't have access to 18 yet).

Thanks,
Ian and Tracy

I try to solve these two nonlinear odes, but no desire outcome. Please helpreal_work1.mwreal_work1.mw  or real_work1.mw

restart:

Eq1:=diff(psi(y),y$4)-diff(psi(y),y$2)=0;

dsolve({Eq1});

bcs:=psi(h1)=F,D(psi)(h1)=-1,psi(h2)=-F,D(psi)(h2)=-1;

dsolve({Eq1,bcs});

Error, (in dsolve) found differentiated functions with same name but depending on different arguments in the given DE system: [{psi(h1), psi(h2), psi(y)}, {psi(h2), psi(y)}]

Any suggestion?

Cheers!

 

how maple calculate exp(x) with e.g. 100000 decimal numbers

a divsion of the series x^k/k! with e.g. 1/25000!/25001 lasts longer than the exp(1.xx) calculation

 

is there a faster way to calculate exp(x) than with the x^k/k! series

 

thanks

 

 

 

 

 

 

 

 

Hi all,

 

Say I have some list like this,

tmp:=[[0, 0, 1], [0, 1, 0], [0, 1, 1], [0, 1, 2], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2, 0]];

 

And I have worked out some probabilities for each of them, a,b,c,d, ect.

I want to print them like this

Pr( 001 ) = 1

Pr( 010 ) = 1-phi[2]+phi[2]*(1-p[3])*(1-phi[3])

Pr( 011 ) = phi[2]*p[3]*(1-phi[3])

and so on.

I there a way to do that?

The probabilities can be extracted from a Vector. I have no problem to print them.

I dont know how to convert the 0,1,2 into the desired format as shown above.

 

This is the best I can do.

 

Also, is it possible to convert all the subscripte [] to _ when printing the output?

and get ride of all * as well.

Thanks,

 

casperyc

 

ali := (1/12)*(12*c[4]*ln(x+1)*x^4+48*c[4]*ln(x+1)*x^3+72*c[4]*ln(x+1)*x^2+48*c[4]*ln(x+1)*x+12*c[1]*x+30*c[2]*x^2+12*c[2]*x+36*c[3]*x^3+36*c[3]*x^2+12*c[3]*x+12*c[5]*x^5+48*c[5]*x^4+72*c[5]*x^3+48*c[5]*x^2+3*c[0]*x^4+12*c[0]*x^3+18*c[0]*x^2+12*c[0]*x+4*c[1]*x^4+16*c[1]*x^3+24*c[1]*x^2+6*c[2]*x^4+24*c[2]*x^3+12*c[3]*x^4+12*c[4]*ln(x+1)+12*c[5]*x)/(x+1)^4+.1

but simplify(ali-simplify(ali)) is not equal to 0!

 

restart:

Eq1:=diff(f(x),x)=1;

f:=1:

plot(1,x=0..10);

cs:=(f)(0)=0;

p:=dsolve({Eq1,cs},numeric);

odeplot(p, [x,diff(f(x),x)], 0..10);

why I cannot get a plot diff(f(x),x) like this?

 

whats going on here?

 

 

 

Hello everyone!

I have a question that I can't seem to find a straight answer to. I need to fit a circle to a collection of points that a circular in nature. I was trying to use the following elliptical least squares fit, but I can't determine what I should be minimizing.

Here's the page:

http://www.maplesoft.com/applications/view.aspx?SID=1395&view=html

 

For an ellipse, I used the general conic:

F:=a*x^2+b*x*y+c*y^2+d*x+e*y+f

I minimize using:

V:=Minimize(E,{4*a*c-b^2=1});

 

What would I use for a circle? Or is there a better way for a circle?

Hello everyone!

I used Maple 17 to fit an ellipse to a set of points using the following guide:

http://www.maplesoft.com/applications/view.aspx?SID=1395&view=html

My rotated ellipse was calculated to be:

SOL;

0.3939708949 x^2 - 0.005975799853 + 0.6345432059 y^2

But everytime I try to graph it in Maple 17, it only shows the axes and nothing else. Any help would be extremely appreciated.

I am recently using maple to plot poincare surface of section, and when I do the harmonic hamiltonian I need to fix different values of p1,q1,p2 and q2 in a tyler series expansion. So i'm expected to use the numbers from a txt file to caculate the tyler series expansion. But after i realize the "readdata" code, i don't know what to do next...

Can anybody tell me how to operate those data please?

Thank you very much!

By the way, I'm not a native English speaker, if my question is unclear please ask me for confirming...

First 36 37 38 39 40 41 42 Last Page 38 of 61