# Is my calculation too complex for Matlab?

2 vues (au cours des 30 derniers jours)
Krystian Meresinski le 28 Avr 2013
Through few operations I have come up to equation of certain complexity and I wonder if that's the reason why my Matlab is evaluating the cell with them for what seems like eternity. Code goes as listed below:
y1 = (1/200)*(-2*cos(q1)*(67*cos(q2+q3)-68*sin(q2)+26)-sqrt(2)-52);
y2 = (1/200)*(-2*sin(q1)*(67*cos(q2+q3)-68*sin(q2)+26)-23);
y3 = (1/200)*(-134*cos(q2)-134*sin(q3)*cos(q2)-134*sin(q2)*cos(q3)-sqrt(2));
rozw=solve(y1,y2,y3,'q1,q2,q3');
y1/y2/y3 are already simplified with Wolfram, so I don't think it will get any shorter that that.
My question: is it possible that those equations are too complex, or the problem lies somewhere else?
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Walter Roberson le 29 Avr 2013
Note: the solution involves the root of a polynomial of order 8. 4 of the roots are entirely real-valued, and the other 4 roots have some imaginary components. The roots repeat every 2*Pi

Connectez-vous pour commenter.

### Réponses (3)

Bjorn Gustavsson le 28 Avr 2013
Your qs are all arguments to sin and cos (if in see it right), since they are periodic your equations seem bound to have an infinite number of solutions. My guess is that causes your problem. Try to find a solution in a bounded region. If you try some numberical solution you should be able to do this versy easily with fminsearchbnd that you can find on the file exchange.
HTH
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Krystian Meresinski le 28 Avr 2013
The problem is most likely connected with the boundaries, you're right. Do you have any suggestions what methods can I use to set them? I tried to go over fminsearchbnd, but it's a little bit complex and, frankly, my academic project shouldn't require to use such sophisticadet tools.
If this will help, the topic of the project is on robotics and this script is calculating an inverse kinematics for my manipulator, so it is supposed to have few solutions. Still, my q1, q2 and q3 have obviously some physical boundaries

Connectez-vous pour commenter.

Adam Filion le 28 Avr 2013
As Bjorn mentioned, since they're periodic they may have many solutions. However if I remember the solve command right, I think you are defining q1,q2,q3 as a single variable. Try this:
syms q1 q2 q3
y1 = (1/200)*(-2*cos(q1)*(67*cos(q2+q3)-68*sin(q2)+26)-sqrt(2)-52);
y2 = (1/200)*(-2*sin(q1)*(67*cos(q2+q3)-68*sin(q2)+26)-23);
y3 = (1/200)*(-134*cos(q2)-134*sin(q3)*cos(q2)-134*sin(q2)*cos(q3)-sqrt(2));
[q1a,q2a,q3a]=solve(y1,y2,y3,q1,q2,q3);
Does this get the solutions you expect?
##### 3 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Adam Filion le 28 Avr 2013
Just to make sure it's clear, my point was when you enclose names in single quotes, it gets treated as a single variable. Removing the quotes makes it treat them as three separate variables.
Krystian Meresinski le 28 Avr 2013
I later got those anwsers with
q1_1 = rozw.q1;
q3_1 = rozw.q3;
q2_1 = rozw.q2;
It's taken from my script, so I don't think that this causes the problem.

Connectez-vous pour commenter.

Walter Roberson le 29 Avr 2013
Let
V = RootOf(85030560000*z^8 - 8908683264000*z^7 + (-4421831731200*sqrt(2) + 214255955347200)*z^6 + (233354220503040*sqrt(2) + 1008527591485440)*z^5 + (410857748248064*sqrt(2) + 866389716008288)*z^4 + (-426241914781696*sqrt(2) - 1179433923146752)*z^3 + (74232159520896*sqrt(2) + 108438997734896)*z^2 + (111966437303552 + 7779762591744*sqrt(2))*z - 20046506997903 - 605605313248*sqrt(2), z)
Then,
q1 = arctan(((4418478714164777376633212570056241307780101240613239031682220043474 - 10000750813923041604857182299632826492081968935049348079797421277580 * V + 6641285118241981986734824458402563495961979847377161133655520000 * V^7 - 693642691263999482525721030969847314040404154194716592910300368000 * V^6 + 17104864637745845991044743435542862230347108380107903653490536049600 * V^5 + 52850052021842465901974744809458667431123350185934150089233611257440 * V^4 + 29784151119258989085875778707162336415093547335454274782336804980752 * V^3 - 24223848570456083685746615886897364531861184372838261913275545755160 * V^2) * 2^(1/2) - 8860259899587451191765004614222084280962397833790778353317017013595 - 29235056058574601225667262672280714207436367244073460386410882964000 * V^5 + 18914480443756691087173017616247435369702902241591835578178446023122 * V + 67594482641525801846484211302659801659894898448508905155833703670828 * V^2 - 11477338587929814805362751547400620106314464177238171288291760000 * V^7 - 86192064969550472079943929501627732501868401007509023377495481832392 * V^3 + 1198888873733443209680946524876415019068056696014791074991865224000 * V^6 - 108855748997697249969285633433558989929612885022714614881200843280080 * V^4) / ((9604375358129607495354871696900107118417515942525984838876453271611 - 21788024429575716189800020085419980096459107929607576720490759148306 * V + 14516064676550141239341222621284029638422108168972791637469360000 * V^7 - 1516110046608457820941589003719810665697085187917846598101902344000 * V^6 + 37400778482791712622115625911997744424809272544414675199786825722400 * V^5 + 114754215484265694649278308550360509412556579332428747380823780091600 * V^4 + 63590599705735520016765067968296250481869393932004924578435581615944 * V^3 - 51828071435747415209232165861565354521603769084307857144978029373804 * V^2) * 2^(1/2) - 19647676406531213357326687599975473912803673255473652013440019331304 - 64609268946538590076200355308152670188086820866591484034190645305600 * V^5 + 41893542671630515361881850062852216793060303421420728430681928289008 * V + 150715886966018675158508076346283259010904884807686371490295717364032 * V^2 - 25371262449385495908930149197740309501583833805288286292341760000 * V^7 - 192279090268613329129797077246535539881172598161720028959351801970560 * V^3 + 2650214610939610779928599010071038537541658255842595770163321344000 * V^6 - 241512993210285742026039280388093484412070579165621377114955505567360 * V^4)) - pi
q2 = arctan(1548664623565618533458841205354311084167552 * V / ((20668276109234989810755787214028560975530523 - 66160549165293473426199219911528915058162144 * V + 38083741907496754076292771751832444160000 * V^7 - 3974048562484512788240460664988053818264000 * V^6 + 96079036514496149512059237915919459516915200 * V^5 + 397745309074093917100744533329159097419373840 * V^4 + 390016886141745258752644118388821794950992768 * V^3 - 191752166116947294412990890797958454559795092 * V^2) * 2^(1/2) - 18492025632347385527070665562918504409564768 - 34363330213053367330099431823448985600000 * V^7 + 47262084094955439234267674658750668119681024 * V + 3586164635204137086524700149969031231360000 * V^6 - 76453342847564026440991592581039151549212672 * V^3 - 89077127570708429864419717200345513311846400 * V^5 - 235120047484182736697555572339702989611166720 * V^4 + 68051947264193584356039180454674806657646016 * V^2)) + pi
q3 = arctan((( - 5736565808571571558307786757940909771008351828363451832754364380 + 12988079816139804367645475093738211800635671766697256986811104616 * V - 8674789639850665032666530170014246858989060713443241304640000 * V^7 + 906021947557988569915633303460986406311600128370564523604576000 * V^6 - 22356968432997446923165838907037010393069832203829331814019868800 * V^5 - 68234092449226261061486297200249098541207092378347317798129584960 * V^4 - 37321213806335437116644877734087898639800515760901679711527341792 * V^3 + 30468245505594013223381172347263983979674483299358919743595648464 * V^2) * 2^(1/2) + 18276480621056946434712795067120230119257769372255303641935876926 + 116730659969028542969203701090702791418312476281526027352094086448 * V^3 - 25287493674518664427965784584519409438117673821861323801554245516 * V + 145969437955335174866146929240352574952960522237785504293318594080 * V^4 + 15291424709995652140273704402385277001311547923035254362400000 * V^7 - 1597300279925136710862243748029606777876569355388308270938640000 * V^6 - 91342071511667812223902978720793934239209255592073070940724728344 * V^2 + 38932581839861494916551727948217049724851924565809859967416145600 * V^5) / ((103695484123177216361776040797584670254019303086153113740281364333 - 295295981382445951870957497994076193975657517598881421690347312270 * V + 179683840784129423635419287427409302240212831552425658683440000 * V^7 - 18754119293253271183900072974753582907387125809757934945209096000 * V^6 + 453896958948529144233540810011223092522356251035565800637388399200 * V^5 + 1858098938395561471835206055714562343589008143527938971863272458480 * V^4 + 1773062841221982445834660480594879300269870135879881625803744437224 * V^3 - 954342079422193265909654249989543207984823397809113041205348360060 * V^2) * 2^(1/2) - 92660853719228348167295707496166975861886296891314535798912440688 - 392313722232707030884526201029561794176364324197684179502319257984 * V^3 + 235205263679678560470171845606768688369928815733419145539532341664 * V - 1142102837876917940024503580704530264030208655356912478338142588160 * V^4 - 165236306924969869073633347518315148615920049042622297099520000 * V^7 + 17246883252004210836376363302132953232827084046761956355280768000 * V^6 + 345234574491154054718133348458955522041457379700741804875427884096 * V^2 - 428259710393306321614875427576076089403622285093593799093330240000 * V^5)) - pi
Sorry, the coefficients are not completely sorted.
Each power has two coefficients, above, one a rational fraction and the other a rational fraction multiplied by sqrt(2).
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Common Operations dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by