I am trying to reframe a polynomial equation using MATLAB. For example I have the following polynomial equation:
758622.2445*x2+-418477.9101*x2^2+27.50552059*x1-29.66792273*x1*x2+7.993937155*x1*x2^2-0.01387653551*x1^2+0.007688875184*x1^2*x2+-458420.9152*1+9.035554275e-08*x1^3+76949.5016*x2^3=y
I want to rewrite this equation to find x1 with respect to x2 and y. Is there a way in MATLAB that I can do this?
Regards,
Vivekram
You can do it with symbolic maths:
syms x1 x2 y
eq=758622.2445*x2+-418477.9101*x2^2+27.50552059*x1-29.66792273*x1*x2+7.993937155*x1*x2^2-0.01387653551*x1^2+0.007688875184*x1^2*x2+-458420.9152*1+9.035554275e-08*x1^3+76949.5016*x2^3-y; %note the "-y"
Then solve for x1:
answers=solve(eq,'x1');
This gives a somehow slightly impractical answer:
((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)/((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3) - (290477491679118196736*x2)/10240607678978289 + ((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3) + 524240689526195486720/10240607678978289
524240689526195486720/10240607678978289 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)/(2*((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3)) - (3^(1/2)*(((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)/((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3) - ((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3))*i)/2 - ((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3)/2 - (290477491679118196736*x2)/10240607678978289
524240689526195486720/10240607678978289 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)/(2*((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3)) + (3^(1/2)*(((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)/((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3) - ((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3))*i)/2 - ((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 + (((18889465931478580854784*y)/3413535892992763 - (14329969042344564774680920064*x2)/3413535892992763 - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^2 - ((373607477110716017672192*x2)/3413535892992763 + ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^2/9 - (100667469031835544059904*x2^2)/3413535892992763 - 1039129188224775258898432/10240607678978289)^3)^(1/2) - ((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)^3/27 + (((290477491679118196736*x2)/3413535892992763 - 524240689526195486720/3413535892992763)*((302002407095506632179712*x2^2)/3413535892992763 - (1120822431332148053016576*x2)/3413535892992763 + 1039129188224775258898432/3413535892992763))/6 + (7904824225910305924958912512*x2^2)/3413535892992763 - (1453534988917456608983777280*x2^3)/3413535892992763 + 8659326259947631308263391232/3413535892992763)^(1/3)/2 - (290477491679118196736*x2)/10240607678978289
You can try to simplify it, not really short anyway:
(4096*2^(1/3)*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 - 837973096065059809422718597962663861885373484944680*x2 + 21619843983901197262960457263110232492474368*y + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3))/10240607678978289 - (290477491679118196736*x2)/10240607678978289 + (2^(2/3)*(9922422485720215904809854396879785984*x2^2 - 35776652619913349559784336713660694528*x2 + 32249387965150852164297978842759315456))/(10240607678978289*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(21619843983901197262960457263110232492474368*y - 837973096065059809422718597962663861885373484944680*x2 + 464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3)) + 524240689526195486720/10240607678978289
524240689526195486720/10240607678978289 - (2048*2^(1/3)*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 - 837973096065059809422718597962663861885373484944680*x2 + 21619843983901197262960457263110232492474368*y + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3))/10240607678978289 - (2^(2/3)*3^(1/2)*16124693982575426082148989421379657728*i - 2^(1/3)*3^(1/2)*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 - 837973096065059809422718597962663861885373484944680*x2 + 21619843983901197262960457263110232492474368*y + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(2/3)*2048*i - 2^(2/3)*3^(1/2)*x2*17888326309956674779892168356830347264*i + 2^(2/3)*3^(1/2)*x2^2*4961211242860107952404927198439892992*i)/(10240607678978289*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(21619843983901197262960457263110232492474368*y - 837973096065059809422718597962663861885373484944680*x2 + 464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3)) - (2^(2/3)*(4961211242860107952404927198439892992*x2^2 - 17888326309956674779892168356830347264*x2 + 16124693982575426082148989421379657728))/(10240607678978289*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(21619843983901197262960457263110232492474368*y - 837973096065059809422718597962663861885373484944680*x2 + 464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3)) - (290477491679118196736*x2)/10240607678978289
524240689526195486720/10240607678978289 - (2048*2^(1/3)*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 - 837973096065059809422718597962663861885373484944680*x2 + 21619843983901197262960457263110232492474368*y + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3))/10240607678978289 + (2^(2/3)*3^(1/2)*16124693982575426082148989421379657728*i - 2^(1/3)*3^(1/2)*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 - 837973096065059809422718597962663861885373484944680*x2 + 21619843983901197262960457263110232492474368*y + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(2/3)*2048*i - 2^(2/3)*3^(1/2)*x2*17888326309956674779892168356830347264*i + 2^(2/3)*3^(1/2)*x2^2*4961211242860107952404927198439892992*i)/(10240607678978289*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(21619843983901197262960457263110232492474368*y - 837973096065059809422718597962663861885373484944680*x2 + 464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3)) - (2^(2/3)*(4961211242860107952404927198439892992*x2^2 - 17888326309956674779892168356830347264*x2 + 16124693982575426082148989421379657728))/(10240607678978289*(43239687967802394525920914526220464984948736*y - 1675946192130119618845437195925327723770746969889360*x2 + 929545073270215159552834175230731008239003999989360*x2^2 - 171853986154027941742866902559669863546308859847142*x2^3 + 2^(1/2)*(2*(21619843983901197262960457263110232492474368*y - 837973096065059809422718597962663861885373484944680*x2 + 464772536635107579776417087615365504119501999994680*x2^2 - 85926993077013970871433451279834931773154429923571*x2^3 + 503614772788955588295591518904028047560511199495004)^2 - (2422466427177787086135218358613229*x2^2 - 8734534331033532607369222830483568*x2 + 7873385733679407266674311240908036)^3)^(1/2) + 1007229545577911176591183037808056095121022398990008)^(1/3)) - (290477491679118196736*x2)/10240607678978289
Related
My problem is that my app has been crashing since iOS 13. The app doesn't work on any iPhone anymore. A bit strange, however, is that the iPhone simulators on iOS 13 all work fine. Here is the output of the lldb console after I type bt:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48)
frame #0: 0x00000001b952d268 AVFAudio`-[AVAudioPlayer(AVAudioPlayerPriv) privRemoveSessionListener] + 16
frame #1: 0x00000001b952b9ac AVFAudio`-[AVAudioPlayer dealloc] + 32
frame #2: 0x0000000100dae9e4 Ducko`#objc StartView.__ivar_destroyer(self=0x0000000101e2de70) at startView.swift:0
frame #3: 0x00000001ac8c01e8 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 112
frame #4: 0x00000001ac8d2d14 libobjc.A.dylib`objc_destructInstance + 88
frame #5: 0x00000001ac8d9db8 libobjc.A.dylib`_objc_rootDealloc + 48
frame #6: 0x00000001b0bd19b8 UIKitCore`-[UIResponder dealloc] + 152
frame #7: 0x00000001e1a40900 UIKit`-[UIResponderAccessibility dealloc] + 60
frame #8: 0x00000001c528e93c SpriteKit`-[SKNode dealloc] + 100
frame #9: 0x00000001c52461dc SpriteKit`-[SKScene dealloc] + 332
frame #10: 0x00000001c526bf54 SpriteKit`-[SKView _update:] + 568
frame #11: 0x00000001c526761c SpriteKit`__51-[SKView _vsyncRenderForTime:preRender:postRender:]_block_invoke.340 + 388
frame #12: 0x00000001c5266a1c SpriteKit`-[SKView _vsyncRenderForTime:preRender:postRender:] + 520
frame #13: 0x00000001c5269bd0 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 200
frame #14: 0x00000001c52ac180 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 132
frame #15: 0x0000000101c715f8 GPUToolsCore`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168
frame #16: 0x00000001b33dd514 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632
frame #17: 0x00000001b34a7774 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 264
frame #18: 0x00000001acaed6d4 CoreFoundation`__CFMachPortPerform + 172
frame #19: 0x00000001acb16e5c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
frame #20: 0x00000001acb16588 CoreFoundation`__CFRunLoopDoSource1 + 444
frame #21: 0x00000001acb1145c CoreFoundation`__CFRunLoopRun + 2168
frame #22: 0x00000001acb108bc CoreFoundation`CFRunLoopRunSpecific + 464
frame #23: 0x00000001b697b328 GraphicsServices`GSEventRunModal + 104
frame #24: 0x00000001b0ba56d4 UIKitCore`UIApplicationMain + 1936
* frame #25: 0x0000000100d777c8 Ducko`main at AppDelegate.swift:14:7
frame #26: 0x00000001ac99b460 libdyld.dylib`start + 4
(lldb) * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x48)
frame #0: 0x00000001b952d268 AVFAudio`-[AVAudioPlayer(AVAudioPlayerPriv) privRemoveSessionListener] + 16
frame #1: 0x00000001b952b9ac AVFAudio`-[AVAudioPlayer dealloc] + 32
frame #2: 0x0000000100dae9e4 Ducko`#objc StartView.__ivar_destroyer(self=0x0000000101e2de70) at startView.swift:0
frame #3: 0x00000001ac8c01e8 libobjc.A.dylib`object_cxxDestructFromClass(objc_object*, objc_class*) + 112
frame #4: 0x00000001ac8d2d14 libobjc.A.dylib`objc_destructInstance + 88
frame #5: 0x00000001ac8d9db8 libobjc.A.dylib`_objc_rootDealloc + 48
frame #6: 0x00000001b0bd19b8 UIKitCore`-[UIResponder dealloc] + 152
frame #7: 0x00000001e1a40900 UIKit`-[UIResponderAccessibility dealloc] + 60
frame #8: 0x00000001c528e93c SpriteKit`-[SKNode dealloc] + 100
frame #9: 0x00000001c52461dc SpriteKit`-[SKScene dealloc] + 332
frame #10: 0x00000001c526bf54 SpriteKit`-[SKView _update:] + 568
frame #11: 0x00000001c526761c SpriteKit`__51-[SKView _vsyncRenderForTime:preRender:postRender:]_block_invoke.340 + 388
frame #12: 0x00000001c5266a1c SpriteKit`-[SKView _vsyncRenderForTime:preRender:postRender:] + 520
frame #13: 0x00000001c5269bd0 SpriteKit`__29-[SKView setUpRenderCallback]_block_invoke + 200
frame #14: 0x00000001c52ac180 SpriteKit`-[SKDisplayLink _callbackForNextFrame:] + 132
frame #15: 0x0000000101c715f8 GPUToolsCore`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168
frame #16: 0x00000001b33dd514 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632
frame #17: 0x00000001b34a7774 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 264
frame #18: 0x00000001acaed6d4 CoreFoundation`__CFMachPortPerform + 172
frame #19: 0x00000001acb16e5c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
frame #20: 0x00000001acb16588 CoreFoundation`__CFRunLoopDoSource1 + 444
frame #21: 0x00000001acb1145c CoreFoundation`__CFRunLoopRun + 2168
frame #22: 0x00000001acb108bc CoreFoundation`CFRunLoopRunSpecific + 464
frame #23: 0x00000001b697b328 GraphicsServices`GSEventRunModal + 104
frame #24: 0x00000001b0ba56d4 UIKitCore`UIApplicationMain + 1936 * frame #25: 0x0000000100d777c8 Ducko`main at AppDelegate.swift:14:7
frame #26: 0x00000001ac99b460 libdyld.dylib`start + 4
Does anyone have any idea how to fix the problem? I don't know where to start.
I am implementing the LinkedIn sign in using UIWebView
Here is my code
import UIKit
typealias LinkedInLoginCallBack = ([String:String]?,String,Error?) -> Void
class LinkedInWebViewController: UIViewController,UIWebViewDelegate {
#IBOutlet weak var linkedinWebView: UIWebView!
#IBOutlet weak var indicator: UIActivityIndicatorView!
var userDidLogin:LinkedInLoginCallBack!
let linkedInKey = "xxxx"
let linkedInSecret = "xxxx"
let authorizationEndPoint = "https://www.linkedin.com/uas/oauth2/authorization"
let accessTokenEndPoint = "https://www.linkedin.com/uas/oauth2/accessToken"
override func viewDidLoad() {
super.viewDidLoad()
linkedinWebView.delegate = self
self.startAuthorization()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func startAuthorization() {
let responseType = "code"
let redirectURL = "https://example.com/login/check-linkedin".addingPercentEncoding(withAllowedCharacters: .urlFragmentAllowed)!
let state = "xxxxx"
let scope = "r_basicprofile,r_emailaddress"
var authorizationURL = "\(authorizationEndPoint)?"
authorizationURL += "response_type=\(responseType)&"
authorizationURL += "client_id=\(linkedInKey)&"
authorizationURL += "redirect_uri=\(redirectURL)&"
authorizationURL += "state=\(state)&"
authorizationURL += "scope=\(scope)"
// logout already logined user or revoke tokens
logout()
// Create a URL request and load it in the web view.
let request = URLRequest(url: URL(string: authorizationURL)!)
linkedinWebView.loadRequest(request)
}
func logout(){
let revokeUrl = "https://api.linkedin.com/uas/oauth/invalidateToken"
let request = URLRequest(url: URL(string: revokeUrl)!)
linkedinWebView.loadRequest(request)
}
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
let url = request.url!
if url.host == "https://example.com/login/check-linkedin" {
if url.absoluteString.range(of: "code") != nil {
let urlParts = url.absoluteString.components(separatedBy: "?")
let code = urlParts[1].components(separatedBy: "=")[1]
requestForAccessToken(authorizationCode: code)
}
}
return true
}
func webViewDidStartLoad(_ webView: UIWebView) {
indicator.startAnimating()
}
func webViewDidFinishLoad(_ webView: UIWebView) {
indicator.stopAnimating()
}
func requestForAccessToken(authorizationCode: String) {
let grantType = "authorization_code"
let redirectURL = "https://example.com/login/check-linkedin".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
// Set the POST parameters.
var postParams = "grant_type=\(grantType)&"
postParams += "code=\(authorizationCode)&"
postParams += "redirect_uri=\(redirectURL)&"
postParams += "client_id=\(linkedInKey)&"
postParams += "client_secret=\(linkedInSecret)"
// Convert the POST parameters into a NSData object.
let postData = postParams.data(using: String.Encoding.utf8)
// Initialize a mutable URL request object using the access token endpoint URL string.
let request = NSMutableURLRequest(url: NSURL(string: accessTokenEndPoint)! as URL)
// Indicate that we're about to make a POST request.
request.httpMethod = "POST"
// Set the HTTP body using the postData object created above.
request.httpBody = postData
// Add the required HTTP header field.
request.addValue("application/x-www-form-urlencoded;", forHTTPHeaderField: "Content-Type")
// Initialize a NSURLSession object.
let session = URLSession(configuration: URLSessionConfiguration.default)
// Make the request.
let task: URLSessionDataTask = session.dataTask(with: request as URLRequest) { (data, response, error) -> Void in
// Get the HTTP status code of the request.
let statusCode = (response as! HTTPURLResponse).statusCode
if statusCode == 200 {
// Convert the received JSON data into a dictionary.
do {
let dataDictionary = try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
print("dataDictionary\(dataDictionary)")
let accessToken = dataDictionary["access_token"] as! String
var socialAuth:[String:String] = [String:String]()
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_TYPE] = SocialMediaType.instagram.rawValue
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_ID] = dataDictionary["username"] as? String
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_TOKEN] = accessToken
socialAuth[SignupAPIController.KEY_PARAM_SOCIAL_RTOKEN] = accessToken
socialAuth["name"] = dataDictionary["full_name"] as? String
socialAuth["email"] = dataDictionary["username"] as? String
self.userDidLogin(socialAuth,accessToken,nil)
DispatchQueue.main.async {
self.dismiss(animated: true, completion: nil)
}
} catch {
print("Could not convert JSON data into a dictionary.")
}
}else{
print("cancel clicked")
}
}
task.resume()
}
}
But don't know it crashes my app after some time because of the below error
thread #20, name = 'WebThread', stop reason = EXC_BAD_ACCESS (code=1, address=0x2ffffff6b)
Here it is my stack trace
(lldb) bt
* thread #16, name = 'WebThread', stop reason = EXC_BAD_ACCESS (code=1, address=0x2ffffff6b)
* frame #0: 0x000000018fda66e4 JavaScriptCore`llint_entry + 15716
frame #1: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #2: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #3: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #4: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #5: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #6: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #7: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #8: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #9: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #10: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #11: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #12: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #13: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #14: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #15: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #16: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #17: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #18: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #19: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #20: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #21: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #22: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #23: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #24: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #25: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #26: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #27: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #28: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #29: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #30: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #31: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #32: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #33: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #34: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #35: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #36: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #37: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #38: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #39: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #40: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #41: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #42: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #43: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #44: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #45: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #46: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #47: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #48: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #49: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #50: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #51: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #52: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #53: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #54: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #55: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #56: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #57: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #58: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #59: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #60: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #61: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #62: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #63: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #64: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #65: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #66: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #67: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #68: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #69: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #70: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #71: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #72: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #73: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #74: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #75: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #76: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #77: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #78: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #79: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #80: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #81: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #82: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #83: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #84: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #85: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #86: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #87: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #88: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #89: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #90: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #91: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #92: 0x000000018fda89d4 JavaScriptCore`llint_entry + 24660
frame #93: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #94: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #95: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #96: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #97: 0x000000018fca616c JavaScriptCore`JSC::boundThisNoArgsFunctionCall(JSC::ExecState*) + 448
frame #98: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #99: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #100: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #101: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #102: 0x000000018f6c75fc JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 352
frame #103: 0x000000018f93a2a8 JavaScriptCore`JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 164
frame #104: 0x0000000190340a10 WebCore`WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 992
frame #105: 0x00000001906748d8 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event&, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul>&) + 620
frame #106: 0x0000000190674588 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event&) + 328
frame #107: 0x000000019067442c WebCore`WebCore::EventTarget::dispatchEvent(WebCore::Event&) + 108
frame #108: 0x00000001906743ac WebCore`WebCore::EventTarget::dispatchEventForBindings(WebCore::Event*, int&) + 116
frame #109: 0x00000001909eb22c WebCore`WebCore::jsEventTargetPrototypeFunctionDispatchEvent(JSC::ExecState*) + 260
frame #110: 0x000000018fda9450 JavaScriptCore`llint_entry + 27344
frame #111: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #112: 0x000000018fda8a38 JavaScriptCore`llint_entry + 24760
frame #113: 0x000000018fda27b8 JavaScriptCore`vmEntryToJavaScript + 264
frame #114: 0x000000018fc75a88 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 168
frame #115: 0x000000018f6b0480 JavaScriptCore`JSC::Interpreter::execute(JSC::ProgramExecutable*, JSC::ExecState*, JSC::JSObject*) + 13724
frame #116: 0x000000018f9936f4 JavaScriptCore`JSC::evaluate(JSC::ExecState*, JSC::SourceCode const&, JSC::JSValue, WTF::NakedPtr<JSC::Exception>&) + 440
frame #117: 0x0000000190ec88a0 WebCore`WebCore::ScriptController::evaluateInWorld(WebCore::ScriptSourceCode const&, WebCore::DOMWrapperWorld&, WebCore::ExceptionDetails*) + 328
frame #118: 0x0000000190224c84 WebCore`WebCore::ScriptElement::executeScript(WebCore::ScriptSourceCode const&) + 612
frame #119: 0x00000001902a0448 WebCore`WebCore::HTMLScriptRunner::executePendingScriptAndDispatchEvent(WebCore::PendingScript&) + 212
frame #120: 0x000000019026b5a8 WebCore`WebCore::HTMLScriptRunner::executeScriptsWaitingForParsing() + 88
frame #121: 0x000000019078b53c WebCore`non-virtual thunk to WebCore::HTMLDocumentParser::notifyFinished(WebCore::CachedResource*) + 52
frame #122: 0x000000019029d8b8 WebCore`WebCore::CachedResource::checkNotify() + 448
frame #123: 0x000000019029d59c WebCore`WebCore::SubresourceLoader::didFinishLoading(double) + 1020
frame #124: 0x000000018c00e788 CFNetwork`__65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 80
frame #125: 0x000000018c00e718 CFNetwork`-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 200
frame #126: 0x000000018c00e88c CFNetwork`-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 56
frame #127: 0x000000018bf393dc CFNetwork`___ZN27URLConnectionClient_Classic23_delegate_cacheTrifectaEPK20_CFCachedURLResponseU13block_pointerFvvE_block_invoke + 576
frame #128: 0x000000018bf34960 CFNetwork`___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 108
frame #129: 0x00000001033e921c libdispatch.dylib`_dispatch_client_callout + 16
frame #130: 0x00000001033f3c9c libdispatch.dylib`_dispatch_block_invoke_direct + 400
frame #131: 0x000000018bfebeb4 CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 36
frame #132: 0x000000018b6a79a8 CoreFoundation`CFArrayApplyFunction + 68
frame #133: 0x000000018bfebd98 CFNetwork`RunloopBlockContext::perform() + 136
frame #134: 0x000000018bfed0c0 CFNetwork`MultiplexerSource::perform() + 312
frame #135: 0x000000018bfece2c CFNetwork`MultiplexerSource::_perform(void*) + 64
frame #136: 0x000000018b77c278 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #137: 0x000000018b77bbc0 CoreFoundation`__CFRunLoopDoSources0 + 524
frame #138: 0x000000018b7797c0 CoreFoundation`__CFRunLoopRun + 804
frame #139: 0x000000018b6a8048 CoreFoundation`CFRunLoopRunSpecific + 444
frame #140: 0x000000019025845c WebCore`RunWebThread(void*) + 456
frame #141: 0x000000018a864850 libsystem_pthread.dylib`_pthread_body + 240
frame #142: 0x000000018a864760 libsystem_pthread.dylib`_pthread_start + 284
frame #143: 0x000000018a861dac libsystem_pthread.dylib`thread_start + 4
I am trying to find the general formula of an inverse matrix of size 4 x 4. What I wrote is simply this:
A = [a b c d ; e f g h ; i l m n; o p q r];
inv(A)
However, the MATLAB console returns the following: undefined function or variable 'a'. How should I write the matrix to get the generic formula without putting in numeric values and doing this symbolically?
You are getting that error because those variables aren't defined in MATLAB... at least, not currently. You'll need to use the Symbolic Mathematics Toolbox for that. One way is to create each variable: a up to p using sym, create a 4 x 4 matrix of these variables, then find the inverse.
sym a b c d e f g h i j k l m n o p;
A = [a b c d; e f g h; i j k l; m n o p];
invA = inv(A);
However, that leads to bad coding. Defining all of those symbolic variables gets rather unwieldy. Instead, I would use sym to create a 4 x 4 matrix of variables that follow a numeric pattern, then go ahead and find the inverse of that:
>> A = sym('A%d%d', [4 4])
A =
[ A11, A12, A13, A14]
[ A21, A22, A23, A24]
[ A31, A32, A33, A34]
[ A41, A42, A43, A44]
>> invA = inv(A)
invA =
[ (A22*A33*A44 - A22*A34*A43 - A23*A32*A44 + A23*A34*A42 + A24*A32*A43 - A24*A33*A42)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A12*A33*A44 - A12*A34*A43 - A13*A32*A44 + A13*A34*A42 + A14*A32*A43 - A14*A33*A42)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A12*A23*A44 - A12*A24*A43 - A13*A22*A44 + A13*A24*A42 + A14*A22*A43 - A14*A23*A42)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A12*A23*A34 - A12*A24*A33 - A13*A22*A34 + A13*A24*A32 + A14*A22*A33 - A14*A23*A32)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41)]
[ -(A21*A33*A44 - A21*A34*A43 - A23*A31*A44 + A23*A34*A41 + A24*A31*A43 - A24*A33*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A11*A33*A44 - A11*A34*A43 - A13*A31*A44 + A13*A34*A41 + A14*A31*A43 - A14*A33*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A11*A23*A44 - A11*A24*A43 - A13*A21*A44 + A13*A24*A41 + A14*A21*A43 - A14*A23*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A11*A23*A34 - A11*A24*A33 - A13*A21*A34 + A13*A24*A31 + A14*A21*A33 - A14*A23*A31)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41)]
[ (A21*A32*A44 - A21*A34*A42 - A22*A31*A44 + A22*A34*A41 + A24*A31*A42 - A24*A32*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A11*A32*A44 - A11*A34*A42 - A12*A31*A44 + A12*A34*A41 + A14*A31*A42 - A14*A32*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A11*A22*A44 - A11*A24*A42 - A12*A21*A44 + A12*A24*A41 + A14*A21*A42 - A14*A22*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A11*A22*A34 - A11*A24*A32 - A12*A21*A34 + A12*A24*A31 + A14*A21*A32 - A14*A22*A31)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41)]
[ -(A21*A32*A43 - A21*A33*A42 - A22*A31*A43 + A22*A33*A41 + A23*A31*A42 - A23*A32*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A11*A32*A43 - A11*A33*A42 - A12*A31*A43 + A12*A33*A41 + A13*A31*A42 - A13*A32*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), -(A11*A22*A43 - A11*A23*A42 - A12*A21*A43 + A12*A23*A41 + A13*A21*A42 - A13*A22*A41)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41), (A11*A22*A33 - A11*A23*A32 - A12*A21*A33 + A12*A23*A31 + A13*A21*A32 - A13*A22*A31)/(A11*A22*A33*A44 - A11*A22*A34*A43 - A11*A23*A32*A44 + A11*A23*A34*A42 + A11*A24*A32*A43 - A11*A24*A33*A42 - A12*A21*A33*A44 + A12*A21*A34*A43 + A12*A23*A31*A44 - A12*A23*A34*A41 - A12*A24*A31*A43 + A12*A24*A33*A41 + A13*A21*A32*A44 - A13*A21*A34*A42 - A13*A22*A31*A44 + A13*A22*A34*A41 + A13*A24*A31*A42 - A13*A24*A32*A41 - A14*A21*A32*A43 + A14*A21*A33*A42 + A14*A22*A31*A43 - A14*A22*A33*A41 - A14*A23*A31*A42 + A14*A23*A32*A41)]
The notation here is that the first subscript denotes the row, and the second subscript denotes the column. Specifically Aij is the entry for row i and column j. I'll let you figure out the rest.
Hello I have to simplify the first expression which is from a 7 segment Display assignment.
upper case means it is a NOT so for example the first part ZYXW means NOT z AND NOT y AND NOT x AND NOT w. I hope that makes sense.
So the problem is i found the answer for the expression which simplifies to
a = z + x + yw + YW
however my simplification ends at a = zYX
bellow are the steps for my simplification, could someone identify the problem please.
a = ZYXW + ZYxW + ZYxw + ZyXw + ZyxW + Zyxw + zYXw + zYXW
a = ZYXW + ZYxW + ZYxw + ZyXw + ZyxW + Zyxw + zYX(w + W)
a = ZYXW + ZYxW + ZYxw + ZyXw + ZyxW + Zyxw + zYX(1)
a = ZYXW + ZYxW + ZYxw + ZyXw + ZyxW + Zyxw + zYX.1
a = ZYXW + ZYxW + ZYxw + ZyXw + ZyxW + Zyxw + zYX
a = ZYXW + ZYxW + ZYxw + ZyXw + Zyx(W + w) + zYX
a = ZYXW + ZYxW + ZYxw + ZyXw + Zyx(1) + zYX
a = ZYXW + ZYxW + ZYxw + ZyXw + Zyx.1 + zYX
a = ZYXW + ZYxW + ZYxw + ZyXw + Zyx + zYX
a = ZYW(X + x) + ZYxw + ZyXw + Zyx + zYX
a = ZYW(1) + ZYxw + ZyXw + Zyx + zYX
a = ZYW.1 + ZYxw + ZyXw + Zyx + zYX
a = ZYW + ZYxw + ZyXw + Zyx + zYX
a = ZYW + Zw(xY + Xy) + Zyx + zYX
a = ZYW + Zw(x.1 + X.1) + Zyx + zYX
a = ZYW + Zw(x + X) + Zyx + zYX
a = ZYW + Zw(1) + Zyx + zYX
a = ZYW + Zw.1 + Zyx + zYX
a = ZYW + Zw + Zyx + zYX
a = Z(YW + w + yz) + zYX
a = Z(Y.1 + yz) + zYX
a = Z(Y = yz) + zYX
a = Z(z) + zYX
a = Z + z + zYX
a = 1 + zYX
a = zYX
Hey I think this exercise is for using Karnaugh Maps. With those its quite simple. Just look here: Karnaugh Map Wiki
First you create a truth table, like the one at the start of this tutorial.
The 16 rows represent all combinations of your 4 variables. You get the result of a row, by comparing it to your function.
So 0 0 0 0 is equivalent to ZYXW and the solution would be 1 because ZYXW is in your function.
0 0 0 1 would be ZYXw which is not in your function, so the solution is 0.
0 0 1 0 would be ZYxW which is in your function, so the solution is 1.
Do this for all 16 rows. Then go ahead like in the
Tutorial.
I'm trying to find the eigenvectors of a symbolic 3x3 rotation matrix in MATLAB, it appears to work for some inputs but not all, for example:
A =
[ cos(q), -sin(q), 0]
[ sin(q), cos(q), 0]
[ 0, 0, 1]
[V,lambda]=eig(A)
V =
[ 0, -i, i]
[ 0, 1, 1]
[ 1, 0, 0]
lambda =
[ 1, 0, 0]
[ 0, cos(q) - sin(q)*i, 0]
[ 0, 0, cos(q) + sin(q)*i]
this works fine, however if I try something which is not a rotation about a unit axis (x,y,z) I get the following error:
A =
[ cos(q), -sin(q), 0]
[ 0, 0, -1]
[ sin(q), cos(q), 0]
>> [V,lambda]=eig(A)
Warning: basis of eigenspace for eigenvalue cos(q)/3 - (cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 +
(cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3)/2 + (cos(q)/3 - cos(q)^2/9)/(2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 +
((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/... [linalg::eigenvectors]
??? Error using ==> mupadmex
Error in MuPAD command: Unable to find explicit eigenvectors.
Error in ==> sym.sym>sym.mupadmexnout at 2003
out = mupadmex(fcn,args{:});
Error in ==> sym.eig at 68
[V,D,p] = mupadmexnout('mllib::eigenvectors',A);
I'm using the eigenvalues to find the axis of rotation of the matrix, and I need to use it for much more complicated systems
Any help would be appreciated.
Thanks
I am unable to reproduce the error (tested on MATLAB R2010b):
syms q
A = [cos(q) -sin(q) 0 ; 0 0 -1 ; sin(q) cos(q) 0]
[V,lambda] = eig(A)
I get the following (rather long) result:
A =
[ cos(q), -sin(q), 0]
[ 0, 0, -1]
[ sin(q), cos(q), 0]
V =
[ (3*cos(q)^2 + 4*cos(q)^3 + cos(q)^4 + 27*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(4/3) + 9*cos(q)*sin(q)^2 + 9*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) - 6*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 9*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 2*cos(q)^3*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 18*cos(q)*(cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))/(3*sin(q)*(cos(q)^2 - 3*cos(q) + 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 3*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3))*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)), (3*cos(q)^2 - 27*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(4/3)*i + 4*cos(q)^3 + cos(q)^4 + 27*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(4/3) + 9*cos(q)*sin(q)^2 - 18*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) - 6*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) - 18*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 2*cos(q)^3*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 3*3^(1/2)*cos(q)^2*i + 4*3^(1/2)*cos(q)^3*i + 3^(1/2)*cos(q)^4*i + 18*cos(q)*(cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2) + 6*3^(1/2)*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*i - 2*3^(1/2)*cos(q)^3*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*i + 18*3^(1/2)*cos(q)*(cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2)*i + 9*3^(1/2)*cos(q)*sin(q)^2*i)/(3*sin(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*(cos(q)^2 + 9*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3)*i - 3*cos(q) + 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) - 6*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 3*3^(1/2)*cos(q)*i - 3^(1/2)*cos(q)^2*i)), -(27*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(4/3)*i + 3*cos(q)^2 + 4*cos(q)^3 + cos(q)^4 + 27*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(4/3) + 9*cos(q)*sin(q)^2 - 18*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) - 6*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) - 18*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 2*cos(q)^3*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) - 3*3^(1/2)*cos(q)^2*i - 4*3^(1/2)*cos(q)^3*i - 3^(1/2)*cos(q)^4*i + 18*cos(q)*(cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2) - 6*3^(1/2)*cos(q)^2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*i + 2*3^(1/2)*cos(q)^3*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*i - 18*3^(1/2)*cos(q)*(cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2)*i - 9*3^(1/2)*cos(q)*sin(q)^2*i)/(3*sin(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)*(3*cos(q) + 9*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3)*i - cos(q)^2 - 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 6*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 3*3^(1/2)*cos(q)*i - 3^(1/2)*cos(q)^2*i))]
[ -(9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3))/(cos(q)^2 - 3*cos(q) + 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 3*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3)), (18*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3))/(cos(q)^2 + 9*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3)*i - 3*cos(q) + 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) - 6*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 3*3^(1/2)*cos(q)*i - 3^(1/2)*cos(q)^2*i), -(18*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3))/(3*cos(q) + 9*3^(1/2)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3)*i - cos(q)^2 - 9*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(2/3) + 6*cos(q)*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + (cos(q)^5/27 + (2*cos(q)^4)/27 + (cos(q)^3*sin(q)^2)/27 + cos(q)^3/27 + (cos(q)^2*sin(q)^2)/3 + sin(q)^4/4)^(1/2))^(1/3) + 3*3^(1/2)*cos(q)*i - 3^(1/2)*cos(q)^2*i)]
[ 1, 1, 1]
lambda =
[ cos(q)/3 + (cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3) - (cos(q)/3 - cos(q)^2/9)/(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3), 0, 0]
[ 0, cos(q)/3 - (cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3)/2 + (cos(q)/3 - cos(q)^2/9)/(2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3)) - (3^(1/2)*((cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3) + (cos(q)/3 - cos(q)^2/9)/(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3))*i)/2, 0]
[ 0, 0, cos(q)/3 - (cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3)/2 + (cos(q)/3 - cos(q)^2/9)/(2*(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3)) + (3^(1/2)*((cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3) + (cos(q)/3 - cos(q)^2/9)/(cos(q)^2/3 + cos(q)^3/27 + sin(q)^2/2 + ((cos(q)/3 - cos(q)^2/9)^3 + (cos(q)^3/27 + cos(q)^2/3 + sin(q)^2/2)^2)^(1/2))^(1/3))*i)/2]
The problematic example you gave is not a general rotation matrix, 1 is not an eigenvalue. See more here http://en.wikipedia.org/wiki/Rotation_matrix. This shouldn't affect the matlab function however, you are guaranteed a basis of generalized eigenvectors over the complex numbers. Do you have any more information about the error? I'm noticing some calls to symmetric matrix-based functions, have you tried calling eig with the option 'qz' to explicitly call the non-symmetric based algorithm?