Preben Alsholm

13728 Reputation

22 Badges

20 years, 239 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

Since the expression ((10.-t*n)/n)^1.5 appears in your expression r, you need  t*n <=10.

You can try this, where I let n take the integral values k = 1, 2, 3, 4, 5.

seq(Optimization:-NLPSolve(r,{a<=b,n=k,a>=4,t*n<=9.99} , assume=nonnegative,maximize),k=1..5);

Preben Alsholm

It is NEVER a good idea to use t and t[1] in the same calculations. t[1]:=67; is an implicit assignment to a table called t.

Change t[1] to t1 and start over.

Preben Alsholm

 

 

Are there no other restrictions than a, b, n, t positive and a < b? What about n?

Any reason to believe that there is a minimum?

Preben Alsholm

Sometimes it takes a long time for Maple to figure out how to write output to the screen. If you have no need to see it anyway, then suppress it by using colon.

I have added an axes option so you see something also in the first frame of the animation. Also I have used a list in display instead of a set.

restart;
with(plots):
with(plottools):
a := seq(sphere([1, 1, 1], 5*i), i = 0 .. 10):
b := seq(sphere([3, 3, 3], 5*i), i = 0 .. 10):
display(a[4]);
display([a, b], insequence = true,axes=normal);
 

Preben Alsholm

Try the following:

240*t^3 + 144*t^2- 135*t -52 =0:
solve(%,t):
simplify(evalc([%]));
         

Preben Alsholm

You can also do like this, where I avoid D and use B (irrelevant here, but remember that D has a special meaning in Maple):

e1 := 1.74*10^(-15) = B*exp(-Q/(8.31*1473));
e2 := 7.1*10^(-15) = B*exp(-Q/(8.31*1573));
solve(convert({e1, e2},rational), {B, Q});
evalf(%);

Preben Alsholm
 

There are two cases, if you want an arctan with one argument.

y:=cos(w*t-arctan(2*s0^3*w, -s0^2*(-s0^2+w^2)));

simplify(y) assuming s0>w,w>0;
simplify(y) assuming s0<w,s0>0;
 

Preben Alsholm

I have used D1 instead of D, since D is used for differentiating functions (procedures).

A:=B+C*Z+D1^2*Z^2;
S:={B=0.01, C=0.2, D1=0.3};
eval(A,S union {Z=1});
SBC:=remove(has,S,D1);
plot(eval(A,SBC union {Z=1}),D1=0..1);

Preben Alsholm
 

Since you didn't provide the form of the input to dsolve I'll have to guess.

Here is a very simple example that results in a similar error message.

eq:=diff(x(t),t)=x(t):
dsolve({eq,x(0)=1},x(t),y(t),numeric);
Error, (in dsolve/numeric/process_input) received more than one indication of the dependent vars [x(t), y(t)]

The correct syntax is

dsolve({eq,x(0)=1},x(t),numeric);

or just

dsolve({eq,x(0)=1},numeric);

See line 24 of the procedure `dsolve/numeric/process_input` :

showstat(`dsolve/numeric/process_input`);
 

Here is a system version:

eq1:=diff(x(t),t)=y(t):
eq2:=diff(y(t),t)=-x(t):
dsolve({eq1,eq2,x(0)=1,y(0)=0},x(t),y(t),numeric);
Error, (in dsolve/numeric/process_input) received more than one indication of the dependent vars [x(t), y(t)]

Correct syntax:

dsolve({eq1,eq2,x(0)=1,y(0)=0},[x(t),y(t)],numeric);

or just

dsolve({eq1,eq2,x(0)=1,y(0)=0},numeric);

Preben Alsholm

Could you give us a, maybe simplified, version of the actual code that provokes this?

The following returns true

evalb(0. < 59.92088005+55.46829645*ln(.4804980261));

but this

evalb(0. < 59.92088005+55.46829645*ln(Pi));
returns the inequality, so that

if 0. < 59.92088005+55.46829645*ln(Pi) then "OK" end if;

results in an error message, because evalb is used in the 'if' statement.
 

Preben Alsholm

Maybe I don't get your point, but the output of the procedures don't have to depend on all parameters. 

Here I have chosen an example from the help page for NLPSolve and turned it into a procedural version with 4 superfluous arguments.

with(Optimization);
p:=proc(x,y,z,v,w,d1,d2,d3,d4)::float[8] ;w^3*(v-w)^2+(w-x-1)^2+(x-y-2)^2+(y-z-3)^2 end proc:
p1:=proc(x,y,z,v,w,d1,d2,d3,d4)::float[8]; w+x+y+z-5 end proc:
p2:=proc(x,y,z,v,w,d1,d2,d3,d4)::float[8]; 3*z+2*v-3 end proc:
res:=NLPSolve(p, {p1}, {p2}, assume = nonnegative,initialpoint=[1,1,1,1,1,0,0,0,0]);

Preben Alsholm
 

Here is a simple version.

I have assumed that the system itself doesn't contain parameters. Therefore I have kept it outside the procedure.

As it has been made the procedure returns a sequence of 4 numerical procedures.

sys:=diff(f1(t),t)=piecewise(t<=4,3*exp(-2*t),-1),diff(f2(t),t)=sin(t),diff(g1(t),t)=f1(t),diff(g2(t),t)=f2(t);

p:=proc(a1::realcons,a2::realcons)
local init,F;
init:= f1(0)=a1, f2(0)=a2,g1(0)=0,g2(0)=0;
F:=dsolve({sys,init}, numeric,output=listprocedure);
op(subs(F,[f1(t),f2(t),g1(t),g2(t)]));
end proc:
F1,F2,G1,G2:=p(1,1);
G2(5.5)/G1(5.5);
F1,F2,G1,G2:=p(Pi,1);
G2(5.5)/G1(5.5);

plots:-animate(plot,['p(a,1)[1]' ,0..6],a=.5..3);

Perhaps you would prefer this other version, which returns the listprocedure:

p2:=proc(a1::realcons,a2::realcons)
local init,F;
init:= f1(0)=a1, f2(0)=a2,g1(0)=0,g2(0)=0;
dsolve({sys,init}, numeric,output=listprocedure);
end proc:

p2(Pi,1);
F1,F2,G1,G2:=op(subs(%,[f1(t),f2(t),g1(t),g2(t)]));
 

Preben Alsholm
 

I don't see the need for aold. Does  this accomplish what you want?

restart;
anew:=x-> x^2:
for i from 1 to 5 do
anew:=unapply(anew(x)+x,x);
end do:
anew(x);

Preben Alsholm

This works.

restart;
sys:=diff(f1(t),t)=piecewise(t<=4,3*exp(-2*t),-1),
diff(f2(t),t)=sin(t);
init:= f1(0)=1, f2(0)=1:
F:=dsolve({sys,init}, {f1(t), f2(t)}, numeric,output=listprocedure);
F1:=subs(F,f1(t));
F2:=subs(F,f2(t));
int(F2(t),t=0..5.5)/int(F1(t),t=0..5.5);
 

I guess you insist on doing it numerically, but in this case it is certainly not necessary.

Preben Alsholm

Is this what you want?

with(plots):
a := animate(spacecurve, [[cos(t), sin(t), t], t = 0 .. A], A = 0 .. 2*Pi, color = red, axes = boxed, labels = [x, y, z]):
b := animate(spacecurve, [[piecewise(t<Pi,undefined,sin(t)),cos(t), t], t = 0 .. A], A = 0 .. 2*Pi, color = blue):
display(a, b);
 

Preben Alsholm

First 154 155 156 157 158 159 160 Page 156 of 160