Preben Alsholm

13728 Reputation

22 Badges

20 years, 249 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

FunctionAdvisor(definition,InverseJacobiCN);
FunctionAdvisor(definition,JacobiCN);
FunctionAdvisor(definition,InverseJacobiAM);

plot(JacobiCN(x,2),x=0..5);
eq:=diff(X(x), x, x)+(1.6+4*JacobiCN(x, 2)^2)*X(x) = 0;
T:=5: #Change as desired
res:=dsolve({eq,X(0)=1,D(X)(0)=0},numeric,range=0..T);
plots:-odeplot(res,[x,X(x)],0..T,refine=1);

By searching the internet you should be able to find inspiration. The lines you list above are not very close to Maple syntax.

Without looking too hard I found

http://www.cems.uwe.ac.uk/~jvanlent/NA/cwk/midpoint_rule.mpl

In Maple syntax the ode can be written

eq:=diff(z(t),t)=k*(1/2-z(t))*(1/3-z(t));

Use dsolve to solve the ode. You need an initial value, say z(0) = z0.
Then the solution to the initial value problem is

dsolve( { eq, z(0) = z0} );

Be aware that there are two equilibria, z = 1/2 and z = 1/3. The one is asymptotically stable, the other is unstable.

Let T3(t) = diff(T1(t),t,t) (*)  and T4(t) = diff(T2(t),t,t)  (**). Then your first given ode can be written as

A1*diff(T3(t),t,t) + A2*T3(t) +  A3*T1(t) + A4*T4(t) + A5*T2(t) = 0.

The other given ode can be rewritten similarly. With those two eqs and  (*) and (**) you have 4 odes of order 2.

For a numerical solution m and initial conditions must have numerical values:

X := diff(F(t), t$2)+(10+8*sin(m*t)/(m*t))*F(t) = 0;
T:=2*Pi: #Change as desired
res:=dsolve({eval(X,m=1),F(0)=1,D(F)(0)=0},numeric,range=T);
plots:-odeplot(res,[t,F(t)],0..T,refine=1);

The following works on your longer example (as well as on your simple one):

restart;
sys:=[0 < 2*f[1], 5 < f[1]+f[2], 8 < f[1]+f[3], f[1]+f[4] = 7, 0 < 2*f[2], f[2]+f[3] = 6,
    6 < f[2]+f[4], 0 < 2*f[3], 11/2 < f[3]+f[4], 0 < 2*f[4]];
var:={f[1],f[2],f[3],f[4]};
#Splitting:
eqs,ineqs:=selectremove(type,sys,`=`);
solve(eqs,var);
subs(%,ineqs);
solve(%,indets(%,name));
#Output NULL as is correct in this case.

Is this what you are looking for:

a := Array([ [[1,2,3],[4,5,6]],[[1,2,3],[4,5,6]],[[1,2,3],[4,5,6]]]);
b:=ArrayTools:-Permute(a,[1,3,2]);
#To check if b is what you want:
convert(b,listlist);


Type function in Maple means an expression of the form f(x) where x could be anything. Thus sin(1) is of type function.

Your function f (in the mathematical sense) is of type procedure in Maple.

Your aprox doesn't quite do what you want it to do though even with the type check change. Here is a modified version. You may want to include an evalf wrapped around [resp] at the end:

aprox:=proc(fn::procedure,x::realcons,iteracions::integer)
local i,resp;
resp:=NULL;
for i from 1 to iteracions do
resp:=resp,[x+(1/i),fn(x+(1/i))];
end do;
[resp]
end proc;

If Digits = 15 is OK with you then method = _d01amc is very fast (as fast as Digits=10 without specifying a method):

evalf[15](Int((phi(g_line(t,mu0,c0))/(g_line(t,mu0,c0)-mu0)*exp(-l*g_line(t,mu0,c0))
  *diff(g_line(t,mu0,c0),t)),t=0..infinity,method = _d01amc));

#Result 0.999887009423573e-1-.605301458903814*I

This agrees with the result 0.9998870094e-1-.6053014589*I from

evalf(Int((phi(g_line(t,mu0,c0))/(g_line(t,mu0,c0)-mu0)*exp(-l*g_line(t,mu0,c0))
  *diff(g_line(t,mu0,c0),t)),t=0..infinity));

This was done in Maple 16.

plot(sin(x)-1/2,x=-1000..1000,sample=[seq(i,i=-1000..1000,10)],adaptive=false);
plot(sin(x)-1/2,x=-1000..1000,sample=[seq(i,i=-1000..1000,10)],adaptive=false,style=point);
#Or use pointplot
plots:-pointplot([seq([i,sin(i)-1/2],i=-1000..1000,10)]);
plots:-pointplot([seq([i,sin(i)-1/2],i=-1000..1000,10)],connect);

You don't have a differential equation. Presumably you meant:

DE := diff(y(t),t)=y(t)^2*(4-y(t)^2);

 

The number option referred to is the number of equations in the first order system corresponding to your equation in your case 1. It applies only when the ode is given as a procedure:

p:=proc(N,t,Y,YP) YP[1]:=Y[1]^2*(4-Y[1]^2) end proc;

DEtools[DEplot]( p,y(t) ,t=0..1/2, number=1,{[y(0)=1],[y(0)=3]}, arrows=none, thickness=2, linecolor=[blue,green]);

(see the help page for DEplot)

plot evaluates its arguments first (as most Maple procedures do). So pltx(2, 5, x) is evaluated. But x is just a name. So obviously the inequality checks in pltx cannot succeed.

Either use unevaluation quotes around pltx(2, 5, x) as in:

d := plot('pltx(2, 5, x)', x = 0.1 .. 0.4);

or change the procedure so it begins like this

pltx := proc (num1::integer, num2::integer, x)
if not x::numeric then return 'procname(_passed)' end if;
#The rest unchanged

This will mean that

pltx(2, 5, x);

returns unevaluated, if x is not of type numeric.

Remove the second assume command. New assumptions cancel previous ones.

I find it more convenient not to use assume at all. I use assuming instead:

restart;
f_exp:=exp(-alph*r^2);
ff_deriv:=r^2*f_exp^2;
ff:=int(ff_deriv,r=0..infinity) assuming alph>0;
#assuming makes assumptions during that last computation only.

This is a bug in Maple 12. It has been corrected in later versions.

http://www.mapleprimes.com/posts/134942-Patching-Maple?submit=135014#comment135014

A workaround is to add a harmless nonlinear term to the right hand side of the pde. By harmless I mean that it evaluates to zero inside the r-range. The following is perfectly fine:

Enonlin := E+(0=T(r,t)^2*piecewise(r < 0, 1, 0));

restart;
u:=A*sin(x)*cos(z) + B*sin(2*x)*cos(z) + C*sin(3*x)*cos(2*z);
L:=convert(u,list);
eval(L,{sin=1,cos=1});
L/~%;

All assuming that sine or cosine don't appear in the coefficients.

First 109 110 111 112 113 114 115 Last Page 111 of 160