hello?
I wrote the following equations to be solved.
restart;
eq1:=expand(sum((-1)^(i+1)*cos(omega*t[i]),i=1..5)=0):
eq2:=expand(sum((-1)^(i+1)*sin(omega*t[i]),i=1..5)=0):
eq3:=expand(sum((-1)^(i+1)*cos(r*omega*t[i]),i=1..5)=0):
eq4:=expand(sum((-1)^(i+1)*sin(r*omega*t[i]),i=1..5)=0):
t[1]=0;t[4]:=2*t[3]-t[2];t[5]:=2*t[3];
_EnvAllSolutions:=true:
_EnvExplicit:=true:
s1:=solve({eq1,eq2,eq3,eq4},{t[2],t[3],r});
Do I have to specify t[3]>t[2], t[2]>0 in the code?
where t[1] to t[5] are time variables starting from t[1]=0
and omega and r are constants.
How can I get the solutions for t[2] and t[3]?
Thanks
Comments
Trying fsolve?
First of all I think you should change omega variable to sth. else, e.g. om, since Maple translates omega as a built-in function [except, of course, you need to use omega]. You may change the code writing:
restart:
eq[1]:=add((-1)^(i+1)*cos(om*t[i]),i=1..5):
eq[2]:=add((-1)^(i+1)*sin(om*t[i]),i=1..5):
eq[3]:=add((-1)^(i+1)*cos(r*om*t[i]),i=1..5):
eq[4]:=add((-1)^(i+1)*sin(r*om*t[i]),i=1..5):
eq[5]:=t[1]:
eq[6]:=t[4]-2*t[3]+t[2]:
eq[7]:=t[5]-2*t[3]:
s1:=fsolve({seq(eq[i],i=1..7)},{seq(t[i],i=1..5),r,om});
Solutions:=subs(s1,[seq(t[i],i=1..5), r, om]):
t:=[seq(op(i,Solutions),i=1..5)]; r:=op(6,Solutions); om:=op(7,Solutions);
omega
Maple 10.06 should not confuse omega with the built-in function Wrightomega, unless it has been given as an alias for the latter. AFAIK there were no omega functions in previous versions of Maple.
Hope this helps,
J. Tarr
symbolic solution?
Thank you for your numeric way.
But, I try to get a solution symbolically.
t[1],t[2],...t[5] are time variables.
oemga, r are constants.
Could you give me help?
Thanks,
omega
J. Tarr is right when he points that it should work with variable omega without problem. I checked it out, but another paradox emerged: although, fsolve gave results with both omega and alternative variable, when used with omega the calculations delayed a little. Again with time function:
<
restart: st:=time(): Digits:=10:
eq[1]:=add((-1)^(i+1)*cos(omega*t[i]),i=1..5):
eq[2]:=add((-1)^(i+1)*sin(omega*t[i]),i=1..5):
eq[3]:=add((-1)^(i+1)*cos(r*omega*t[i]),i=1..5):
eq[4]:=add((-1)^(i+1)*sin(r*omega*t[i]),i=1..5):
eq[5]:=t[1]:
eq[6]:=t[4]-2*t[3]+t[2]:
eq[7]:=t[5]-2*t[3]:
s1:=fsolve({seq(eq[i],i=1..7)},{seq(t[i],i=1..5),r,omega}):
Solutions:=subs(s1,[seq(t[i],i=1..5), r, omega]):
t:=[seq(op(i,Solutions),i=1..5)]; r:=op(6,Solutions); omega:=op(7,Solutions);
seq(eq[i],i=1..7); time()-st;
>
If omega is substituted for om for instance, calculations do not delay (maybe this happens at random). Still, since Maple output generates the greek omega (something like a w) for omega variable, then I guess that one should be sceptical for using this variable.
But, maybe he shouldn't.
pantole
arbitrary constants
Thanks anyway,
I am trying to solve it for time variables.
Could you make some code for arbitrary constants
of omega and r for time t[2] and t[3] solutions?
Those should be in positive format due to time variables.
I think that you have to use "solve" command.
Thanks
fsolve
If you know that the values of the variables fall within a certain range, you can insert this as option in fsolve - please see ?fsolve,details. Something like this:
restart: Digits:=15:
eq[1]:=add((-1)^(i+1)*cos(omega*t[i]),i=1..5)=0:
eq[2]:=add((-1)^(i+1)*sin(omega*t[i]),i=1..5)=0:
eq[3]:=add((-1)^(i+1)*cos(r*omega*t[i]),i=1..5)=0:
eq[4]:=add((-1)^(i+1)*sin(r*omega*t[i]),i=1..5)=0:
eq[5]:=t[1]=0:
eq[6]:=t[4]-2*t[3]+t[2]=0:
eq[7]:=t[5]-2*t[3]=0:
s1:=fsolve({seq(eq[i],i=1..7)},{seq(t[i],i=1..5),r,omega},0..4):
Solutions:= [seq(t[i]=eval(t[i],s1),i=1..5),r=eval(r,s1),omega=eval(omega,s1)];
check_Solutions := seq(eval(eq[i],s1),i=1..7);
Hope this helps,
J. Tarr