Iteration/Rekursion im CAS abzubilden entspricht nicht gerade dem Hauptsatz der Informatik ([i]Schreibe effizienten, sparsamen und schnellen Code[/i]).[br][size=85]Eine einmal belegte Variable kann von nachfolgendem Code nicht überschrieben/geändert werden - eine Variable ändern heißt erzeuge eine neue Instanz/neue Variable. Ein Matrix-Element kann nicht per Indizes geändert/geschrieben werden sondern man muss eine Zeile Element für Element durchlaufen und eine neue Zeile/Matrix mit der Änderung erzeugen oder wie in diesem Beispiel die Änderungen an (unvollständige) Zeilen anhängen.[/size][br][br][math]\frac{p(x) \, := \, x^{6} - 5 \; x^{5} + 8 \; x^{4} - 2 \; x^{3} + x^{2} + 8 \; x - 6}{q(x) \, := \, x^{3} - 2 \; x^{2} + x - 1}[/math][br][br]Startmatrix H enthält einen Zähler H(1), die Koeffizientenzeilen (q höchster Koeffizient 1 nicht im Tableau vertreten) und die Summenzeile {1}. [br][br][math]\small H \, := \, \left\{ 1, \left\{ 0, 0, 0 \right\} , \left\{ 0, 0 \right\} , \left\{ 0 \right\} , \left\{ 1 \right\} \right\} [/math][br][br]Iteration [math]\Leftrightarrow[/math] IterationList(), entferne abschließendes Semikolon(;) in CAS-Zeile, zeigt die Abfolge in Hkern. Die Koeffizientenzeilen erweitern, [br]Zeile(1..3)+=cq(1...3) Last(Spalte(Zähler)) [br]und Aufsummieren der durch Zähler benannten Spalte + cp(Zähler):[br][br][math]\small Hkern \, := \, \left(\begin{array}{rrrrr}1& \left\{ 0, 0, 0 \right\} & \left\{ 0, 0 \right\} & \left\{ 0 \right\} & \left\{ 1 \right\} \\2& \left\{ 0, 0, 0, 1 \right\} & \left\{ 0, 0, -1 \right\} & \left\{ 0, 2 \right\} & \left\{ 1 \right\} \\2& \left\{ 0, 0, 0, 1 \right\} & \left\{ 0, 0, -1 \right\} & \left\{ 0, 2 \right\} & \left\{ 1, -3 \right\} \\3& \left\{ 0, 0, 0, 1, -3 \right\} & \left\{ 0, 0, -1, 3 \right\} & \left\{ 0, 2, -6 \right\} & \left\{ 1, -3 \right\} \\3& \left\{ 0, 0, 0, 1, -3 \right\} & \left\{ 0, 0, -1, 3 \right\} & \left\{ 0, 2, -6 \right\} & \left\{ 1, -3, 1 \right\} \\4& \left\{ 0, 0, 0, 1, -3, 1 \right\} & \left\{ 0, 0, -1, 3, -1 \right\} & \left\{ 0, 2, -6, 2 \right\} & \left\{ 1, -3, 1 \right\} \\4& \left\{ 0, 0, 0, 1, -3, 1 \right\} & \left\{ 0, 0, -1, 3, -1 \right\} & \left\{ 0, 2, -6, 2 \right\} & \left\{ 1, -3, 1, 4 \right\} \\5& \left\{ 0, 0, 0, 1, -3, 1, 4 \right\} & \left\{ 0, 0, -1, 3, -1, -4 \right\} & \left\{ 0, 2, -6, 2, 8 \right\} & \left\{ 1, -3, 1, 4 \right\} \\\end{array}\right)[/math][br][br]Hsum ergänzen der noch aufzusummierenden Spalten:[br][br][math]Hsum \, := \, \left(\begin{array}{rrrrr}5& \left\{ 0, 0, 0, 1, -3, 1, 4 \right\} & \left\{ 0, 0, -1, 3, -1, -4 \right\} & \left\{ 0, 2, -6, 2, 8 \right\} & \left\{ 1, -3, 1, 4 \right\} \\6& \left\{ 0, 0, 0, 1, -3, 1, 4 \right\} & \left\{ 0, 0, -1, 3, -1, -4 \right\} & \left\{ 0, 2, -6, 2, 8 \right\} & \left\{ 1, -3, 1, 4, 5 \right\} \\7& \left\{ 0, 0, 0, 1, -3, 1, 4 \right\} & \left\{ 0, 0, -1, 3, -1, -4 \right\} & \left\{ 0, 2, -6, 2, 8 \right\} & \left\{ 1, -3, 1, 4, 5, 5 \right\} \\8& \left\{ 0, 0, 0, 1, -3, 1, 4 \right\} & \left\{ 0, 0, -1, 3, -1, -4 \right\} & \left\{ 0, 2, -6, 2, 8 \right\} & \left\{ 1, -3, 1, 4, 5, 5, -2 \right\} \\\end{array}\right)[/math][br][br]HTBL auffüllen noch fehlender 0-Werte und anhängen der Koeffizienten von p,q (1.Zeile/1.Spalte):[br][br][math]\large HTBL \, := \, [br]\left(\begin{array}{rrrrrrrrr}[br]0\;\vdots&\; & \textbf{1}&\textbf{-5}&\textbf{8}&\textbf{-2}&\textbf{1}&\textbf{8}&\textbf{-6}\\[br] \cdots\;&\; & \; &\; &\; &\; &\; &\; &\; \\[br] \textbf{1}&\to & 0&0&0&1&-3&1&4\\[br] \;& \; &\; &\;&\;&\textcolor{blue}{\ {\nearrow_{(1)(1)}}}&\textcolor{Olivegreen}{ {\nearrow_{(1)(-3)}}}&\textcolor{Orange}{{\nearrow_{(2)(1)}}}&\textcolor{Magenta}{{\nearrow_{(1)(4)}}} \\[br]\textbf{-1}&\to & 0&0&-1&3&-1&-4&0\\[br] \;&\;& \; &\;&\textcolor{blue}{{\nearrow_{(-1)(1)}}}&\textcolor{Olivegreen}{{\nearrow_{(-1)(-3)}}}&\textcolor{Orange}{{\nearrow_{(-1)(1)}}}&\textcolor{Magenta}{{\nearrow_{(-1)(4)}}}&\;\\[br]\textbf{2}&\to & 0&2&-6&2&8&0&0\\[br]\;&\;& \; &\textcolor{blue}{{\nearrow_{(2)(1)}}}&\textcolor{Olivegreen}{{\nearrow_{(2)(-3)}}}&\textcolor{Orange}{{\nearrow_{(2)(1)}}}&\textcolor{Magenta}{{\nearrow_{(2)(4)}}}&\;&\;\\[br] 0\;\vdots&\textcolor{red}{\sum \downarrow}&\textbf{\textcolor{blue}{1}}&\textbf{\textcolor{Olivegreen}{-3}}&\textbf{\textcolor{Orange}{1}}&\textbf{\textcolor{Magenta}{4}}&5&5&-2\\[br]\end{array}\right)[br][/math][br][br] → p(x) = q(x) cd + cr[br] [math]\large \to p(x) = q(x) \left( x^{3} - 3 \; x^{2} + x + 4\right) + 5 \; x^{2} + 5 \; x - 2 [/math][br][br][br][size=150]Ausklammern Faktor im Quotient[br][br][math] \frac{p(x)}{q(x)}= \frac{4x^4 + 3x^2 - 1}{3x^2 - 4} \to \frac{4x^4 + 3x^2 - 1}{x^2 - 4/3}\to p(x)=3 q(x) \frac{1}{3}cd + cr[/math][br][br]Ausklammern entsprechend Horner-Schema p(x) mit Iteration()[/size][br][br][i]cc:=Reverse(Take((cp ),2)) + {0x,0x,0x,0x,0x,cp(1) x}[/i]; Länge anpassen für pseudo x-Liste[br][size=85]ggb ist sehr empfindlich wenn Listen unterschiedliche Objekte enthalten - die 0x Liste soll eine Liste aus Funktionen simulieren. [/size][br][br][math]\large Hx \, := \, \left\{ \left(\left(\left(\left(\left(x - 5 \right) \; x + 8 \right) \; x - 2 \right) \; x + 1 \right) \; x + 8 \right) \; x - 6 \right\} [/math]