I have the following symbolic equation e.g. syms F1 F2 G in Matlab :
eqn =
G*((1.1*(F1 - 1.0)*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) + (1.1*F1*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G))) - 1.0*(G*(((F1 - 1.0)*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) + (F1*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G))) - (0.526*F1^2*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*(F1 - 1.0)^2*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G)) + 0.55)^2 + 1.0*G^2*((1.0*F1*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25)^2)/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G))^2 - (1.0*(F1 - 1.0)*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25)^2)/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G))^2) - 2.1*G*(((F1 - 1.0)*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) + (F1*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G)))*((0.5*F1^2*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) - (0.5*(F1 - 1.0)^2*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G))) + (0.277*(F1 - 1.0)^2*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25)^2)/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G))^2 - (0.579*F1^2*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25))/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.277*F1^2*((0.132*F2^2)/(0.526*(F1 - 1.0)^2 + F1*G) - (0.25*G*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G) + 0.25)^2)/(0.526*(F2 - 1.0)^2 + G*(F2 - (1.0*(G*(F1 - 1.0) - 0.526*F1^2)*(F2 - 1.0))/(0.526*(F1 - 1.0)^2 + F1*G)) + (0.526*F2^2*(G*(F1 - 1.0) - 0.526*F1^2))/(0.526*(F1 - 1.0)^2 + F1*G))^2 + (0.579*(F1 - 1.0)^2*((0.132*F1^2)/(0.526*(F2 - 1.0)^2 + F2*G) - (0.25*G*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G) + 0.25))/(0.526*(F1 - 1.0)^2 + G*(F1 - (1.0*(G*(F2 - 1.0) - 0.526*F2^2)*(F1 - 1.0))/(0.526*(F2 - 1.0)^2 + F2*G)) + (0.526*F1^2*(G*(F2 - 1.0) - 0.526*F2^2))/(0.526*(F2 - 1.0)^2 + F2*G)) + 0.302 == 0.08
It's a big one but all the values are in the range [0.0,1.0] and I want to isolate G in a polynomial form. So I call eqn = isolate(eqn,G) and the result I am getting is as follows:
eqn =
G == root(625000000040358827391239865006471429713989707011023710947483778000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*F2*z^4 + 312500000020179413695619932503235714856994853505511855473741889000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2^2*z^4 + 1289062500020179413695619932503235714856994853505511855473741889000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^2*z^4 - 625000000040358827391239865006471429713989707011023710947483778000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2*z^4 - 1601562500040358827391239865006471429713989707011023710947483778000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*z^4 + 312500000020179413695619932503235714856994853505511855473741889000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*z^4 + 3000601753982512388900693004011126908350061726894072319683884222378588840916297186822703224606812000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*F2*z^3 + 2342935616106242608066626518506190225774889065624622776607849292670361310610864791215135483071208000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2^2*z^3 + 657666137873724706683875204682023422575020575631357439894628074130102530305432395607567741535604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^3*F2*z^3 + 657666137873724706683875204682023422575020575631357439894628074130102530305432395607567741535604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*F2^3*z^3 - 3329434822916829668092439325529226336199919929071658936449791403855749481069013384626487095374614000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2*z^3 - 3329434822916829668092439325529225359637419929071658936449791403863561981069013384626487095374614000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*F2^2*z^3 - 328833068936862353341937602341011711287510287815678719947314037067004390152716197803783870767802000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2^3*z^3 + 1027603340363883342999258670787967947500152085638092103181406855589843750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^4*z^3 + 657666137872452169608779564270567280856194532812311388303924646337133780305432395607567741535604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2^2*z^3 - 2384039749664629039340454943916948582850314459091862926310127748238879390152716197803783870767802000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^3*z^3 + 2712872818602763929757488186669417412419150789726587697848145213091040030305432395607567741535604000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^2*z^3 - 328833068936862353341937602341011711287510287815678719947314037063098140152716197803783870767802000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2*z^3 - 1356436409303290770491387553951892918787814459091862926310127748234973140152716197803783870767802000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1*z^3 + 1272537075095640411456141718826042819046051590703427792968750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*z^3 - 940741328805673681968816073414179915105671695276044851370511997499693202896854870689460386676852634989271776251529288970232300926000000000000000000000000000000000000000000000000000000000000000000*F1*F2*z^2 + 1157003703195776300329994791982601389079448906421721089042991435235524505133356019623560595303813535220149078929008368277209228836000000000000000000000000000000000000000000000000000000000000000000*F1^4*F2^2*z^2 + 692039598201819774843505038693588663631455071359435822333845332615249906853885982677692134354342859502798157858016736554418457672000000000000000000000000000000000000000000000000000000000000000000*F1^3*F2^3*z^2 + 616347767133424723237486859228071452264769777634700998657651281065358489508356019623560595303813535220149078929008368277209228836000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2^4*z^2 - 3352066803694282262925247142005586287407750601824267411216086263368211950150693126158918443722848699538245394645041841386046144180000000000000000000000000000000000000000000000000000000000000000000*F1^3*F2^2*z^2 - 2270754931569579108740231276496526413778392344250227230445405955038053870623583832309710982842569152663245394645041841386046144180000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2^3*z^2 + 3314220888158880008321904642394756673199831360125422410838645027221688329966808848125885460891008021771920855180537657247441529762000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2^2*z^2 - 540655936059673482553547185746505632731273773664074005789223078824864959087173943430570943746715789062500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^5*F2*z^2 + 194636136953407406053873172383662178947065348341866575992011690763656688133512364149710893886124183529850921070991631722790771164000000000000000000000000000000000000000000000000000000000000000000*F1^4*F2*z^2 - 616347767133424723237486859228071452264769777634700998657651281067413696189078696161258730083743648501399078929008368277209228836000000000000000000000000000000000000000000000000000000000000000000*F1*F2^4*z^2 + 421711630190461058401162747624628826832105309084300599240293668352153860640845480695642088728104863409048157858016736554418457672000000000000000000000000000000000000000000000000000000000000000000*F1^3*F2*z^2 + 1232695534265510399205493344952130495587001787373361742750396533199115340671744364037802932040845191534048157858016736554418457672000000000000000000000000000000000000000000000000000000000000000000*F1*F2^3*z^2 + 346019799081092815317840844038487915703562280615969952637926385701187098271772644661750117760191293032649078929008368277209228836000000000000000000000000000000000000000000000000000000000000000000*F1^2*F2*z^2 - 600128089007000643689802953095560893031626438355537203267264682434404618735883065230582989076112781186100921070991631722790771164000000000000000000000000000000000000000000000000000000000000000000*F1*F2^2*z^2 + 540655936062351577092507932754529936814679128787020090385340154170166015625000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^6*z^2 + 86504949775562233672808223212701813639983871061223147566380919444064003061200343174739216215918440445662269732252092069302307209000000000000000000000000000000000000000000000000000000000000000000*F2^4*z^2 - 1351639840157217990000750205390337507880070678925620617699463494169165516824647532700964802643284199218750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^5*z^2 - 2543487930722676537698134779930113281250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F2^3*z^2 + 2384292678039351707515633527541383165028211114919253324011234875555439260342284559917522826459268706070662269732252092069302307209000000000000000000000000000000000000000000000000000000000000000000*F1^4*z^2 - 432524748877744009129467634250538239540521223609050798685699942296619261238852805564680817159873647540811348661260460346511536045000000000000000000000000000000000000000000000000000000000000000000*F2^2*z^2 - 2297787728265128521112305677832694787934105373092339280077149950103625852306774568489800003590062257812500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^3*z^2 + 783951107253576663849753490796889016390692600617225029172967079269235784555762402345602244050192430584188651338739539653488463955000000000000000000000000000000000000000000000000000000000000000000*F1^2*z^2 + 519029698646812484158594435382087925437659746935595368197689769165110181981485296328213701922505978611473618393512552415813843254000000000000000000000000000000000000000000000000000000000000000000*F2*z^2 + 113537746611697271357095956474481677117715602082229171285442081587961744481485296328213701922505978611473618393512552415813843254000000000000000000000000000000000000000000000000000000000000000000*F1*z^2 - 173009899552396355380523338116445721364777558990556035085158195433058310873110157400573966198620658235074539464504184138604614418000000000000000000000000000000000000000000000000000000000000000000*z^2 - 270327968029836741276773592873250139940222456756594208329185538768963602938517176710320200072601437500000000000000000000000000000000000000000000000000000000000000*F1^6*F2*z + 284456881091126574059638426752737093756065387090894145929258444266088878552121728692090293834733079196997795485168936124864558223632812500000000000000000000000000000000000000000000000000000000000*F1^5*F2*z - 347037394907268141979696523915493409032541052308550679913577386083350775346436091731736044087207498310670599231931499730025442374257791174072931394967156393249752000000000000000000000000000000000*F1^4*F2*z + 364104807820548293169399542966348108881766277270525600134243908864226726199000340248770069775486206175027237738638729468048787851496115075927068605032843606750248000000000000000000000000000000000*F1*F2^4*z - 563224624648892870067771891999726746254048174268070331563272614226759792438319311027523807006210021885635507788900453335680026244640699640744740117614952623625868000000000000000000000000000000000*F1^3*F2*z - 1416595267912692033998748055259237180046025149393173639974195997713335248265413026959716474041847267049100703761108219652976799439906324640744740117614952623625868000000000000000000000000000000000*F1*F2^3*z + 1120760111612616082690414313726248394654858410856316279571811126891045000776237695765253521762888626281345038129052657454345526804007903135190041571389585328688554000000000000000000000000000000000*F1^2*F2*z + 1689673873780498393437782491733672932920468592602830216594921103140555557138939457650131041621173476156832831307616057885703403900168059385190041571389585328688554000000000000000000000000000000000*F1*F2^2*z - 585981175105113857556918989555026761229926846108241913804229848598012274277641195416192940218749975866472502286462374684671560886601605151854137210065687213500496000000000000000000000000000000000*F1*F2*z - 270327968029836741276773592873250139940222456756594208329185538768963602938517176710320200072601437500000000000000000000000000000000000000000000000000000000000000*F1^5*F2^2*z + 270327968029836741276773592873250139940222456756594208329185538768963602938517176710320200072601437500000000000000000000000000000000000000000000000000000000000000*F1^4*F2^3*z - 1339047269480373504015085367952197971483049130332029580157490811482823289679799927398562500000000000000000000000000000000000000000000000000000000000000*F1^3*F2^4*z - 364104807820548293169399542966347838553798248772831592841024539627833941221526517416213588208976693386170342808049537495945352305335958825927068605032843606750248000000000000000000000000000000000*F1^4*F2^2*z - 1012666496732223160398437512685432770863661881958462792650560515491586025090778820558419209588627307607481858135621431757155408037179730151854137210065687213500496000000000000000000000000000000000*F1^3*F2^3*z - 364104807820548293169399542966348108881766276601001965394057156855345829515686316785848221896471093334240189100991313296445533808929708825927068605032843606750248000000000000000000000000000000000*F1^2*F2^4*z + 2247209360739431326936455354960844698239105309447810075565250301958653701094590334727336682884339175331006914079764010809007328649296981629635343025164218033751240000000000000000000000000000000000*F1^3*F2^2*z + 2247209360739431326936455354960844968567073330179857404270155899004325494868363998801342472107418006747785612699060516776220635225312606629635343025164218033751240000000000000000000000000000000000*F1^2*F2^3*z - 3299699820841155626013742984252432454255839113492813673416683809739568324217650196754387848874091361168555705618005031143257983648121253694453014537746327050626860000000000000000000000000000000000*F1^2*F2^2*z + 270327968031175788546253966377265225308174654728077257459517568349121093750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*F1^7*z - 810983904094196889273502085883803218608500063169973296943718719838174448530741411644839899963699281250000000000000000000000000000000000000000000000000000000000000*F1^6*z - 91026201955137073292349885741587027220441569317631400033560977216391234726553844492541838122121632295302376408718625199938019548695317831481767151258210901687562000000000000000000000000000000000*F2^4*z - 142228440545563287029819213376367060074208526630957042602157785279215742954231481624024954977971232753416178483996112902332242811097656250000000000000000000000000000000000000000000000000000000000*F1^5*z + 273078605863016080315064877975086410448205972696131823580640757861759610535291372215055482162401323620806255632153513644978480428914078494445301453774632705062686000000000000000000000000000000000*F2^3*z + 193430679131199221643318982511799102141578175201094906915219274217349109479057142966792118891996598934158129284211125209865071766855463418518232848741789098312438000000000000000000000000000000000*F1^4*z - 273078605863016080315064877975086410448205972696131823580640757860421397828076334493658199449401000614623987735917742313275190085628922244445301453774632705062686000000000000000000000000000000000*F2^2*z - 11378275213739656372664873279601574717274894486169339276277056975889619637636624159946091681030832449866424545004706615501967476222640255554698546225367294937314000000000000000000000000000000000*F1^3*z + 11378275213739656372664873279601845045242918565834841682116414055260195170260103777382858595182644997684723182652122787105221518789046505554698546225367294937314000000000000000000000000000000000*F1^2*z + 91026201957532212854334664991261698433560304574393776553603151001128902956493930312317304900084559548038714210249444491367017079296880331481767151258210901687562000000000000000000000000000000000*F2*z - 51202238583240795051514989885757100526282874371940262950739165693434760794885575522991697136062439416286862998684193016103831425156244668518232848741789098312438000000000000000000000000000000000*F1*z - 2395139561984779249674671213118735256762376520042173786075880937155123541172749490963250258918605697766590623132287873886718750000000000000000000000000000000000000000000000000000000000*z + 1263148349339290402242467782430012693895576216102482452117041254558159831050134628581834294173174733350960510666950880321330403695703783133372576897247179781879260535002446077668402518723311800386*F1^2*F2^2 + 341229648873486446833555427640005567152168231314121990121850811106154851010558271891793406352943964205631495400508305125479129885568744539184156606353181308462248206765281430039624122052543953032*F1^3*F2^3 - 703411995485294519643774341068005429136390661574185178985864225605355658182947739534558266084210014761649024535240586487611308254183004059847387741939065662389530391913203575099060305131359882580*F1^3*F2^2 - 568913762182253148119276853505466932922352992566557250975250527946126619809310686784217391010973159238192075335849295925072510726750000000000000000000000000000000*F1^5*F2 + 532797171048551296226996627248002645560306536336565935985821821350777069217924940100195881510978327987768181490329826033567248797978250886292977363410437544413769663530562860079248244105087906064*F1*F2 - 135163984015587894273126983188632355753252237029471416462911292910644531250000000000000000000000000000000000000000000000000000000*F1^6*F2^2 + 67581992007793947136563491594316177876626118514735708231455646455322265625000000000000000000000000000000000000000000000000000000*F1^4*F2^4 - 874026819922037743060552054888007928255593681314392990438804379074216040781858760457596640937038171465622319907823042996003120453677566781420632082791675048492972807795844290118872366157631859096*F1^2*F2 + 532797171048551296226996627248002361103425454790550124286512067318811771501172320310036075282474059595523372179643041816176237824819012694217641514114512471903042913530562860079248244105087906064*F1^3*F2 - 778243058834505318363831455084009389051524524012891893537260374601154349948303594609162562659641137239021429190583978596306813740762623155885055666587028198644893766913203575099060305131359882580*F1^2*F2^3 + 142228440545563287029819213376367003558556279317427858997779009251243161456801730638887273575329111098610518833962323981268127681687500000000000000000000000000000*F1^5*F2^2 - 142228440545563287029819213376366733230588248141639312743812631986531654952327671696054347752743289809548018833962323981268127681687500000000000000000000000000000*F1^4*F2^3 - 142228440545563287029819213376366733230588248141639312743812631986531654952327671696054347752743289809548018833962323981268127681687500000000000000000000000000000*F1^3*F2^4 - 799195756572826944340494940872003968340459804504848903978732732026165603826887410150293822266467491981652272235494739050350873196967376329439466045115656316620654495295844290118872366157631859096*F1*F2^2 - 133199292762137824056749156812000661390076634084141483996455455337694267304481235025048970377744581996942045372582456508391812199494562721573244340852609386103442415882640715019812061026271976516*F1*F2^4 + 133199292762137824056749156812000803618517182042568075800448081379735206765655557177671923969529129706128896536418304535565688571139467495582661322014600020167283259632640715019812061026271976516*F1^2*F2^4 - 95783761087532424696720599803997970290306975048352977624690499006128768480562599291183103026869088099981081406552280182305295739755705433460240566908721777337352290882640715019812061026271976516*F1^4*F2 + 142228440545563287029819213376366733230588248141639312743812631986531654952327671696054347752743289809548018833962323981268127681687500000000000000000000000000000*F1^6*F2 + 95783761087532424696720599803998539204069157301501096901544004472926526849539577954160951294208401870847638480209592983233395420004299094285576416204646849848079040882640715019812061026271976516*F1^4*F2^2 + 532797171048551296226996627248002645560306536336565935985821821350777069217924940100195881510978327987768181490329826033567248797978250886292977363410437544413769663530562860079248244105087906064*F1*F2^3 - 95783761087532424696720599803998681432509698074509002751198881489044339691931475743513981391649168422723295372582456508391812199494562721573244340852609386103442415882640715019812061026271976516*F2 - 133199292762137824056749156812000661390076634084141483996455455337694267304481235025048970377744581996942045372582456508391812199494562721573244340852609386103442415882640715019812061026271976516*F1 + 143675641631298637045080899705998022148764547111763504126798322233566509537897213615270972087473752634084943058873684762587718299241844082359866511278914079155163623823961072529718091539407964774*F2^2 + 112246595023816198080085671024006082101141348801905349585424598561797267712013882668751037246235840187740900181284449275769682900758330033537667924647962536255363375000000000000000000000000000000*F1^5 - 20952697738321625976663485787994579288935285282236134411030856775761835608455647285364100305206207078163390717239064399696306712914943625535576416204646849848079040882640715019812061026271976516*F1^3 - 37415531674605399360028557008001979957566933614492919260477324172936726787576815085405398257376955329427094452747433777785142492912971180259416981161990634063840843750000000000000000000000000000*F1^6 + 181091173305904036405109456714000002106331485516535547356834145757591728015382888768922381422759092376069966895037836735413841927596939308350449530116923445091322780073961072529718091539407964774*F1^2 - 125716186426538491265934078081008533929021405856197609962094828405054504973842561136323754601796531731329282021354738327713849533540465698038190801758791457857184458529339821245046984743432005871*F1^4 + 23945940271883106174180149950999670358127424518627250687799720372261084922982868935878495347912292105680823843145614127097953049873640680393311085213152346525860603970660178754953015256567994129*F2^4 - 95783761087532424696720599803998681432509698074509002751198881489044339691931475743513981391649168422723295372582456508391812199494562721573244340852609386103442415882640715019812061026271976516*F2^3 + 67581992007793947136563491594316177876626118514735708231455646455322265625000000000000000000000000000000000000000000000000000000*F1^8 - 270327968031175788546253966377264711506504474058942832925822585821289062500000000000000000000000000000000000000000000000000000000*F1^7 + 23945940271883106174180149950999670358127424518627250687799720372261084922982868935878495347912292105680823843145614127097953049873640680393311085213152346525860603970660178754953015256567994129, z, 1)
Which seems very weird to me. How do these huge numbers appear ? Is this the wrong way to do it ? Also , after that I want to exctract the coefficients from the polynomial. I already tried c=coeffs(eqn,G) but it doesn't seem to work. It returns the previous result.
UPDATE: By the advice in the comments and removing the magic numbers , I finally managed to get a neat form without the big numbers, but still the coeffs doesn't appear to work to extract the coefficients.I also tried c=sym2poly(eqn) but I am getting
Error using sym/sym2poly (line 30)
Not a polynomial.
Related
I want to estimate the parameters x1-x15 with the least square method in MATLAB. My objective function is
sum((Pot-Potcap).^2)
Pot = x(14)*exp(-(t*log(x(1)*x(15) + 1))/x(15)) + x(14)*(exp(-(t*log(x(3)*x(15) + 1))/x(15)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/(x(2) - x(3)) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(3))*(x(2) - x(3)))) + x(14)*(exp(-(t*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/(x(3) - x(4)) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) - x(13)*(exp(-(t*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) + x(14)*(exp(-(t*log(x(2)*x(15) + 1))/x(15)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/(x(1) - x(2))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4))*(x(3) - x(5)))/(x(8)*x(9)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(3))*(x(2) - x(3)))) - x(13)*((exp(-(t*log(x(4)*x(15) + 1))/x(15))*(x(4) - x(5)))/x(9) + (x(8)*exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/(x(9)*(x(3) - x(4))) + (x(7)*x(8)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4)))/(x(4) - x(5)) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) + x(14)*(exp(-(t*log(x(5)*x(15) + 1))/x(15)) + (x(9)*exp(-(t*log(x(4)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(8)*x(9)*exp(-(t*log(x(3)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(7)*x(8)*x(9)*exp(-(t*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*x(9)*exp(-(t*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(5))*(x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(13)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/x(9) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(2)))) + x(12)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(2)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3)))) - x(11)*((exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4))*(x(2) - x(5)))/(x(7)*x(8)*x(9)) + (x(6)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)*(x(1) - x(2)))) - x(13)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(3))*(x(2) - x(3)))) + x(12)*((exp(-(t*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*x(7)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) - (x(13)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/x(9) + (x(12)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) - (x(11)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(10)*exp(-(t*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(6)*x(7)*x(8)*x(9))
for the data Potcap and t from 1 to 21. I have tried using the code:
x = sym('x', [1 15], 'real')
t = [1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21]
x0 = [0.2;0.21;0.22;0.23;0.24;0.31;0.32;0.33;0.34;0.1;0.1;0.1;0.1;0.1;0.3]
lb = zeros(21,1)
ub = [Inf Inf Inf Inf Inf Inf Inf Inf Inf 1 1 1 1 1 Inf]
fnc = #(x) Fungsi(x,t,Potcap);
[p,fval] = fmincon(fnc,x0,[],[],[],[],lb,ub,#mycon)
function f = Fungsi(x, t, Potcap)
f = sum(((x(14)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)) + x(14)*(exp(-(t.*log(x(3)*x(15) + 1))/x(15)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/(x(2) - x(3)) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(3))*(x(2) - x(3)))) + x(14)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(3) - x(4)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) - x(13)*(exp(-(t.*log(x(4)*x(15) + 1))/x(15)) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) + x(14)*(exp(-(t.*log(x(2)*x(15) + 1))/x(15)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/(x(1) - x(2))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4))*(x(3) - x(5)))/(x(8)*x(9)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(3))*(x(2) - x(3)))) - x(13)*((exp(-(t.*log(x(4)*x(15) + 1))/x(15))*(x(4) - x(5)))/x(9) + (x(8)*exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/(x(9)*(x(3) - x(4))) + (x(7)*x(8)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(6)*x(7)*x(8)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(4))*(x(2) - x(4))*(x(3) - x(4)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(4)))/(x(4) - x(5)) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4)))/((x(3) - x(5))*(x(4) - x(5))) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) + x(14)*(exp(-(t.*log(x(5)*x(15) + 1))/x(15)) + (x(9)*exp(-(t.*log(x(4)*x(15) + 1))/x(15)))/(x(4) - x(5)) + (x(8)*x(9)*exp(-(t.*log(x(3)*x(15) + 1))/x(15)))/((x(3) - x(5))*(x(4) - x(5))) + (x(7)*x(8)*x(9)*exp(-(t.*log(x(2)*x(15) + 1))/x(15)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(6)*x(7)*x(8)*x(9)*exp(-(t.*log(x(1)*x(15) + 1))/x(15)))/((x(1) - x(5))*(x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5)))) - x(13)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/x(9) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(2)))) + x(12)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(1) - x(2)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(4))*(x(2) - x(5)))/(x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3)))) - x(11)*((exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(3))*(x(2) - x(4))*(x(2) - x(5)))/(x(7)*x(8)*x(9)) + (x(6)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)*(x(1) - x(2)))) - x(13)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(2) - x(3))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(1) - x(3))*(x(2) - x(3)))) + x(12)*((exp(-(t.*log(x(3)*x(15) + 1))/x(15))*(x(3) - x(5)))/x(9) + (x(7)*exp(-(t.*log(x(2)*x(15) + 1))/x(15))*(x(2) - x(5)))/(x(9)*(x(3) - x(4))) + (x(6)*x(7)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4)))) - (x(13)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(5)))/x(9) + (x(12)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(5)))/(x(9)*(x(2) - x(4))*(x(3) - x(4))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4)))/((x(2) - x(5))*(x(3) - x(5))*(x(4) - x(5))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) - (x(11)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(7)*x(8)*x(9)) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(4))*(x(1) - x(5)))/(x(8)*x(9)*(x(2) - x(3))) + (x(10)*exp(-(t.*log(x(1)*x(15) + 1))/x(15))*(x(1) - x(2))*(x(1) - x(3))*(x(1) - x(4))*(x(1) - x(5)))/(x(6)*x(7)*x(8)*x(9)))-Potcap).^2);
end
function [c,ceq] = mycon(x)
c = []
ceq = (x(10)+x(11)+x(12)+x(13)+x(14))==1
end
But running the code above meets an error saying "FMINCON requires all values returned by
functions to be of data type double". I have tried many things to fix this error but it still persists. Any suggestions for the problem I have or alternatives to using the code above? Thanks.
Edit
The code works by fixing the mistake in syntax for ceq so function #mycon reads as:
function [c,ceq] = mycon(x)
c = [];
ceq = (x(10)+x(11)+x(12)+x(13)+x(14))-1;
end
But now the problem is the outcome is unexpectedly large. MATLAB also prints:
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.715224e-17.
Any ideas on how to fix this?
Consider the following code :
T01 = [cos(t1) -sin(t1)*cos(alpha1) sin(alpha1)*sin(t1) a1*cos(t1);sin(t1) cos(t1)*cos(alpha1) -cos(alpha1)*sin(t1) a1*sin(t1);0 sin(alpha1) cos(alpha1) d1 ;0 0 0 1];
T12 = [cos(t2) -sin(t2)*cos(alpha2) sin(alpha2)*sin(t2) a2*cos(t2);sin(t2) cos(t2)*cos(alpha2) -cos(alpha2)*sin(t2) a2*sin(t2);0 sin(alpha2) cos(alpha2) d2 ;0 0 0 1];
T23 = [cos(t3) -sin(t3)*cos(alpha3) sin(alpha3)*sin(t3) a3*cos(t3);sin(t3) cos(t3)*cos(alpha3) -cos(alpha3)*sin(t3) a3*sin(t3);0 sin(alpha3) cos(alpha3) d3 ;0 0 0 1];
T34 = [cos(t4) -sin(t4)*cos(alpha4) sin(alpha4)*sin(t4) a4*cos(t4);sin(t4) cos(t4)*cos(alpha4) -cos(alpha4)*sin(t4) a4*sin(t4);0 sin(alpha4) cos(alpha4) d4 ;0 0 0 1];
T45 = [cos(t5) -sin(t5)*cos(alpha5) sin(alpha5)*sin(t5) a5*cos(t5);sin(t5) cos(t5)*cos(alpha5) -cos(alpha5)*sin(t5) a5*sin(t5);0 sin(alpha5) cos(alpha5) d5 ;0 0 0 1];
T56 = [cos(t6) -sin(t6)*cos(alpha6) sin(alpha6)*sin(t6) a6*cos(t6);sin(t6) cos(t6)*cos(alpha6) -cos(alpha6)*sin(t6) a6*sin(t6);0 sin(alpha6) cos(alpha6) d6 ;0 0 0 1];
T= T01*T12*T23*T34*T45*T56 ;
vect = [T(1,4);T(2,4);T(3,4)];
tet= [t1;t2;t3;t4;t5;t6];
J=jacobian(vect,tet);
XYZinit=[x;y;z];
H=pinv(J);
qCible=(tet+(H*(vect-XYZinit)))*180.0/pi;
In this case the program takes too long calculating the qCible.
I had a look on the Jacobian and it was very complex having "4967757600021511/405648192073033408478945025720320" and more !
Is there any way to make Matlab simplify these numbers to 3 digits after the decimal point.
P.S this is for exemple the 2nd line of the Jacobian matrix:
[ (667495948725283505644223413159337121101697927362615132085977267803570842210039392837475731450497*cos(t1))/66749594872528440074844428317798503581334516323645399060845050244444366430645017188217565216768000 + (180182749026672061615969125490030497260998891573948681728240766153*cos(t1)*sin(t2))/822752278660603021077484591278675252491367932816789931674304512000 + (23859816081157487611247053147082199287638984338758594710122908873*sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064))/822752278660603021077484591278675252491367932816789931674304512000 + (895104220870018647914711647235873838858522473234640872822096410779044699920717183*sin(t1)*sin(t2))/66749594872528440074844428317798503581334516323645399060845050244444366430645017188217565216768000 - (4967757600021511*sin(t5)*(cos(t1)*sin(t2) - (4967757600021511*cos(t1))/81129638414606681695789005144064 + sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064 - (4967757600021511*cos(t4)*(cos(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/81129638414606681695789005144064 + (4967757600021511*sin(t4)*(sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/81129638414606681695789005144064))/405648192073033408478945025720320 - (21*cos(t4)*(sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/1000 - (17277797851872663442627176416851563336929412302080901873592316727*sin(t4)*(cos(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/822752278660603021077484591278675252491367932816789931674304512000 - (4967757600021511*sin(t4)*(sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/405648192073033408478945025720320 + (sin(t5)*(cos(t4)*(sin(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))) + sin(t4)*(cos(t3)*(cos(t1) + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)))))/5 + (19*cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)))/100, (sin(t5)*(cos(t4)*(sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))) + sin(t4)*(cos(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)))))/5 - (895104220870018647914711647235873838858522473234640872822096410779044699920717183*cos(t1)*cos(t2))/66749594872528440074844428317798503581334516323645399060845050244444366430645017188217565216768000 + (180182749026672061615969125490030497260998891573948681728240766153*cos(t2)*sin(t1))/822752278660603021077484591278675252491367932816789931674304512000 - (4967757600021511*sin(t5)*(cos(t2)*sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - (4967757600021511*cos(t4)*(cos(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/81129638414606681695789005144064 + (4967757600021511*sin(t4)*(sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/81129638414606681695789005144064))/405648192073033408478945025720320 + (23859816081157487611247053147082199287638984338758594710122908873*sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064))/822752278660603021077484591278675252491367932816789931674304512000 - (21*cos(t4)*(sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/1000 - (17277797851872663442627176416851563336929412302080901873592316727*sin(t4)*(cos(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/822752278660603021077484591278675252491367932816789931674304512000 - (4967757600021511*sin(t4)*(sin(t3)*((4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 + (4967757600021511*cos(t2)*sin(t1))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2))))/405648192073033408478945025720320 + (19*cos(t3)*(cos(t1)*cos(t2) - sin(t1)*sin(t2)))/100, (23859816081157487611247053147082199287638984338758594710122908873*cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064))/822752278660603021077484591278675252491367932816789931674304512000 - (4967757600021511*sin(t5)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + (4967757600021511*cos(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064 + (4967757600021511*sin(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064))/405648192073033408478945025720320 - (21*cos(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/1000 - (4967757600021511*sin(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/405648192073033408478945025720320 + (17277797851872663442627176416851563336929412302080901873592316727*sin(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/822752278660603021077484591278675252491367932816789931674304512000 - (19*sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))/100 + (sin(t5)*(cos(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))) - sin(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))))/5, (21*sin(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/1000 - (17277797851872663442627176416851563336929412302080901873592316727*cos(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/822752278660603021077484591278675252491367932816789931674304512000 - (4967757600021511*cos(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/405648192073033408478945025720320 - (4967757600021511*sin(t5)*((4967757600021511*cos(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064 + (4967757600021511*sin(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064))/405648192073033408478945025720320 + (sin(t5)*(cos(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))) - sin(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))))/5, (4967757600021511*cos(t5)*((4967757600021511*sin(t1))/81129638414606681695789005144064 + (4967757600021511*cos(t1)*sin(t2))/81129638414606681695789005144064 - sin(t1)*sin(t2) - sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + (4967757600021511*cos(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064 - (4967757600021511*sin(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))))/81129638414606681695789005144064))/405648192073033408478945025720320 + (cos(t5)*(cos(t4)*(sin(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) - cos(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1))) + sin(t4)*(cos(t3)*(sin(t1) - (4967757600021511*cos(t1)*cos(t2))/81129638414606681695789005144064 + (4967757600021511*sin(t1)*sin(t2))/81129638414606681695789005144064) + sin(t3)*(cos(t1)*sin(t2) + cos(t2)*sin(t1)))))/5, 0]
For the variable representation concern, using double to get a floating point view instead of rational. For example if a = sym('4967757600021511/405648192073033408478945025720320'); you can make it double like double(a) which is shown like 1.2246e-17.
Update
As the question is updated by adding an example, you can do this in symbolic expressions using vpa similar to double for the previous part. For instance, if the name of the symbolic expression is a you can use vpa(a, 3).
I'm trying to solve a system of 3 equations with 3 variables in matlab.
Here's the matlab code:
clear;
close all;
clc;
syms x y z
eq1 = 30 - ((30*sin(y) + (6032463447834141*(30*cos(y)*sin(x) - (30*sin(y)*((139651314883359*cos(y)*sin(x))/140737488355328 + (10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(72057594037927936*(((842441452475839123526592959619*cos(y)*sin(x))/10141204801825835211973625643008 + (30162317239170705*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/571740979893939208192 + (18097390343502423*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/285870489946969604096)/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) + 3888617886914517/36028797018963968)))*((12*15869^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/15869 - (139651314883359*cos(x)*cos(y))/140737488355328 + (10*15869^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) - 30*cos(x)*cos(y) == -(8922777075240197*(30*cos(y)*sin(x) - (30*sin(y)*((139651314883359*cos(y)*sin(x))/140737488355328 + (10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(9007199254740992*(((842441452475839123526592959619*cos(y)*sin(x))/10141204801825835211973625643008 + (30162317239170705*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/571740979893939208192 + (18097390343502423*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/285870489946969604096)/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) + 3888617886914517/36028797018963968));
eq2 = ((30*sin(y) - (2751313666748167*(30*cos(y)*sin(x) + (30*sin(y)*((10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 - (139651314883359*cos(y)*sin(x))/140737488355328 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(36028797018963968*(((13756568333740835*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/285870489946969604096 - (384224571217937317986432052953*cos(y)*sin(x))/5070602400912917605986812821504 + (8253941000244501*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/142935244973484802048)/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 1085710309166423/18014398509481984)))*((139651314883359*cos(x)*cos(y))/140737488355328 + (12*15869^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/15869 + (10*15869^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 30*cos(x)*cos(y) + 30 == -(8964476491404667*(30*cos(y)*sin(x) + (30*sin(y)*((10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 - (139651314883359*cos(y)*sin(x))/140737488355328 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(9007199254740992*(((13756568333740835*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/285870489946969604096 - (384224571217937317986432052953*cos(y)*sin(x))/5070602400912917605986812821504 + (8253941000244501*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/142935244973484802048)/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 1085710309166423/18014398509481984));
eq3 = 30 - ((30*sin(y) - (5869842550983837*(30*cos(y)*sin(x) + (30*sin(y)*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)))/(72057594037927936*((5869842550983837*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/(72057594037927936*((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)) + 7567579956186207/72057594037927936)))*((278913769878129*cos(x)*cos(y))/281474976710656 + (12*13469^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/13469 - (10*13469^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469) - 30*cos(x)*cos(y) == (8927287469964123*(30*cos(y)*sin(x) + (30*sin(y)*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)))/(9007199254740992*((5869842550983837*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/(72057594037927936*((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)) + 7567579956186207/72057594037927936));
equation_3_angles(1) = eq1;
equation_3_angles(2) = eq2;
equation_3_angles(3) = eq3;
fprintf('Trying to solve the equations (the function never finish)\n');
[x_solution, y_solution, z_solution] = solve(equation_3_angles,[x, y, z]);
The solve function never finishes.. So I can't get the solution.
There are solutions for the equations above.
The solutions are
(x,y,z)=(0,0,0)
(x,y,z)=(0.523598775598299, 0, 0)
But I need to get these solutions mathematically.
How can I do that?
Thanks
I tried to solve them numerically with this script:
x0=[0.1 0.1 0.1]
sol=fsolve(#fun,x0)
function[obj]=fun(xx)
Calling this function
function[obj]=fun(xx)
x=xx(1);
y=xx(2);
z=xx(3);
eq1 = 30 - ((30*sin(y) + (6032463447834141*(30*cos(y)*sin(x) - (30*sin(y)*((139651314883359*cos(y)*sin(x))/140737488355328 + (10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(72057594037927936*(((842441452475839123526592959619*cos(y)*sin(x))/10141204801825835211973625643008 + (30162317239170705*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/571740979893939208192 + (18097390343502423*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/285870489946969604096)/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) + 3888617886914517/36028797018963968)))*((12*15869^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/15869 - (139651314883359*cos(x)*cos(y))/140737488355328 + (10*15869^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) - 30*cos(x)*cos(y) -( -(8922777075240197*(30*cos(y)*sin(x) - (30*sin(y)*((139651314883359*cos(y)*sin(x))/140737488355328 + (10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(9007199254740992*(((842441452475839123526592959619*cos(y)*sin(x))/10141204801825835211973625643008 + (30162317239170705*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/571740979893939208192 + (18097390343502423*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/285870489946969604096)/((139651314883359*sin(y))/140737488355328 - (10*15869^(1/2)*cos(y)*cos(z))/15869 + (12*15869^(1/2)*cos(y)*sin(z))/15869) + 3888617886914517/36028797018963968)));
eq2 = ((30*sin(y) - (2751313666748167*(30*cos(y)*sin(x) + (30*sin(y)*((10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 - (139651314883359*cos(y)*sin(x))/140737488355328 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(36028797018963968*(((13756568333740835*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/285870489946969604096 - (384224571217937317986432052953*cos(y)*sin(x))/5070602400912917605986812821504 + (8253941000244501*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/142935244973484802048)/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 1085710309166423/18014398509481984)))*((139651314883359*cos(x)*cos(y))/140737488355328 + (12*15869^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/15869 + (10*15869^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 30*cos(x)*cos(y) + 30 -( -(8964476491404667*(30*cos(y)*sin(x) + (30*sin(y)*((10*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/15869 - (139651314883359*cos(y)*sin(x))/140737488355328 + (12*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/15869))/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869)))/(9007199254740992*(((13756568333740835*15869^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/285870489946969604096 - (384224571217937317986432052953*cos(y)*sin(x))/5070602400912917605986812821504 + (8253941000244501*15869^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/142935244973484802048)/((139651314883359*sin(y))/140737488355328 + (10*15869^(1/2)*cos(y)*cos(z))/15869 - (12*15869^(1/2)*cos(y)*sin(z))/15869) - 1085710309166423/18014398509481984)));
eq3 = 30 - ((30*sin(y) - (5869842550983837*(30*cos(y)*sin(x) + (30*sin(y)*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)))/(72057594037927936*((5869842550983837*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/(72057594037927936*((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)) + 7567579956186207/72057594037927936)))*((278913769878129*cos(x)*cos(y))/281474976710656 + (12*13469^(1/2)*(cos(z)*sin(x) + cos(x)*sin(y)*sin(z)))/13469 - (10*13469^(1/2)*(sin(x)*sin(z) - cos(x)*cos(z)*sin(y)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469) - 30*cos(x)*cos(y) -( (8927287469964123*(30*cos(y)*sin(x) + (30*sin(y)*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)))/(9007199254740992*((5869842550983837*((278913769878129*cos(y)*sin(x))/281474976710656 + (10*13469^(1/2)*(cos(x)*sin(z) + cos(z)*sin(x)*sin(y)))/13469 - (12*13469^(1/2)*(cos(x)*cos(z) - sin(x)*sin(y)*sin(z)))/13469))/(72057594037927936*((10*13469^(1/2)*cos(y)*cos(z))/13469 - (278913769878129*sin(y))/281474976710656 + (12*13469^(1/2)*cos(y)*sin(z))/13469)) + 7567579956186207/72057594037927936)));
obj=[eq1;eq2;eq3]
end
This is what I got, as expected
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
sol =
0.5236 0.0000 0.0000
If you use x0=[0 0 0] as seed, the result is (as expected):
sol =
0 0 0
But, the solution is extremely dependant of the initial guess (seed). For example, for x0=[1 1 1] the result is:
sol =
-2.2063 3.0245 3.1109
In order to find the possible solutions, you can modify the script to perform a sweep like this:
n=5; %You can change this value for trying more points
x0=linspace(0,2*pi,n)
y0=linspace(0,2*pi,n)
z0=linspace(0,2*pi,n)
sol=zeros(n^3,3);
fval=zeros(n^3,3);
fval_flag=ones(n^3,1);
c=0;
for i=1:n
for j=1:n
for k=1:n
c=c+1;
[sol(c,:),fval(c,:)]=fsolve(#fun,[x0(i) y0(j) z0(k)]);
%Check if the function evaluation is larger than 1e-6 because
%this might not be a solution and set a flag
if any(fval(c,:)>1e-6)
fval_flag(c)=0;
end
end
end
end
%Get only the solutions from 0 to 2*pi. This will list all the rows with
%this condition
[row,col]=find(sol<0 | sol>2*pi);
%Sort and get the unique rows with wrong values
row=unique(sort(row));
%Create a copy of the solution and remove this rows from the solution
sol2=sol;
sol2(row,:)=[];
fval_flag(row)=[];
%Show and compare the obtained solutions with its flag values (is the 4th
%column is 0 then it might not be a solution
out=[sol2 fval_flag]
This will remove the possible solutions outside the range [0 2*pi] and will show you the solutions for x,y,a and also a flag showing a 0 with values that are possibly not a solution because the equations are not close enought to 0 (I used a tolerance varue of 1e-6).
I am trying to solve the following equation numerically under Matlab2014b environment.However matlab does not output numerically solutions, it instead output the following
>>solve(1/beta(13,11)*x^(12)*(1-x)^(10)==1.8839,x)
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[1]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[1]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[2]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[2]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[3]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[3]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[4]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[4]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[5]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[5]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[6]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[6]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[7]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[7]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[8]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[8]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[9]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[9]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[10]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[10]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 - (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[11]
RootOf(z^11 - 5*z^10 + 10*z^9 - 10*z^8 + 5*z^7 - z^6 + (4096*10^(1/2)*3342794185613871913^(1/2))/66540040320887625, z)[11]
On the other hand, I have no problem of solving the equation with Wolframmath.
I am wondering what cause the problem, it may worth noting that the equation does have complex solution but I am only interested in the solution between 0 and 1.
I encountered the same problem just now and I think I've found the solution.
From the information I get, MATLAB does this sometime to simply the representation of a analytic solution. To evaluate the solutions, simply call vpafunction. Here is a minimal reproduction and solution.
syms x
solve(x^5 + x + 7)
The result will be like
ans =
RootOf(z^5 + z + 7, z)[1]
RootOf(z^5 + z + 7, z)[2]
RootOf(z^5 + z + 7, z)[3]
RootOf(z^5 + z + 7, z)[4]
RootOf(z^5 + z + 7, z)[5]
Simply try
vpa(ans)
Then the numerical result will show:
ans =
-1.4108138510595771319852918753499
- 0.5084694089730227818822736708423 + 1.3686164883298987835863274173391i
- 0.5084694089730227818822736708423 - 1.3686164883298987835863274173391i
1.2138763345028113478749196085173 + 0.92418811092205120320563065825557i
1.2138763345028113478749196085173 - 0.92418811092205120320563065825557i
See MATLAB documentation for detail:
http://au.mathworks.com/help/symbolic/solve.html#zmw57dd0e111869
I have a system of 6 equations in 6 unknowns and I am trying to solve it using fsolve. A strange thing arises though. When I keep 6 in eq's in 6 un's as they are and call fsolve they solver does not converge and is very slow. But when I reduce equations in 5 with 6 unknowns (I can do this by substituting one of my equations in the rest) and by using the 'levenberg-marquardt' the solver converges really fast and reaches a solution. While the solutions I get are good I am not sure if they are correct and I cannot understand why this happens. I also tried to set as initial values in the 6x6 case the solution I got from the 5x6 case but again the fsolve is not converging. I don't know if it is a mathematical problem or fsolve's problem
Any thoughts?
Thank you
p.s I am not posting the code, it is really big, My system is first written in symbolic and then i substitute symbolic variables with numeric so as to solve it with fsolve.
function f=examplegeneral(x);
beta11=0.5; beta12=0.5; beta21=0.5; beta22=0.5; b11=0.5; b12=0.5; b21=0.5; b22=0.5; v1=0.5; v2=0.5;
f(1)=x(2)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^beta12 - v1*(b12*x(1)^2 + b11)^(1/2) - x(2)*(x(4) + x(6))*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 1);
f(2)=x(3)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^beta22 - v2*(b22*x(1)^2 + b21)^(1/2) - x(3)*(x(5) + x(6))*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 1);
f(3)=(x(2)*(x(4) + x(6))*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 - (x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2)*((b12*x(1)*v1)/(b12*x(1)^2 + b11)^(1/2) - x(2)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 1) + (x(2)*(x(4) + x(6))*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12))/(beta12*((b12^2*x(1)^2*v1)/(b12*x(1)^2 + b11)^(3/2) - (b22*v2)/(b22*x(1)^2 + b21)^(1/2) - (b12*v1)/(b12*x(1)^2 + b11)^(1/2) + (b22^2*x(1)^2*v2)/(b22*x(1)^2 + b21)^(3/2) + (x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22));
f(4)=(x(3)*(x(5) + x(6))*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22 - (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2)*((b22*x(1)*v2)/(b22*x(1)^2 + b21)^(1/2) - x(3)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 1) + (x(3)*(x(5) + x(6))*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22))/(beta22*((b12^2*x(1)^2*v1)/(b12*x(1)^2 + b11)^(3/2) - (b22*v2)/(b22*x(1)^2 + b21)^(1/2) - (b12*v1)/(b12*x(1)^2 + b11)^(1/2) + (b22^2*x(1)^2*v2)/(b22*x(1)^2 + b21)^(3/2) + (x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22));
f(5)=(x(2)*(x(4) + x(6))*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 - (((x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22)*((x(2)*(x(4) + x(6))*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(x(5) + x(6))*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22))/((b12^2*x(1)^2*v1)/(b12*x(1)^2 + b11)^(3/2) - (b22*v2)/(b22*x(1)^2 + b21)^(1/2) - (b12*v1)/(b12*x(1)^2 + b11)^(1/2) + (b22^2*x(1)^2*v2)/(b22*x(1)^2 + b21)^(3/2) + (x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22) + (x(3)*(x(5) + x(6))*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22;
f(6)=1/((b12^2*x(1)^2*v1)/(b12*x(1)^2 + b11)^(3/2) - (b22*v2)/(b22*x(1)^2 + b21)^(1/2) - (b12*v1)/(b12*x(1)^2 + b11)^(1/2) + (b22^2*x(1)^2*v2)/(b22*x(1)^2 + b21)^(3/2) + (x(2)*(beta12 - 1)*(1/beta11)^beta11*((x(1) + x(4) + x(6))/beta12)^(beta12 - 2))/beta12 + (x(3)*(beta22 - 1)*(1/beta21)^beta21*((x(1) + x(5) + x(6))/beta22)^(beta22 - 2))/beta22);
and then i call
x0=[0.8,0.05,0.05,0.01,0.01,-0.01]; % This is the vector of initial values.
options = optimset('Display','iter','MaxFunEvals',1e+15,'MaxIter',1000000000);
[sol,exitflag,fval]=fsolve('examplegeneral',x0,options)