Items tagged with odeplot

Feed


I want to use a variant of the arctangent function in odeplot but I run into various problems. Here is the variant called at
> at := proc (x::realcons, yy)

if 0 < x then arctan(yy/x) elif x < 0 then Pi+arctan(yy/x) elif x = 0 then (1/2)*Pi end if end proc;


It would be nice to know if this is really what I want so I try to plot at  values for which I know the answer
> plot(at(-cos(-t), sin(t)), t = 0 .. 3.14);


Error, invalid input: at expects its 1st argument, x, to be of type realcons, but received -cos(t)


I have seen this problem before so I use single quotes with success:
plot('at(-cos(-t), sin(t))', t = 0 .. 3.14);

I get the desired plot;

Now I want to use this procedure in a plot of a numerical solution to an ODE.
The ODE is quite complicated but returns a procedure ,nans, that i use to visualize solutions via commands such as


> odeplot(nans, [[y, f(y)]], y = 0 .. 6);
No problem with any of that,

The problem arise when I define theta below
> theta := at(f(y)-(1/2)*Pi, diff(f(y), y));
and try to use it in odeplot, for example,
> odeplot(nans, [[y, theta]], y = 0 .. 6);
or
> theta1:=y->at(f(y)-Pi/(2),diff(f(y),y));


> odeplot(nans, [[y, theta1(y) ]], y = 0 .. 6);


Maple's complains about theta and theta1 and all of my attempts to fix the problem:


Error, (in plots/odeplot) curve 1 is not fully specified in terms of the ODE solution, found additional unknowns {Theta1}
or
Error, (in Theta1) invalid input: at expects its 1st argument, xx, to be of type realcons, but received f1(y)-(1/2)*Pi  or


Error, (in Theta1) invalid input: diff received HFloat(0.001), which is not valid for its 2nd argument


I supect there is an easy fix. If I give up on at and just use arctan I get an ugly jump in my plot but otherwise everything works.


I am looking for a high accuracy plot, however, and the jump obscures important features.

Please help!

Hello every body i need help with my program. how can i plot r&s versus each other?



 

restart

with(plots):

with(PDEtools, casesplit, declare)

[casesplit, declare]

(1)

with(DEtools, gensys)

[gensys]

(2)

declare((Omega, H)(z));

Omega(z)*`will now be displayed as`*Omega

 

H(z)*`will now be displayed as`*H

(3)

`&epsilon;` := -1

-1

(4)

h := 70

70

(5)

r := 0.3e-3

0.3e-3

(6)

n := 42

42

(7)

``

``

ode1 := -(diff(Omega(z), z))+Omega(z)*((3*(1-2*`&epsilon;`*h*sqrt(r)/H(z)-Omega(z)+2*Omega(z)^(3/2)/(3*n)))*(1+h*`&epsilon;`*sqrt(r)/sqrt(h^2*r+H(z)^2*(1-2*`&epsilon;`*h*sqrt(r)/H(z))))-2*sqrt(Omega(z))/n)/(1+z) = 0:

ode2 := -(diff(H(z), z))-(3*H(z)*(1/2))*(1-2*`&epsilon;`*h*sqrt(r)/H(z)-Omega(z)+2*Omega(z)^(3/2)/(3*n))*(1+h*`&epsilon;`*sqrt(r)/sqrt(h^2*r+H(z)^2*(1-2*`&epsilon;`*h*sqrt(r)/H(z))))/(1+z) = 0:

q := -1+(3/2*(1-2*`&epsilon;`*h*sqrt(r)/H(z)-Omega(z)+2*Omega(z)^(3/2)/(3*n)))*(1+h*`&epsilon;`*sqrt(r)/sqrt(h^2*r+H(z)^2*(1-2*`&epsilon;`*h*sqrt(r)/H(z)))):

``

sys := {ode1, ode2}


ics := {H(0) = h, Omega(0) = .77}:
sol := dsolve(`union`(sys, ics), numeric, output = listprocedure, stiff = true):``

 

 

 

 

 

r2 := q+2*q^2+(1+z)*(diff(q, z)):

``

``

s := (r2-1)/(3*(q-1/2)):

 

 

 

 



 

Download rs.mw
 

 

 



 

Download rs.mw

 

i want to draw plot Y[1] . but i cant. thank for you

i want to take this equation

restart;
with(LinearAlgebra); Digits := 70; with(plots);

K := Matrix(5, 5, [[18278000.0000, 0., 0., 0., 0.], [0., 8478500.0000, 0., 0., 0.], [0., 0., 3874800.0000, 0., 0.], [0., 0., 0., 494710000.0000, 0.], [0., 0., 0., 0., 7707500.0000]]); M := Matrix(5, 5, [[4119700.0000, 0., 0., 0., 0.], [0., 175900.0000, 0., 0., 0.], [0., 0., 52796., 0., 0.], [0., 0., 0., 2002900.0000, 0.], [0., 0., 0., 0., 21711.]]); L := Vector[column](5, [400689.48, 36882.21, 24223.175, 7197.4865, 5007.6466]); V := Vector[column](5, [4.4368, 48.201, 73.39160, 246.999, 355.012]);
NS := ImportMatrix("D:/tabas.txt", datatype = float[8]);
t_NS := NS[() .. (), 1];
acc_NS := NS[() .. (), 2];
plot(NS, t = 0 .. 4.5, size = [800, 400]);
acc := unapply(CurveFitting:-Spline(t_NS, acc_NS/(9.81), t, degree = 1), t);
eq := seq(diff(x[i](t), t$2)+(2*0.5e-1)*sqrt(V[i])*(diff(x[i](t), t))+V[i]*x[i](t) = L[i]/M[i, i], i = 1 .. 5, 1);
ic := [seq({x[i](0) = 0, (D(x[i]))(0) = 0}, i = 1 .. 6, 1)];
res := evalf(seq(dsolve({eq[i], ic[i][]}, numeric, method = rkf45), i = 1 .. 5, 1));
Z := `<,>`(res[1], res[2], res[3], res[4], res[5]);
Y := Phi . Z;
#odeplot(rhs(Y[1]), t = 0 .. 4)

import file text

tabas.txt

how can i draw the plot of solution of Runge–Kutta methods

@rkt4.mw

hello,

i went to plot a complex numerical solution , i used odeplot but did not work

please help

Thank you very much 


 

restart; with(plots)

NULL

L := 1;

1

(1)

R := 0.57e-1;

0.57e-1

(2)

V := evalf(Pi*R^2*L);

0.1020703453e-1

(3)

pcy := m/V;

97.97164858*m

(4)

Am := 0.6e-1;

0.6e-1

(5)

``

k := evalf(2*Pi/(1.56*T*T));

4.027682890/T^2

(6)

h := 10; -1; zz := h+Am*cos(omega*t)

10+0.6e-1*cos(omega*t)

(7)

g := 9.81;

9.81

(8)

pe := 1025;

1025

(9)

T := 3.57;

3.57

(10)

omega := 2*Pi/T;

1.759995884

(11)

m := (1/2)*pe*evalf(Pi*R^2*L);

5.231105195

(12)

``

``

eq := m*(diff(z(t), `$`(t, 2)))-pe*g*L*R^2-pe*L*R^2*(diff(z(t), `$`(t, 2)))+I*R^3*pe*L*cosh(k*(zz+h))*cos(omega*t)*exp(-I*omega*t)/cosh(k*h)

1.900880195*(diff(diff(z(t), t), t))-32.66950725+(0.1607410765e-1*I)*cosh(6.320462130+0.1896138639e-1*cos(1.759995884*t))*cos(1.759995884*t)*exp(-(1.759995884*I)*t)

(13)

csi := z(0) = 0, (D(z))(0) = 0;

z(0) = 0, (D(z))(0) = 0

(14)

sol := dsolve({csi, eq}, numeric, maxfun = 0):

NULL

sol2 := simplify(evalf(expand(sol))):

fg1 := evalc(Re(sol)):

odeplot(rhs(sol), [t, z(t)], t = 0 .. 3, labels = ["t", "z(t)"], color = blue, thickness = 1, legend = ["z(t) "], axes = boxed)

Error, invalid input: rhs received sol, which is not valid for its 1st argument, expr

 

complexplot(sol, [t, z(t)], t = 0 .. 3, labels = ["t", "z(t)"], color = blue, thickness = 1, legend = ["z(t) "], axes = boxed)

Error, (in plots:-complexplot) invalid input: `plots/complexplot` expects its 2nd argument, r, to be of type {range, name = range}, but received [t, z(t)]

 

NULL

NULL

``


 

Download mapleprime.mwmapleprime.mw

Hi! I have the system of differential equations

restart; with(plots); with(DEtools);

a := 1;

deq1 := u(s)*(diff(varphi(s), s, s))+2*(diff(u(s), s))*(diff(varphi(s), s))+sin(varphi(s)) = 0;

deq2 := diff(u(s), s, s)-u(s)*(diff(varphi(s), s))^2-cos(varphi(s))+a*(u(s)-1) = 0;

sol := dsolve({deq1, deq2, u(0) = 1, varphi(0) = (1/4)*Pi, (D(u))(0) = 0, (D(varphi))(0) = 0}, {u(s), varphi(s)}, numeric)

 

which is perfectly solved, but I need to convert it to Cartesian coordinates and draw a plot, so what I tried is

x := u(s)*sin(varphi(s));

y := -u(s)*cos(varphi(s));

plot([x, y, s = 0 .. 20])

 

But I'm getting an error "Warning, expecting only range variable s in expressions [u(s)*sin(varphi(s)), -u(s)*cos(varphi(s))] to be plotted but found names [u, varphi]"

I don't know why is this happens if I have a solution. For example, I can get solution for 2 seconds:

sol(2)

[s = 2., u(s) = 2.33095721668252, diff(u(s), s) = 1.02513293353371, varphi(s) = .213677391510693, diff(varphi(s), s) = -.242430995691885]

 

Download 2222222222222222222.mw

 

> restart; 
> A[0] := 10^(-3); a := 10^5;
> sys := diff(R(theta), theta) = A[0]*exp(2*mu(theta))*sin(theta)/(2*a), R(theta) = 2*exp(-2*mu(theta))*(1-(diff(mu(theta), `$`(theta, 2)))-cot(theta)*(diff(mu(theta), theta)));
> cond := R(0) = 10^(-5), mu(0) = 118.92, (D(mu))(0) = 0;
> F := dsolve({cond, sys}, [R(theta), mu(theta)], numeric);
> with(plots);
> odeplot(F, [theta, R(theta)], 0 .. 3.14, color = black, thickness = 3, linestyle = 4)
> odeplot(F, [theta, mu(theta)], 0 .. 3.14, color = blue, thickness = 3, linestyle = 1)

After last two lines maple writes:

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

And gives me empty plots. I can't figure out where an error can be. Some things I noticed:

Maple doesn't calculate the system before and after zero. If I change the range from 0..3.14 to -10..10 or to 0.00001..0.00001, it gives me 2 errors for 1 plot.

Also if I change the condition mu(0) = 118.92 to mu(0) = 1 or mu(0) = 50 or mu(0) = 80, it works. After ~80 it gives an error. I can't imagine where could appear a division by 0 or some other mistake.

Dear All, 

I work on the period doubling phenomenon by integrating the dynamical system at some particular parameter values. My main commands are as follows

restart:
with(DEtools): with(plots): with(plottools):
a:=-1: b:=-3: c:=3: d:=1: omega:=1: v1:=1: f:=-4: epsilon:=0.01: 
sys:=diff(u1(t),t)=v1*u1(t)-(omega+u2(t)^2)*u2(t)+u1(t)*(a*(u1(t)^2+u2(t)^2)+b*z(t)^2),
     diff(u2(t),t)=(omega+u1(t)^2)*u1(t)+v1*u2(t)+u2(t)*(a*(u1(t)^2+u2(t)^2)+b*z(t)^2),
     diff(z(t),t)=z(t)*(-v1+c*(u1(t)^2+u2(t)^2)+z(t)^2)+epsilon*z(t)*(v2+f*z(t)^4):

solC:=dsolve({eval(sys, v2=2.0500014987),
              u1(0)=0.6,u2(0)=0.6,z(0)=0.1},
              type=numeric, method=rkf45, maxfun=10^7,
              range=350..750):
p1:=odeplot(solC, [sqrt(u1(t)^2+u2(t)^2),z(t)],
               refine=2,
               color=burgundy,
               thickness=1);
 

The resulting curves are quite blurring and furry. I have tried to increase the "refine" or the "numpoints" values, but with minimal improvement. I would like to know if there a way to obtain clean and sharp integral curves?  

I would be very grateful if someone could help me! 

Thank you in advance.

With kind wishes,

Wang Zhe

Hi,

I have a Maple code which produces an output plot for a first order differential equation,

nde := evalf(subs(npar, de));
nds := dsolve({nde, sigma(0) = -1e-8}, sigma(t), type = numeric);
acc_nds := (sig0, ae, re) -> dsolve({nde, sigma(0) = sig0}, sigma(t), type = numeric,
method = lsode[backfull], abserr = ae, relerr = re, maxfun = 0, ctrl=Ctrl);

odeplot(acc_nds(-0e-7, 1e-13, 1e-13), [t, sigma(t)], t = 0..2);

This produces the outputplot that I need for sigma(t). I need to produce a outut for d(sigmat)/dt, and how can this be done? what is the command I should use?

Additionally, how can i get the data set out of the polt in to a excel file or a text file?

I am quite new to maple, so i expect your kind support

Thanks

I am having touble plotting the equation, diff(y(t), t$3)+3*(diff(y(t), t$2))+4*(diff(y(t), t))+12*y(t) = 0. With the intional conditons y'(0)=y''(0)=0 and y(0)=3.

Currently I am getting this error, "Error, (in dsolve/numeric/type_check) insufficient initial/boundary value information for procedure defined problem."

My current eqution is DEplot(ode, y(t), t = -1 .. 5, y(t) = -5 .. 5, [ivp]), with ivp := [((D@D)(y(t)))(0) = 0, (D(y(t)))(0) = 0, (y(t))(0) = 3].

> restart; for j to nops(n) do sys := diff(f(eta), eta, eta, eta)+f(eta)*(diff(f(eta), eta, eta))+1-(diff(f(eta), eta))^2 = 0, (diff(diff(theta(eta), eta), eta))/pr+f(eta)*(diff(theta(eta), eta))-(diff(f(eta), eta))*theta(eta) = 0; bcs := f(0) = 0, (D(f))(0) = l+b*((D@@2)(f))(0), (D(f))(-.5) = 1, theta(0) = 1+s*(D(theta))(-.5), theta(2) = 0; n := [1, 2, 3, 4, 5, 6]; pr := .71; p := 0; q := 0; b := 0; l := 0; s := 0; L := [red, blue, orange]; R1 := 2*n[j]/(1+n[j]); R2 := 2*p/(1+n); p := proc (f1, th1, { output::name := 'number' }) local res1, fvals, thvals, res2; option remember; res1 := dsolve({sys, f(1) = 0, theta(0) = 1+th1, (D(f))(0) = f1, (D(theta))(0) = th1, ((D@@2)(f))(0) = f1-1}, numeric, :-output = listprocedure); fvals := (subs(res1, [seq(diff(f(eta), [`$`(eta, i)]), i = 0 .. 2)]))(0); thvals := (subs(res1, [seq(diff(theta(eta), [`$`(eta, i)]), i = 0 .. 1)]))(0); res2 := dsolve({sys, f(0) = fvals[1], theta(0) = thvals[1], theta(5) = 0, (D(f))(0) = fvals[2], (D(f))(5) = 1}, numeric, :-output = listprocedure); if output = 'number' then [fvals[3]-(subs(res2, diff(f(eta), `$`(eta, 2))))(0), thvals[2]-(subs(res2, diff(theta(eta), eta)))(0)] else res1, res2 end if end proc; p1 := proc (f1, th1) p(args)[1] end proc; p2 := proc (f1, th1) p(args)[2] end proc; p(.3, -.2); par := fsolve([p1, p2], [.3, -.2]); res1, res2 := p(op(par), output = xxx); plots:-display(plots:-odeplot(res1, [[eta, f(eta)], [eta, theta(eta)]]), plots:-odeplot(res2, [[eta, f(eta)], [eta, theta(eta)]])); plots:-display(plots:-odeplot(res1, [[eta, diff(f(eta), eta)], [eta, diff(theta(eta), eta)]]), plots:-odeplot(res2, [[eta, diff(f(eta), eta)], [eta, diff(theta(eta), eta)]])); plots:-display(plots:-odeplot(res1, [[eta, diff(f(eta), eta, eta)]]), plots:-odeplot(res2, [[eta, diff(f(eta), eta, eta)]])); plots:-display(plots:-odeplot(res1, [[eta, diff(f(eta), eta)]])); fplt[j] := plots[odeplot](res1, [eta, diff(diff(f(eta), eta), eta)], color = L[j], axes = boxed); tplt[j] := plots[odeplot](res1, [[eta, theta(eta)]], color = L[j], axes = boxed) end do;
> plots:-display([seq(fplt[j], j = 1 .. nops(n))]);


Dear Sir

In my above problem i trying to plot for set of values of n but in plot command it not executing , can you do this why it is not executing ??

 

> restart;
> with(plots);
> pr := .72; p := 0; n := 1; s := 1; a := [-0.5,0.0,0.5]; b := 1;
> R1 := 2*n/(n+1);
                                      1
> R2 := 2*p/(n+1);
                                      0
>
>
> for j to nops(a) do R1 := 2*n/(n+1); R2 := 2*p/(n+1); sol1 := dsolve([diff(diff(diff(f(eta), eta), eta), eta)+f(eta)*(diff(diff(f(eta), eta), eta))+R1*(1-(diff(f(eta), eta))^2) = 0, diff(diff(theta(eta), eta), eta)+pr*s^f(eta)*(diff(theta(eta), eta))+R2*pr*s*(diff(f(eta), eta))*theta(eta)+2*(a[j]*(diff(f(eta), eta))+b*theta(eta))/(n+1) = 0, f(-.5) = 0, (D(f))(0) = 1+b*((D@@2)(f))(0), (D(f))(5) = 0, theta(-.5) = 1+s*(D(theta))(0), theta(5) = 0], numeric, method = bvp); fplt[j] := plots[odeplot](sol1, [eta, diff(diff(f(eta), eta), eta)], color = ["blue", "black", "orange"]); tplt[j] := plots[odeplot](sol1, [eta, theta(eta)], color = setcolors(["red", "Coral"])) end do;
Error, (in dsolve/numeric/process_input) boundary conditions specified at too many points: {0, 5, -1/2}, can only solve two-point boundary value problems
>
> plots:-display([seq(fplt[j], j = 1 .. nops(a))], color = [green, red]);

> plots:-display([seq(tplt[j], j = 1 .. nops(a))], color = [green, red]);

 

Dear sir,

In this program i m not getting the solution for decimal values and i do not have idea about the how to set different color for multiple lines(i tried for different set of colors but it shows that only for first color )

 

Hi,

Does anyone no how to normalize wavefunctions such that the plot on the right looks like the one on the left.

Here's my code:-

schro := {diff(psi(x), x, x)-(alpha*x^4+x^2-energy)*psi(x) = 0};

ic := {psi(3) = 0, (D(psi))(3) = 1};

Ic := [{psi(3) = 0, (D(psi))(3) = -1}, %$2];

E := [1.06538, 3.306, 5.74796];

schro1 := [seq(subs(energy = e, alpha = .1, schro), e = E)];

soln1 := [seq(dsolve(schro1[i] union Ic[i], {psi(x)}, type = numeric), i = 1 .. nops(E))]; with(plots);

display(seq(odeplot(soln1[i], [x, psi(x)], -3 .. 3, color = [red, blue, green][i]), i = 1 .. nops(E)))

 

Thanks in advance

> restart;
> with(plots);
> setoptions(title = `Family Plot`, axes = boxed);
> pr := .71; n := 1; p := 0; q := 0; b := 0; l := 0; s := 0; m := 0;
>
>
> R1 := 2.*n/(1+n);
                                 1.000000000
> R2 := 2.*p/(1+n);
                                     0.
> sol1 := dsolve([diff(diff(diff(f(eta), eta), eta), eta)+f(eta)*(diff(diff(f(eta), eta), eta))+R1*(1-(diff(f(eta), eta))^2) = 0, diff(diff(theta(eta), eta), eta)+.71*f(eta)*(diff(theta(eta), eta))-.71*(diff(f(eta), eta))*theta(eta)*R2 = 0, f(0) = 0, (D(f))(0) = 1.8+b*((D@@2)(f))(0), (D(f))(18) = 0, theta(0) = 1+s*(D(theta))(0), theta(18) = 0], numeric, method = bvp[midrich]); plots[odeplot](sol1, [eta, theta(eta)], color = red, axes = boxed);

Dear sir/madam

In my program i want to plot multiple lines for diffrent values of n, but i do not have such type of idea please can you help me.

Hi everybody,

I solve an ODE system numerically with the command

Tend := ….. :
sol := dsolve(MySys, numeric, method=rosenbrock, range=0..Tend):    # or rkf45

One of my colleagues wants the solution in array form for using it in a spreadsheet (namely Excel). 
Here is an example of what I do :
 
data := plottools:-getdata( plots:-odeplot(sol, […..], 0..Tend, refine = Q) )
:  # Q rational
result := data[3]:
ExcelTools:-Export (result, …)


To understand the following, you need to know that
the time step varies by several decades (at least 3 or 4). and that  numfun
is typically in the order of 10^5
 
When I ask Maple to construct  data , Maple seems to sample the solution 
sol
according to the local time step dsolve has selected (and probably some other parameters ?)
Because this time step varies in very large proportions, the result is sometimes a concentration of points in regions where the solution is rapidly changing (which is desirable) … with some lacunarity in slow varying regions.

To obviate this, sometimes  poor appearance, I used to force Maple to compute the solution by regularly sampling the range
]0, Tend[  and combining this array with the original one (result
).
But this not satisfactory for I do not avoid lacunarity region (unless I proceed in some ad hoc way)

Here is my question :
Could you give me some elements about  the way odeplot adapts its sampling strategy according to the local time step, the budget N (the Q value I guess) and maybe numfun
?

Thank you in advance

1 2 3 4 Page 1 of 4