Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 3

17 Apr '19, 20:33

cis's gravatar image

cis
9.6k104461491

Wie löse ich eine kubische Gleichung mit pgfmath?

Ich habe einmal aus Reiz etwas zusammengeschrieben. Ich habe mich dabei an [diesem Verfahren](https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?topic=160525&post_id=1181901) orientiert: <br> [![alt text][1]][2] Für einfache Beispiele tut es: <br> [![alt text][3]][3] Für komplizierte Beispiele ist meits meist nur das erste Ergebnis richtig. <br> Also falls jmd. Lust hat... \documentclass[margin=5pt]{standalone} \usepackage{amsmath, amssymb} \usepackage{tikz} %\usepackage{fp} %\usetikzlibrary{fixedpointarithmetic} %\pgfkeys{/pgf/fixed point arithmetic} \begin{document} % Beispiel x³+Ax²+Bx+C=0 %% x^3 - 6 x^2 + 12 x - 8 = (x-2)^3 \pgfmathsetmacro{\A}{-6} % \pgfmathsetmacro{\B}{12} % \pgfmathsetmacro{\C}{-8} % %% x^3 - x^2 - x - 1 = 0 = schwieriges Ergeb. %\pgfmathsetmacro{\A}{-1} % %\pgfmathsetmacro{\B}{-1} % %\pgfmathsetmacro{\C}{-1} % %%% x^3-5x^2-4x+20 =(x-5)(x-2)(x+2) %\pgfmathsetmacro{\A}{-5} % %\pgfmathsetmacro{\B}{-4} % %\pgfmathsetmacro{\C}{20} % % %% x^3 - 6 x^2 + 11 x - 6 = (x-1)(x-2)(x-3) %\pgfmathsetmacro{\A}{-6} % %\pgfmathsetmacro{\B}{11} % %\pgfmathsetmacro{\C}{-6} % % %%% c^3−13c^2−21c+377= 0 geht nicht %%\pgfmathsetmacro{\A}{-13} % %%\pgfmathsetmacro{\B}{-21} % %%\pgfmathsetmacro{\C}{377} % % %% x^3-6.5 x^2-5.25 x+47.125 = 0 %\pgfmathsetmacro{\A}{-6.5} % %\pgfmathsetmacro{\B}{-5.25} % %\pgfmathsetmacro{\C}{47.125} % % Berechnung \pgfmathsetmacro{\Avz}{\A<0 ? "\A" : "+\A"} \pgfmathsetmacro{\Bvz}{\B<0 ? "\B" : "+\B"} \pgfmathsetmacro{\Cvz}{\C<0 ? "\C" : "+\C"} \pgfmathsetmacro{\a}{-\A/3} % \pgfmathsetmacro{\b}{\B/6} % \pgfmathsetmacro{\c}{-\C/2} % \pgfmathsetmacro{\p}{\a^2-2*\b} % \pgfmathsetmacro{\q}{\a^3-3*\a*\b+\c} % \pgfmathsetmacro{\D}{\q^2-\p^3} % \pgfmathsetmacro{\DTest}{\D > 0 ? 1 : 0} % \ifnum\DTest=1 \pgfmathsetmacro{\yIre}{\q+sqrt(\q^2-\p^3)} % \pgfmathsetmacro{\yIim}{0} % \pgfmathsetmacro{\yIimVZ}{\yIim<0 ? "" : "+"} \pgfmathsetmacro{\yIIre}{\q-sqrt(\q^2-\p^3)} % \pgfmathsetmacro{\yIIim}{0} % \pgfmathsetmacro{\yIIimVZ}{\yIIim<0 ? "" : "+"} \pgfmathsetmacro{\y}{"\yIre"} %\pgfmathsetmacro{\y}{\yI >= 0 ? \yI : \yII} % \else% \pgfmathsetmacro{\yIre}{\q} % \pgfmathsetmacro{\yIim}{sqrt(-\q^2+\p^3)} % \pgfmathsetmacro{\yIimVZ}{\yIim<0 ? "" : "+"} \pgfmathsetmacro{\yIIre}{\q} % \pgfmathsetmacro{\yIIim}{-sqrt(-\q^2+\p^3)} % - \pgfmathsetmacro{\yIIimVZ}{\yIIim<0 ? "" : "+"} \pgfmathsetmacro{\y}{"\yIre \yIimVZ \yIim \,i"} \fi% \pgfmathsetmacro{\yAbs}{sqrt((\yIre)^2+(\yIim)^2)} % \pgfmathsetmacro{\yW}{\yAbs^(1/3)} % \pgfmathsetmacro{\yArg}{atan2(\yIim,\yIre)} % \pgfmathsetmacro{\zIre}{\yW*cos(\yArg/3)} \pgfmathsetmacro{\zIim}{\yW*sin(\yArg/3)} \pgfmathsetmacro{\zIimVZ}{\zIim<0 ? "" : "+"} \pgfmathsetmacro{\zIabs}{sqrt((\zIre)^2+(\zIim)^2)} \pgfmathsetmacro{\zIIre}{\yW*(-cos(\yArg/3)-sqrt(3)*sin(\yArg))/2} \pgfmathsetmacro{\zIIim}{\yW*(sqrt(3)*cos(\yArg/3)-sin(\yArg))/2} \pgfmathsetmacro{\zIIimVZ}{\zIIim<0 ? "" : "+"} \pgfmathsetmacro{\zIIabs}{sqrt((\zIIre)^2+(\zIIim)^2)} \pgfmathsetmacro{\zIIIre}{\yW*(-cos(\yArg/3)+sqrt(3)*sin(\yArg))/2} \pgfmathsetmacro{\zIIIim}{\yW*(-sqrt(3)*cos(\yArg/3)-sin(\yArg))/2} \pgfmathsetmacro{\zIIIimVZ}{\zIIIim<0 ? "" : "+"} \pgfmathsetmacro{\zIIIabs}{sqrt((\zIIIre)^2+(\zIIIim)^2)} \pgfmathsetmacro{\pTest}{\p==0 ? 1 : 0} \ifnum\pTest=1% \pgfmathsetmacro{\xIre}{\a + \zIre}% \pgfmathsetmacro{\xIim}{\zIim}% \pgfmathsetmacro{\xIimVZ}{\xIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIre}{\a+\zIIre}% \pgfmathsetmacro{\xIIim}{\zIIim}% \pgfmathsetmacro{\xIIimVZ}{\xIIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIIre}{\a+\zIIIre}% \pgfmathsetmacro{\xIIIim}{\zIIIim}% \pgfmathsetmacro{\xIIIimVZ}{\xIIIim<0 ? "" : "+"}% \else% \pgfmathsetmacro{\xIre}{\a+\zIre*(1+\p/\zIabs^2)}% \pgfmathsetmacro{\xIim}{\zIim*(1-\p/\zIabs^2)}% \pgfmathsetmacro{\xIimVZ}{\xIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIre}{\a+\zIIre*(1+\p/\zIIabs^2)}% \pgfmathsetmacro{\xIIim}{\zIIim*(1-\p/\zIIabs^2)}% \pgfmathsetmacro{\xIIimVZ}{\xIIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIIre}{\a+\zIIIre*(1+\p/\zIIIabs^2)}% \pgfmathsetmacro{\xIIIim}{\zIIIim*(1-\p/\zIIIabs^2)}% \pgfmathsetmacro{\xIIIimVZ}{\xIIIim<0 ? "" : "+"}% \fi% $\begin{array}{c l r} (1) & x^3 \Avz x^2 \Bvz x \Cvz = 0 = x^3 -3a x^2 + 6b x - 2c \\ \hline & A = \A & \\ & B = \B & \\ & C = \C & \\ \hline & a = -\dfrac{A}{3} = \a \\ & b = \dfrac{B}{6} = \b \\ & c = -\dfrac{C}{2} = \c \\ \hline (2) & p = a^2-2b = \p \\ & q = a^3-3 ab+c = \q \\ & q^3-p^2 = \D \\ \hline (3) & (y-q)^2 = q^2-p^3 \\ & y_1 = \yIre \yIimVZ \yIim \,i \\ & y_2 = \yIIre \yIIimVZ \yIIim \,i \\ & y=\y \\ \hline (4) & z^3 = y \\ & z_2 = \zIre \zIimVZ \zIim \,i \\ & z_2 = \zIIre \zIIimVZ \zIIim \,i \\ & z_3 = \zIIIre \zIIIimVZ \zIIIim \,i \\ \hline (5) & x = a + z + \dfrac{p}{z} \\ & x_1 = \xIre \xIimVZ \xIim \,i \\ & x_2 = \xIIre \xIIimVZ \xIIim \,i \\ & x_3 = \xIIIre \xIIIimVZ \xIIIim \,i \\ \hline\hline \end{array}$ \end{document} [1]: https://texwelt.de/wissen/upfiles/9999999999999_4.jpg [2]: https://texwelt.de/wissen/upfiles/9999999999999_4.jpg [3]: https://texwelt.de/wissen/upfiles/55555555_335.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 2

17 Apr '19, 20:31

cis's gravatar image

cis
9.6k104461491

Wie löse ich eine kubische Gleichung mit pgfmath?

Ich habe einmal aus Reiz etwas zusammengeschrieben. Ich habe mich dabei an [diesem Verfahren](https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?topic=160525&post_id=1181901) orientiert: <br> [![alt text][1]][2] Für einfach einfache Beispiele tut es: <br> [![alt text][3]][3] Für komplizierte Beispiele ist meits nur das erste Ergebnis richtig. <br> Also falls jmd. Lust hat... \documentclass[margin=5pt]{standalone} \usepackage{amsmath, amssymb} \usepackage{tikz} %\usepackage{fp} %\usetikzlibrary{fixedpointarithmetic} %\pgfkeys{/pgf/fixed point arithmetic} \begin{document} % Beispiel x³+Ax²+Bx+C=0 %% x^3 - 6 x^2 + 12 x - 8 = (x-2)^3 \pgfmathsetmacro{\A}{-6} % \pgfmathsetmacro{\B}{12} % \pgfmathsetmacro{\C}{-8} % %% x^3 - x^2 - x - 1 = 0 = schwieriges Ergeb. %\pgfmathsetmacro{\A}{-1} % %\pgfmathsetmacro{\B}{-1} % %\pgfmathsetmacro{\C}{-1} % %%% x^3-5x^2-4x+20 =(x-5)(x-2)(x+2) %\pgfmathsetmacro{\A}{-5} % %\pgfmathsetmacro{\B}{-4} % %\pgfmathsetmacro{\C}{20} % % %% x^3 - 6 x^2 + 11 x - 6 = (x-1)(x-2)(x-3) %\pgfmathsetmacro{\A}{-6} % %\pgfmathsetmacro{\B}{11} % %\pgfmathsetmacro{\C}{-6} % % %%% c^3−13c^2−21c+377= 0 geht nicht %%\pgfmathsetmacro{\A}{-13} % %%\pgfmathsetmacro{\B}{-21} % %%\pgfmathsetmacro{\C}{377} % % %% x^3-6.5 x^2-5.25 x+47.125 = 0 %\pgfmathsetmacro{\A}{-6.5} % %\pgfmathsetmacro{\B}{-5.25} % %\pgfmathsetmacro{\C}{47.125} % % Berechnung \pgfmathsetmacro{\Avz}{\A<0 ? "\A" : "+\A"} \pgfmathsetmacro{\Bvz}{\B<0 ? "\B" : "+\B"} \pgfmathsetmacro{\Cvz}{\C<0 ? "\C" : "+\C"} \pgfmathsetmacro{\a}{-\A/3} % \pgfmathsetmacro{\b}{\B/6} % \pgfmathsetmacro{\c}{-\C/2} % \pgfmathsetmacro{\p}{\a^2-2*\b} % \pgfmathsetmacro{\q}{\a^3-3*\a*\b+\c} % \pgfmathsetmacro{\D}{\q^2-\p^3} % \pgfmathsetmacro{\DTest}{\D > 0 ? 1 : 0} % \ifnum\DTest=1 \pgfmathsetmacro{\yIre}{\q+sqrt(\q^2-\p^3)} % \pgfmathsetmacro{\yIim}{0} % \pgfmathsetmacro{\yIimVZ}{\yIim<0 ? "" : "+"} \pgfmathsetmacro{\yIIre}{\q-sqrt(\q^2-\p^3)} % \pgfmathsetmacro{\yIIim}{0} % \pgfmathsetmacro{\yIIimVZ}{\yIIim<0 ? "" : "+"} \pgfmathsetmacro{\y}{"\yIre"} %\pgfmathsetmacro{\y}{\yI >= 0 ? \yI : \yII} % \else% \pgfmathsetmacro{\yIre}{\q} % \pgfmathsetmacro{\yIim}{sqrt(-\q^2+\p^3)} % \pgfmathsetmacro{\yIimVZ}{\yIim<0 ? "" : "+"} \pgfmathsetmacro{\yIIre}{\q} % \pgfmathsetmacro{\yIIim}{-sqrt(-\q^2+\p^3)} % - \pgfmathsetmacro{\yIIimVZ}{\yIIim<0 ? "" : "+"} \pgfmathsetmacro{\y}{"\yIre \yIimVZ \yIim \,i"} \fi% \pgfmathsetmacro{\yAbs}{sqrt((\yIre)^2+(\yIim)^2)} % \pgfmathsetmacro{\yW}{\yAbs^(1/3)} % \pgfmathsetmacro{\yArg}{atan2(\yIim,\yIre)} % \pgfmathsetmacro{\zIre}{\yW*cos(\yArg/3)} \pgfmathsetmacro{\zIim}{\yW*sin(\yArg/3)} \pgfmathsetmacro{\zIimVZ}{\zIim<0 ? "" : "+"} \pgfmathsetmacro{\zIabs}{sqrt((\zIre)^2+(\zIim)^2)} \pgfmathsetmacro{\zIIre}{\yW*(-cos(\yArg/3)-sqrt(3)*sin(\yArg))/2} \pgfmathsetmacro{\zIIim}{\yW*(sqrt(3)*cos(\yArg/3)-sin(\yArg))/2} \pgfmathsetmacro{\zIIimVZ}{\zIIim<0 ? "" : "+"} \pgfmathsetmacro{\zIIabs}{sqrt((\zIIre)^2+(\zIIim)^2)} \pgfmathsetmacro{\zIIIre}{\yW*(-cos(\yArg/3)+sqrt(3)*sin(\yArg))/2} \pgfmathsetmacro{\zIIIim}{\yW*(-sqrt(3)*cos(\yArg/3)-sin(\yArg))/2} \pgfmathsetmacro{\zIIIimVZ}{\zIIIim<0 ? "" : "+"} \pgfmathsetmacro{\zIIIabs}{sqrt((\zIIIre)^2+(\zIIIim)^2)} \pgfmathsetmacro{\pTest}{\p==0 ? 1 : 0} \ifnum\pTest=1% \pgfmathsetmacro{\xIre}{\a + \zIre}% \pgfmathsetmacro{\xIim}{\zIim}% \pgfmathsetmacro{\xIimVZ}{\xIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIre}{\a+\zIIre}% \pgfmathsetmacro{\xIIim}{\zIIim}% \pgfmathsetmacro{\xIIimVZ}{\xIIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIIre}{\a+\zIIIre}% \pgfmathsetmacro{\xIIIim}{\zIIIim}% \pgfmathsetmacro{\xIIIimVZ}{\xIIIim<0 ? "" : "+"}% \else% \pgfmathsetmacro{\xIre}{\a+\zIre*(1+\p/\zIabs^2)}% \pgfmathsetmacro{\xIim}{\zIim*(1-\p/\zIabs^2)}% \pgfmathsetmacro{\xIimVZ}{\xIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIre}{\a+\zIIre*(1+\p/\zIIabs^2)}% \pgfmathsetmacro{\xIIim}{\zIIim*(1-\p/\zIIabs^2)}% \pgfmathsetmacro{\xIIimVZ}{\xIIim<0 ? "" : "+"}% % \pgfmathsetmacro{\xIIIre}{\a+\zIIIre*(1+\p/\zIIIabs^2)}% \pgfmathsetmacro{\xIIIim}{\zIIIim*(1-\p/\zIIIabs^2)}% \pgfmathsetmacro{\xIIIimVZ}{\xIIIim<0 ? "" : "+"}% \fi% $\begin{array}{c l r} (1) & x^3 \Avz x^2 \Bvz x \Cvz = 0 = x^3 -3a x^2 + 6b x - 2c \\ \hline & A = \A & \\ & B = \B & \\ & C = \C & \\ \hline & a = -\dfrac{A}{3} = \a \\ & b = \dfrac{B}{6} = \b \\ & c = -\dfrac{C}{2} = \c \\ \hline (2) & p = a^2-2b = \p \\ & q = a^3-3 ab+c = \q \\ & q^3-p^2 = \D \\ \hline (3) & (y-q)^2 = q^2-p^3 \\ & y_1 = \yIre \yIimVZ \yIim \,i \\ & y_2 = \yIIre \yIIimVZ \yIIim \,i \\ & y=\y \\ \hline (4) & z^3 = y \\ & z_2 = \zIre \zIimVZ \zIim \,i \\ & z_2 = \zIIre \zIIimVZ \zIIim \,i \\ & z_3 = \zIIIre \zIIIimVZ \zIIIim \,i \\ \hline (5) & x = a + z + \dfrac{p}{z} \\ & x_1 = \xIre \xIimVZ \xIim \,i \\ & x_2 = \xIIre \xIIimVZ \xIIim \,i \\ & x_3 = \xIIIre \xIIIimVZ \xIIIim \,i \\ \hline\hline \end{array}$ \end{document} [1]: https://texwelt.de/wissen/upfiles/9999999999999_4.jpg [2]: https://texwelt.de/wissen/upfiles/9999999999999_4.jpg [3]: https://texwelt.de/wissen/upfiles/55555555_335.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

17 Apr '19, 20:30

cis's gravatar image

cis
9.6k104461491

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×