solve是解解析解的,如果没有解析解,就返回空值。
没有解析解,可用fsolve解数值解。
另外用solve时,定义全要符号变量:
syms p q s
s=70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150
subs(s,q,0) % 把q换成0
ans =
130*(1 - (9*sin(p))/13)^(1/2) - 90*cos(p) - 80
>> solve(ans)
ans =
2*atan(39/112 - ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 - (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) - (9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)))
2*atan(((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 - (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) - (9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) + 39/112)
2*atan((9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) - ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 + (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) + 39/112)
2*atan((9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)) + ((7439*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/784 - 9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/2))/1568 + (99333*6^(1/2)*((351*2^(1/2)*3^(1/2)*649357^(1/2))/5488 + 175451/1568)^(1/2))/175616)^(1/2)/(6*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/6)*(9*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(2/3) - (27975*((13*2^(1/2)*3^(1/2)*649357^(1/2))/10976 + 175451/84672)^(1/3))/3136 - 7439/784)^(1/4)) + 39/112)
看来有解析解,算了二十秒~~~
转化成数值解:
double(ans)~~~~又用了二十秒
ans =
2.6198 - 1.5555i
2.6198 + 1.5555i
-0.6117
1.6553
一共有四个解
你上面的问题,s已经先定义为字符串了,为什么solve时还要加''.
q=0;
s=sym('70*cos(q)+130*(1-(90*sin(p)-70*sin(q))/130)^0.5-90*cos(p)=150');
p=solve(s,'q')
很easy啊,你把最后一句改成p=solve(s),保证ok!!