All 32 roots I come up with are complex:
10 gosub *Solve(1,12,30)
20
30 end
40
50 *Solve(A,B,C)
60 local Discr,S1,S2
70 Lvl=Lvl+1
80 Discr=B*B-4*A*C
90 ' print Lvl,A;B;C,Discr *** commented out
100 Vr=sqrt(Discr)
110 S1=(-B+Vr)/(2*A)
120 S2=(-B-Vr)/(2*A)
130 if Lvl=5 then
140 :print S1:print S2:Ct=Ct+1:if Ct=20 then stop:endif
150 :else
160 :gosub *Solve(A,B,C-S1)
170 :gosub *Solve(A,B,C-S2)
180 :endif
190 Lvl=Lvl-1
200 return
finds only complex roots:
-5.4337966242328360727+3.7493538961007307981#i
-6.5662033757671639272-3.7493538961007307981#i
-6.188973078708025133+3.7774983525195429567#i
-5.8110269212919748669-3.7774983525195429567#i
-5.8110269212919748669+3.7774983525195429567#i
-6.188973078708025133-3.7774983525195429567#i
-6.5662033757671639272+3.7493538961007307981#i
-5.4337966242328360727-3.7493538961007307981#i
-5.3240048974464779996+4.1515168142615801486#i
-6.6759951025535220003-4.1515168142615801486#i
-6.1303046988704467333+4.1797184724222352339#i
-5.8696953011295532666-4.1797184724222352339#i
-5.8696953011295532666+4.1797184724222352339#i
-6.1303046988704467333-4.1797184724222352339#i
-6.6759951025535220003+4.1515168142615801486#i
-5.3240048974464779996-4.1515168142615801486#i
-5.0824381722026647137+4.5205183160058492112#i
-6.9175618277973352862-4.5205183160058492112#i
-5.9262028894512874294+4.557972442820659469#i
-6.0737971105487125704-4.557972442820659469#i
-5.7285077637707018706+4.5790350095257359616#i
-6.2714922362292981293-4.5790350095257359616#i
-6.5685969932212068322+4.5677757184654518396#i
-5.4314030067787931676-4.5677757184654518396#i
-5.4314030067787931676+4.5677757184654518396#i
-6.5685969932212068322-4.5677757184654518396#i
-6.2714922362292981293+4.5790350095257359616#i
-5.7285077637707018706-4.5790350095257359616#i
-6.0737971105487125704+4.557972442820659469#i
-5.9262028894512874294-4.557972442820659469#i
-6.9175618277973352862+4.5205183160058492112#i
-5.0824381722026647137-4.5205183160058492112#i
The program solves the quadratic, and then adjusts the constant term so that zeros of the new quadratic give each of the respective solutions to the level of quadratic above it.
leading me to think maybe I did something wrong.
However, I tried it out for g(g(x))=0, just two levels of depth:
10 gosub *Solve(1,12,30)
20
30 end
40
50 *Solve(A,B,C)
60 local Discr,S1,S2
70 Lvl=Lvl+1
80 Discr=B*B-4*A*C
90 ' print Lvl,A;B;C,Discr
100 Vr=sqrt(Discr)
110 S1=(-B+Vr)/(2*A)
120 S2=(-B-Vr)/(2*A)
130 if Lvl=2 then
140 :print S1:print S2:Ct=Ct+1:if Ct=20 then stop:endif
150 :else
160 :gosub *Solve(A,B,C-S1)
170 :gosub *Solve(A,B,C-S2)
180 :endif
190 Lvl=Lvl-1
200 return
and it found two real and two complex roots of g(g(x))=0:
-4.4349154199267126834
-7.5650845800732873165
-6.0+1.5650845800732873165#i
-6.0-1.5650845800732873165#i
and the real roots check out:
x=-4.4349154199267126834
OK
g=x*x+12*x+30
OK
?g
-3.5505102572168219016
OK
g2=g*g+12*g+30
OK
?g2
0.0000000000000000009
OK
x=-7.565084580073287316
OK
g=x*x+12*x+30
OK
?g
-3.5505102572168219021
OK
g2=g*g+12*g+30
OK
?g2
-0.0000000000000000017
So it seems to be doing things right, and I'd have to say g(g(g(g(g(x)))))=0 has no real roots.
However, if the original function had been
g(x) = x^2 + 12x - 30
(note the minus sign)
there would be a full 32 real solutions:
10 gosub *Solve(1,12,-30)
20
30 end
40
50 *Solve(A,B,C)
60 local Discr,S1,S2
70 Lvl=Lvl+1
80 Discr=B*B-4*A*C
90 ' print Lvl,A;B;C,Discr
100 Vr=sqrt(Discr)
110 S1=(-B+Vr)/(2*A)
120 S2=(-B-Vr)/(2*A)
130 if Lvl=5 then
140 :print S1:print S2:Ct=Ct+1:if Ct @ 20=0 then stop:endif
150 :else
160 :gosub *Solve(A,B,C-S1)
170 :gosub *Solve(A,B,C-S2)
180 :endif
190 Lvl=Lvl-1
200 return
producing
2.677399691665285459
-14.677399691665285459
1.6312882598378428108
-13.6312882598378428108
1.5809745966989474563
-13.5809745966989474563
0.5196676985597539179
-12.5196676985597539179
1.5259742917976827729
-13.5259742917976827729
0.4637148358327976046
-12.4637148358327976046
0.3950793798219034847
-12.3950793798219034847
-0.6929952144349964636
-11.3070047855650035362
1.4657314834117522766
-13.4657314834117522766
0.4024029320764603025
-12.4024029320764603025
0.3325451712275664461
-12.3325451712275664461
-0.7574056280321333741
-11.2425943719678666258
0.2552881821114838044
-12.2552881821114838044
-0.837065006880782983
-11.1629349931192170169
-0.9405459485938334381
-11.0594540514061665618
-2.0870400591764160871
-9.9129599408235839128
or for g(x) = x^2 - 12x + 30, a different set of 32 real roots:
12.8633893949020836151
-0.8633893949020836151
11.9366969009730132938
0.0633030990269867061
12.0298218903769117385
-0.0298218903769117385
11.1277399156478250752
0.8722600843521749247
12.1561696742637786903
-0.1561696742637786903
11.2496198741050014649
0.750380125894998535
11.3737396376610935879
0.626260362338906412
10.5009947362442789044
1.4990052637557210955
12.3513552190559084179
-0.3513552190559084179
11.4384840842875927878
0.561515915712407212
11.5526152716569331958
0.4473847283430668041
10.6706790040363506325
1.3293209959636493674
11.7165864386738978124
0.2834135613261021875
10.8270756307408749844
1.1729243692591250155
10.9793771085997968736
1.0206228914002031263
10.1311336270934386736
1.8688663729065613263
|
Posted by Charlie
on 2013-11-04 15:53:00 |