Preben Alsholm

13728 Reputation

22 Badges

20 years, 243 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

Just try it like this:

dsolve(ode, phi2(x), method=laplace);

In the answer you will find the two arbitrary constants in the form of phi2(0) and D(phi2)(0).

The pure and simple

simplify(f);

works for me in Maple 15.

(And in Maple 12).

f'' is not greatest in absolute value at -0.645, but at 0.218 (consistent with the graph) and found this way:

f:=(sin(x)+1)/(x^2+1);
numapprox:-infnorm(diff(f,x,x),x=-Pi/2..3*Pi/2,'xmax');
xmax;

Maple does not work like MathCad.

Compare the following two sequences of commands separated by a restart.

restart;
u:=a*b;
a:=3;
b:=8;
u;
a:=7:
b:=9:
u;
restart;
a:=3;
b:=8;
u:=a*b;
a:=7:
b:=9:
u;

In the first part u is defined as a product of the variables a and b.

Then when a and b are set to point to 3 and 8 u evaluates to 24.

When afterwards (and I do mean in time, not position) a and b are set to point to 7 and 9, u evaluates to 63.

In the second part a and b are first set to point to 3 and 8.

Then u is set to point to the value you get by evaluating a*b, in this case 24. When a and b subsequently are changed nothing happens to u since it points directly to 24.

H = h only solves eq(0) if 1 = m-k+(2*n-1-k)*(1-m+k)/(2*n-1+k), and that is not the case with your values for m, k, n.

Try this instead:

H0:=fsolve(eq(0),H=h);
sol := dsolve({ode, H(0)=H0}, numeric, output = listprocedure);

How did you manage to get all these invalid characters into the worksheet? I have never seen anything like that. A worksheet may look incomprehensible in a text editor, but it should be an xml file and contain only the usual characters avalaible on your keyboard.

Here are two ways.

restart; with(LinearAlgebra):
omega := exp(-(2*I)*Pi/N):
N := 8;
F:=evalc~(Matrix(N,(i,j)->omega^((i-1)*(j-1))));
#And an answer to your second question
A:=RandomMatrix(N);
A.Column(F,3);

#A second way
restart;
F:=N->evalc~(Matrix(N,(i,j)->exp(-(2*I)*Pi/N)^((i-1)*(j-1))));
F(4);
F(8);

If you want to procede the way you are doing you should use the 'known' option. This means to tell dsolve/numeric that yy0 is known, like this known = yy0. However, in your case you will also want to define also diff(q(t),t) by yy1:=eval(diff(q(t),t),dsol0); and then write known=[yy0,yy1].
Also I think you want to look at dsys01 where the initial conditions refer to q10 instead of q01.

Since I wasn't quite sure what your point was I thought, why don't you solve the 3 equations as a system?
But the point may be that q01 is identically zero?

Solving the 3 equations as a system.

restart;
u := 8.53;
dsys0:={diff(q(t), t,t) = u*(1 - q(t)*q(t)) * diff(q(t), t) - q(t), q(0) = 0, D(q)(0) = 1};
dsys10:={diff(q10(t), `$`(t, 2)) = u*(1 - q(t))*q(t) * diff(q10(t),t) - 2*u*q(t)*diff(q(t),t) * diff(q10(t),t)- q10(t), q10(0) = 0, D(q10)(0) = 1};
dsys01:={diff(q01(t), t,t) = u*(1 - q(t)*q(t)) * diff(q01(t),t) - 2*u*q(t)*diff(q(t),t) * diff(q01(t), t)- q01(t), q01(0) = 0, D(q01)(0) = 0};
res:=dsolve(dsys0 union dsys10 union dsys01,numeric,output=listprocedure);
plots:-odeplot(res,[t,q01(t)],0..6,thickness=3);
plots:-odeplot(res,[[t,q(t)],[t,q10(t)]],0..6,view=[0..6,-2..2]);
yy0,yy10,yy01:=op(eval([q(t),q10(t),q01(t)],res));
yy01(1.2345);

You can do as in the following simple example, where the point is that the loop ends with a colon and there is an explicit print statement inside.

eq:=diff(x(t),t)=x(t);
ICs:=[seq(x(0)=k,k=-4..5)]:
n:=nops(ICs):
res:=NULL:
for i from 1 to n do
   res:=res,dsolve({eq,ICs[i]});
   print(i);
end do:
   
res;

I don't get any solution from

p1 := dsolve({ics, dics, ode}, y(t));

and I tried in both Maple 15 and 12. Thus you get an error when executing the assignment to f and consequently also an error later on.

(The package linalg is deprecated and should be replaced with LinearAlgebra, but neither one is used in your sequence of commands).

Here is a rather simple approach.

with(CurveFitting);
X:=[0,1,3,5,6]: Y:=[0,-1,-3,6,0]:
#Choosing a model, here a polynomial of degree 3.
#You can use anything linear in the unknown constants a, b, ... (well, not quite):
f:=v->a*v^3+b*v^2+c*v+d;
#Your given piecewise linear function:
g:=Spline(X,Y,x,degree=1);
#The 3 conditions:
eq1:=f(0)=0;
eq2:=f(6)=0;
eq3:=int(f(x),x=0..6)=int(g,x=0..6);
solve({eq1,eq2,eq3},{a,b,c,d});
cv:=subs(%,f(x));
res:=LeastSquares(X,Y, x, curve=cv);
plot([g,res],x=0..6);

The start value in fsolve is not appropriate for large values of z.

Try instead

Y := z->if not type(z,numeric) then 'procname(z)' else fsolve(eq(z), H=0..infinity) end if;

Here are 4 ways. The first and the third make use of the globally defined A. evalf is only included since you did. I would leave it out unless you insist on a floating point number.

A := r*sin(m);
Aval1 := proc (rr, mm) global A,r,m;
evalf(eval(A,{r=rr,m=mm}));
end proc;

Aval1(1, Pi);

Aval2:=proc(r,m) local A;
A := r*sin(m);
evalf(A)
end proc;

Aval2(1,Pi);

Aval3:=evalf@unapply(A,r,m);

Aval3(1,Pi);

Aval4:=(r,m)->evalf(r*sin(m));

Aval4(1,Pi);

The error message tells the story.

Also try

expand(P);

I tried the following (in Maple 12 at the moment).

sys:=diff(z1(t),t)=z2(t),diff(z2(t),t)=-1/m*(d*z2(t) +  k*(1+A*cos(z5(t)*t))*z1(t)),diff(z3(t),t)= v,diff(z4(t),t)=0,diff(z5(t),t)= v/g*z4(t)^2;
#Trying to solve the initial value problem:

dsolve({sys,z1(0)=z10,z2(0)=z20,z3(0)=z30,z4(0)=z40,z5(0)=z50});
#No success.
#Solving the system consisting of the last three equations should be easy:
dsolve({sys[3..5],z3(0)=z30,z4(0)=z40,z5(0)=z50});
#Substituting into the first two:
sys12:=subs(%,{sys[1..2]});
#So we need to solve the initial value problem for z1 and z2:
ini12:=subs(sys12 union {z1(0)=z10,z2(0)=z20});
#I didn't get any response, but didn't wait for too long, so tried without initial conditions:
dsolve(sys12);
#but again I didn't get any response in the time I allotted to the task.

If you know the values of all constants numerical solution of the system is of course possible.

First 131 132 133 134 135 136 137 Last Page 133 of 160