Hello.
I have 8 residual functions in 3 variables.?
I was able to find a least-squares solution using minpack_lsquares.
But when I tried to solve the same problem using minpack_solve it choked.? I squared each of the 8 residual functions and added them to get a single objective function.? Then I created three equations (in 3 unknowns) from that by taking the partial derivative with respect to each of the three variables and setting the result equal to zero.? minpack_solve choked on this.
Here is the macro:
-----------------begin macro------------------------
kill(all)$
load("minpack")$
L: 30$? W:24$
sFR: 0.66146087960253$
sFL: 0.96813559654012$
sRL: 0.74997966956141$
sRR: 0.25042656950073$
aFR: 1.183014673400058$
aFL: 0.6847789579122$
aRL: -0.016464555187806$
aRR: -0.049325965088199$
R: sqrt(L^2+W^2)$ Lr: L/R$? Wr: W/R$
RCW: omega*(R/2)$
A: STR-RCW*(Lr)$? B: STR+RCW*(Lr)$?? C: FWD-RCW*(Wr)$?? D: FWD+RCW*(Wr)$
sFR_: sqrt(B^2+C^2)$ sFL_: sqrt(B^2+D^2)$ sRL_: sqrt(A^2+D^2)$ sRR_: sqrt(A^2+C^2)$
aFR_: atan2(B,C)$ aFL_: atan2(B,D)$ aRL_: atan2(A,D)$ aRR_: atan2(A,C)$
s1: sFR_-sFR$ s2: sFL_-sFL$ s3: sRL_-sRL$ s4: sRR_-sRR$
a1: aFR_-aFR$ a2: aFL_-aFL$ a3: aRL_-aRL$ a4: aRR_-aRR$
function_list: [s1,s2,s3,s4,a1,a2,a3,a4]$
minpack_lsquares(function_list,[FWD,STR,omega],[.5,.5,.5]);
obf: s1^2+s2^2+s3^2+s4^2+a1^2+a2^2+a3^2+a4^2$
eqs: [diff(obf,FWD)=0,diff(obf,STR)=0,diff(obf,omega)=0]$
minpack_solve(eqs,[FWD,STR,omega],[.5,.5,.5]);
-----------------end macro--------------------------
Here is the output from maxima (notice the minpack_lsquares solution at line %o37, and the minpack_solve error following line %i40:
---------------begin maxima output-------------------------
Maxima 5.24.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (a.k.a. GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1)
read and interpret file: #pE:/My Documents/Maxima/z2.mac
(%i2)????????????????????????????? kill(all)
(%i1)??????????????????????????? load(minpack)
[bunch of loading statements snipped here]
(%i2)?????????????????????????????? L : 30
(%i3)?????????????????????????????? W : 24
(%i4)?????????????????????? sFR : 0.66146087960253
(%i5)?????????????????????? sFL : 0.96813559654012
(%i6)?????????????????????? sRL : 0.74997966956141
(%i7)?????????????????????? sRR : 0.25042656950073
(%i8)?????????????????????? aFR : 1.183014673400058
(%i9)??????????????????????? aFL : 0.6847789579122
(%i10)???????????????????? aRL : - 0.016464555187806
(%i11)???????????????????? aRR : - 0.049325965088199
???????????????????????????????????????? 2??? 2
(%i12)???????????????????????? R : sqrt(W? + L )
???????????????????????????????????????? L
(%i13)????????????????????????????? Lr : -
???????????????????????????????????????? R
???????????????????????????????????????? W
(%i14)????????????????????????????? Wr : -
???????????????????????????????????????? R
?????????????????????????????????????? omega R
(%i15)?????????????????????????? RCW : -------
????????????????????????????????????????? 2
(%i16)???????????????????????? A : STR - RCW Lr
(%i17)???????????????????????? B : RCW Lr + STR
(%i18)???????????????????????? C : FWD - RCW Wr
(%i19)???????????????????????? D : RCW Wr + FWD
????????????????????????????????????????? 2??? 2
(%i20)?????????????????????? sFR_ : sqrt(C? + B )
????????????????????????????????????????? 2??? 2
(%i21)?????????????????????? sFL_ : sqrt(D? + B )
????????????????????????????????????????? 2??? 2
(%i22)?????????????????????? sRL_ : sqrt(D? + A )
????????????????????????????????????????? 2??? 2
(%i23)?????????????????????? sRR_ : sqrt(C? + A )
(%i24)??????????????????????? aFR_ : atan2(B, C)
(%i25)??????????????????????? aFL_ : atan2(B, D)
(%i26)??????????????????????? aRL_ : atan2(A, D)
(%i27)??????????????????????? aRR_ : atan2(A, C)
(%i28)????????????????????????? s1 : sFR_ - sFR
(%i29)????????????????????????? s2 : sFL_ - sFL
(%i30)????????????????????????? s3 : sRL_ - sRL
(%i31)????????????????????????? s4 : sRR_ - sRR
(%i32)????????????????????????? a1 : aFR_ - aFR
(%i33)????????????????????????? a2 : aFL_ - aFL
(%i34)????????????????????????? a3 : aRL_ - aRL
(%i35)????????????????????????? a4 : aRR_ - aRR
(%i36)???????? function_list : [s1, s2, s3, s4, a1, a2, a3, a4]
(%i37) minpack_lsquares(function_list, [FWD, STR, omega], [0.5, 0.5, 0.5])
(%o37)??? [[0.5, 0.3, 0.020823168251814], 3.6871652560846944E-15, 2]
????????????????????? 2???? 2???? 2???? 2???? 2???? 2???? 2???? 2
(%i38)??????? obf : a4? + a3? + a2? + a1? + s4? + s3? + s2? + s1
(%i39) eqs : [diff(obf, FWD) = 0, diff(obf, STR) = 0, diff(obf, omega) = 0]
(%i40)????? minpack_solve(eqs, [FWD, STR, omega], [0.5, 0.5, 0.5])
Maxima encountered a Lisp error:
?Error in FUNCALL [or a callee]: ((MEQUAL SIMP) 2.1084356996122464 0.0) is not of type (OR
??????????????????????????????????????????????????????????????????????????????????????? RATIONAL
??????????????????????????????????????????????????????????????????????????????????????? LISP:FLOAT).
Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i42)
---------------------end maxima output----------------------------