MaplePrimes Questions

Maple provides efficient vectorization and automatic parallelization for many common operators. For example

x -> 2*~x*~cos~(x*~x)

But in my application it is common to want to create rather long vectorized operators starting from some complicated symbolic computations. Doing conversions by hand from symbolic expressions to element-wise operations is laborious and error prone.

As a very simple example consider that it is possible to obtain (almost) the same result as above by writing the following as a vectorized operation

D(x->sin(x^2))~

But there are at least two problems with this. First of all it is not nearly as efficient as the first operator and second, perhaps not unrelated, is that the datatype returned when applying this operator to a Vector/rtable of hardware floats (e.g. datatype=float[8]) becomes something  more general.

My question is how can I convert a complicated symbolic expression into an efficient numeric element-wise vector operation?

I have tried several different approaches but so far without success. In the case above for example it seemed natural to expect that the following derivative

D(x->sin~(x^~2))

would produce a vectorized result, but this is not the case. In another attempt I was unable to see how to perform substitions into an expression, e.g. like this

unapply(subs(`*`=`*`~, cos=cos~, diff(sin(x),x)), x)

I would be glad to receive suggestions and/or references to relevant documentation. 

 

I use the example procedure when search. Clock in help 

but elapsed function can only run one time

because it return clock is not running

need to run clock start again and calculate from beginning again

how elapsed function can run more times

Hi!

Everyone,

I want to draw  phase plane of system of three fractional order equations. 

 

Note that 

Also want the  phase portrait when the values of alpha are not same....

Also

Thanks

 

 

 

I want to get solutions of this system ,can anyone help me ?solutions.mw

(1)How can i draw a graph by considering eta on x-axis and f'(eta),theta(eta)on y-axis in a single graph with respect to variatiation  in the parameter beta=0.01,0.1,1.0.. 

(2). how can i get different values of f'(eta) by varying values of eta .

restart; with(plots); beta := 0.1e-1; Bi := 10; Pr := 3.0; L0 := 1; w := 0.2e-1

Eq1 := diff(f(eta), eta, eta, eta)+f(eta)*(diff(f(eta), eta, eta))-(diff(f(eta), eta))^2+beta*H(eta)*(F(eta)-(diff(f(eta), eta))) = 0

diff(diff(diff(f(eta), eta), eta), eta)+f(eta)*(diff(diff(f(eta), eta), eta))-(diff(f(eta), eta))^2+0.1e-1*H(eta)*(F(eta)-(diff(f(eta), eta))) = 0

(1)

Eq2 := G(eta)*(diff(F(eta), eta))+F(eta)^2+beta*(F(eta)-(diff(f(eta), eta))) = 0

G(eta)*(diff(F(eta), eta))+F(eta)^2+0.1e-1*F(eta)-0.1e-1*(diff(f(eta), eta)) = 0

(2)

Eq3 := G(eta)*(diff(G(eta), eta))+beta*(f(eta)+G(eta)) = 0

G(eta)*(diff(G(eta), eta))+0.1e-1*f(eta)+0.1e-1*G(eta) = 0

(3)

Eq4 := H(eta)*F(eta)+H(eta)*(diff(G(eta), eta))+G(eta)*(diff(H(eta), eta)) = 0

H(eta)*F(eta)+H(eta)*(diff(G(eta), eta))+G(eta)*(diff(H(eta), eta)) = 0

(4)

Eq5 := (diff(theta(eta), eta, eta))/Pr+f(eta)*(diff(theta(eta), eta))+(2*H(eta)*beta*(1/3))*(thetap(eta)-theta(eta)) = 0

.3333333333*(diff(diff(theta(eta), eta), eta))+f(eta)*(diff(theta(eta), eta))+0.6666666667e-2*H(eta)*(thetap(eta)-theta(eta)) = 0

(5)

Eq6 := G(eta)*(diff(thetap(eta), eta))+L0*beta*(thetap(eta)-theta(eta)) = 0

G(eta)*(diff(thetap(eta), eta))+0.1e-1*thetap(eta)-0.1e-1*theta(eta) = 0

(6)

bcs1 := f(0) = 0, (D(f))(0) = 1, (D(theta))(0) = -Bi*(1-theta(0)), (D(f))(5) = 0, F(5) = 0, G(5) = -f(5), H(5) = w, theta(5) = 0, thetap(5) = 0;

f(0) = 0, (D(f))(0) = 1, (D(theta))(0) = -10+10*theta(0), (D(f))(5) = 0, F(5) = 0, G(5) = -f(5), H(5) = 0.2e-1, theta(5) = 0, thetap(5) = 0

(7)

p := dsolve({Eq1, Eq2, Eq3, Eq4, Eq5, Eq6, bcs1}, numeric);

proc (x_bvp) local res, data, solnproc, _ndsol, outpoint, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 14; if _EnvInFsolve = true then outpoint := evalf[_EnvDSNumericSaveDigits](x_bvp) else outpoint := evalf(x_bvp) end if; data := eval(`dsolve/numeric/data/modules`[1]); solnproc := data:-Get("soln_procedure"); if not type(outpoint, 'numeric') then if outpoint = "solnprocedure" then return eval(solnproc) elif member(outpoint, ["start", "left", "right", "errorproc", "rawdata", "order", "error"]) then return solnproc(x_bvp) elif outpoint = "sysvars" then return data:-Get("sysvars") elif procname <> unknown then return ('procname')(x_bvp) else _ndsol := pointto(data:-Get("soln_procedures")[0]); return ('_ndsol')(x_bvp) end if end if; try res := solnproc(outpoint); [eta = res[1], seq('[F(eta), G(eta), H(eta), f(eta), diff(f(eta), eta), diff(diff(f(eta), eta), eta), theta(eta), diff(theta(eta), eta), thetap(eta)]'[i] = res[i+1], i = 1 .. 9)] catch: error  end try end proc

(8)

odeplot(p, [eta, f(eta)], 0 .. 5);

 

odeplot(p, [eta, diff(f(eta), eta)], 0 .. 5);

 

NULL

odeplot(p, [eta, thetap(eta)], 0 .. 5);

 

odeplot(p, [[eta, F(eta)], [eta, thetap(eta)]], 0 .. 5);

 

``


 

Download from_net_(1).mw

 

I am trying to plot f=[r^2 *cos(theta)+r*sin(theta)],as a DensityPlot[] in polar coordinates.

here r is a function of theta, r=r1(θ)..r2(θ) , for this reason, I have a problem to plot f in density plot

f=[r^2 *cos(theta)+r*sin(theta)];

r1(theta)= 0.3+0.1*cos(theta);
r2(theta)= 0.5+0.1*cos(theta);
display(changecoords(densityplot(f, r =r1(theta)..r2(theta), theta = 0 .. 2*Pi, style = patchnogrid, colorstyle = HUE), polar), axes = box, orientation = [270, 0], labels = [x, y, ``]);

(Error, (in plots/densityplot) bad range arguments r = .3+.1*cos(theta) .. .5+.1*cos(theta), theta = 0 .. 2*Pi )

The ODE diff(y(x),x) = sec(x)^2*sec(y(x))^3  can be solved as separable. So the answer should be 

simple_answer:=sin(y(x))*(cos(y(x))^2+2)=C_1+3*tan(x);

as can be seen by direct integration of each side of the differential equation. I am trying to make Maple give the same answer, but not having any luck. 

restart;
ode:=diff(y(x),x) = sec(x)^2*sec(y(x))^3;
sol:=dsolve(ode, y(x),implicit);

I tried simplify(sol,trig) and tried simplify(sol,size).  Both Maple answer, and the simple answer solve the ODE.

Is there a way to make Maple dsolve give the simpler answer, or simplify/convert the answer it gives to the simpler one? I am newbie in Maple.

I'm looking over a file someone else made (I jusut have the image of it not the .mw), and there's a line that looks like this:

H1|
    | t=0.45.

H1 is an equation is set from an interpolation expansion line, and I believe this input solves the equation when the variable t is equal to 0.45. But how do I enter this into Maple? Thanks.

I am using Maple 2015 and when assigning a name to a function or expression and hit enter, it appears like in the following picture.

However, I want to make it appear like in the following picture:

How can I make that ?

Thank you !

Can someone help me with this:

reverse_eng.mw

happy new year!

I was trying to solve a system of ODE using Maple, but to my surprise, Maple recognizes diff((phi(t), t)) as a variable which is different than t. 

My code is as following:

dsys := {2*m1*(a+l*sin(phi(t)))^2*(diff(diff(theta(t), t), t))+4*m1*(a+l*sin(phi(t)))*l*cos(phi(t))*(diff(theta(t), t))*(diff(phi(t), t)) = M, 2*m1*l^2*(diff(diff(phi(t), t), t))+4*m2*l^2*sin(2*phi(t))*(diff(phi(t), t))*(diff(phi(t), t))+4*m2*l^2*sin(phi(t))^2*(diff(diff(phi(t), t), t))-2*m1*(a+l*sin(phi(t)))*l*cos(phi(t))*(diff(theta(t), t))*(diff(theta(t), t))-2*m2*l^2*(sin(2*phi(t)))(diff(phi(t), t))*(diff(phi(t), t)) = -(2*(m1+m2))*g*l*sin(phi(t))-2*k*l^2*sin(2*phi(t)), phi(0) = 0, theta(0) = 0, (D(phi))(0) = 0, (D(theta))(0) = 0}

subs({M = 10, a = .5, g = 9.81, k = .1, l = .5, m1 = 10, m2 = 1}, dsys);

dsn1 := dsolve(dsys, numeric)

The error I got was Error, (in dsolve/numeric/process_input) input system must be an ODE system, got independent variables {t, diff(phi(t), t)}

I don't get why this is happening. Could you show me what's going on?

I solve a set of equations in this way and I have three set of answers ,but I don`t know wich one is true.

and I have another question ,how can I assume v[0] like a constant?

 

alpha[2]:= 2.727272728*10^5: alpha[4]:= 3738.685337: alpha[6]:= -30.18675539: alpha[7] := -4.116375735*10^6: alpha[8] := 1.859504132*10^10: alpha[9]:= 2.489142857*10^(-12):

l10:=(alpha[7]*v[0]^2+1)*gamma[i*n]^4+(-alpha[4]*beta[n]^2+alpha[8]*v[0]^2-alpha[9])*gamma[i*n]^2+(2*I)*gamma[i*n]*alpha[2]*beta[n]*v[0]+(2*I)*gamma[i*n]^3*alpha[6]*beta[n]*v[0]-beta[n]^2 = 0:

l11 := subs(i = 1, l10);

l12 := subs(i = 2, l10);

l13 := subs(i = 3, l10);

l14 := subs(i = 4, l10);

l15 := (exp(I*(gamma[n]+gamma[2*n]))+exp(I*(gamma[3*n]+gamma[4*n])))*(gamma[3*n]^2-gamma[4*n]^2)*(gamma[n]^2-gamma[2*n]^2)+(exp(I*(gamma[n]+gamma[4*n]))+exp(I*(gamma[2*n]+gamma[3*n])))*(gamma[2*n]^2-gamma[3*n]^2)*(gamma[n]^2-gamma[4*n]^2)+(exp(I*(gamma[2*n]+gamma[4*n]))+exp(I*(gamma[n]+gamma[3*n])))*(gamma[2*n]^2-gamma[4*n]^2)*(-gamma[n]^2+gamma[3*n]^2) = 0;

l1 := combine(expand(evalc(l15)), trig):

l2 := combine(expand(evalc(Re(l15))), trig):

l3 := combine(expand(evalc(Im(l15))), trig): v[0] := 1; 1

fsolve({l1, l11, l12, l13, l14}, {beta[n], gamma[n], gamma[2*n], gamma[3*n], gamma[4*n]}):

fsolve({l11, l12, l13, l14, l2}):

solve({l11, l12, l13, l14, l3}):

thanks

Reyhaneh

Friends in Maple

I have a Vehicle Routing Problem I wish to cast as a integer model. VRP is a kind of TSP and knapsack problem hybrid  I would be grateful if someone can finish it. answers included. This isn't homework BTW.

VRP_IP.mw

with(plots):with(plottools):
p1:=plot( x^3,x=-1..1,thickness=20,color=red):
p2:=plot(-x^3,x=-1..1,thickness=20,color=blue):
p3:=display(rectangle([0.5, 1],[0.75,-1],color=green)):
p4:=display(rectangle([-1,-0.1],[1,0.1],color=yellow)):

display(p1,p2,p3,p4); # order = 4312

 

#  display(p3,p4,p1,p2); # order = 4312 (the same)

It seems that the rectangles are plotted first, in reversed order, and then the curves, in direct order.
Has someone an explanation?

Cmaple always print the source code first and then print output , how to print output only without printing heading logo and source code by default when use cmaple

First 1025 1026 1027 1028 1029 1030 1031 Last Page 1027 of 2428