Properties
Similar Topics
Statistics
Comments
6
Participants
4
Subscribers
0
Votes
1
Views
1683
Share
Invert matrix without "circular definition" error
Answered
I've got a matrix that displays in 3D,
https://www.geogebra.org/st...
and I'd like to add a button [Invert] to invert the matrix on the fly, but I get the "circular definition" error when I try M := Invert[M].
I tried making a new matrix MI = Invert[M], but all my graphics routines that draw the matrix are still defined with reference to the original matrix M, and neither can I assign M := MI, that too triggers "circular definition".
Is there a simple solution to this?
 GeoGebra
 Help
 Partners

Contact us
 Feedback & Questions
 This email address is being protected from spambots. You need JavaScript enabled to view it.
 +43 677 6137 2693
© 2022 International GeoGebra Institute
Hi,
If M is free, SetValue[M,invert[M]] work
But M isn't free object...then, SetValue[xmag,Elément[Mi,1,1]]....etc
https://ggbm.at/1388489
https://ggbm.at/1388491
M':reverse[M] M := Invert[M]
M':inversa[M]
e
Hi Patrick,
That worked perfectly for the inverse function, thank you very much!
But when I tried to create a "Transpose" button exactly the same way, that did NOT work!
I created MI = Invert[M] and MT = Transpose[M] which both show the correct values in the Algebra view.
When I click Invert everything works as expected. But when I click Transpose all three matrices get reset to the identity matrix!
Here is the On Click script for the Invert button, exactly as you suggested (thanks again!)
SetValue[xmag,Element[MI,1,1]]
SetValue[xymag,Element[MI,1,2]]
SetValue[xzmag,Element[MI,1,3]]
SetValue[yxmag,Element[MI,2,1]]
SetValue[ymag,Element[MI,2,2]]
SetValue[yzmag,Element[MI,2,3]]
SetValue[zxmag,Element[MI,3,1]]
SetValue[zymag,Element[MI,3,2]]
SetValue[zmag,Element[MI,3,3]]
And here is the On Click code for the Transpose button, done exactly the same way!
SetValue[xmag,Element[MT,1,1]]
SetValue[xymag,Element[MT,1,2]]
SetValue[xzmag,Element[MT,1,3]]
SetValue[yxmag,Element[MT,2,1]]
SetValue[ymag,Element[MT,2,2]]
SetValue[yzmag,Element[MT,2,3]]
SetValue[zxmag,Element[MT,3,1]]
SetValue[zymag,Element[MT,3,2]]
SetValue[zmag,Element[MT,3,3]]
I even tried doing the transpose "manually" from the original matrix M, i.e. just swapping i,j to j,i, ...
Save your work first.
Make a new check box; say b, with text label "Invert?"
Then use the input bar: "N = if[b, invert[M], M]".
Change your vectors to get their values from N using element[N, ,<row>, <column>] instead of referring back to the sliders.
(edited some mistakes)
Hi,
Michel said : "in the same time..." !!! :flushed:
thank you Michel : my first file inverseMatrice.ggb is wrong !
because command in script are execute one bye one...and M is degenerated...
In new version Mi and Mt are free objects and are not modified by the script when SetValue[xmag...
(Mii and Mtt are just here to verify...)
https://ggbm.at/1388495
Thank you timstudiesmath! That works perfectly!
And to add an Inverted checkbox as well as the Transposed checkbox I made a third invertedtransposed matrix MTI that depends on the transposed matrix MT that depends on the original matrix M.
M = {{A1, B1, C1}, {A2, B2, C2}, {A3, B3, C3}}
MT = If[checktransposed, Transpose[M], M]
MTI = If[checkinverted, Invert[MT], MT]
I'm beginning to understand the "chain of dependencies" idea in geogebra.
Thanks everyone for your help! Here is the result:
http://tube.geogebra.org/st...
Comments have been locked on this page!