Ich habe einmal aus Reiz etwas zusammengeschrieben.

Ich habe mich dabei an diesem Verfahren orientiert:
alt text

Für einfache Beispiele tut es:
alt text

Für komplizierte Beispiele ist meist nur das erste Ergebnis richtig.
Also falls jmd. Lust hat...

Öffne in Overleaf
\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}

gefragt 17 Apr '19, 20:30

cis's gravatar image

cis
9.5k75452491
Akzeptiert-Rate: 29%

bearbeitet 17 Apr '19, 20:33

1

Erstens ist das keine Frage und zweitens weiß ich nicht, wie oft man dir noch sagen muss, dass man die Einbuchstabenmakros nicht überschreiben soll. Daher -1

(18 Apr '19, 04:38) Henri

Bei dem Umfang war das mein kleinstes Problem und da habe ich gedacht, da nehme ich mal den Stock aus dem Arsch. Kannst Du ja auch mal versuchen. Du würdest überrascht sein.

(18 Apr '19, 15:44) cis

Ich habe Deinen Code nicht ausprobiert (auch weil ich nicht der Meinung bin, dass TikZ ein Computer Algebra System ist), aber vermute ganz stark, dass es daran liegt, dass TikZ Potenzen etwas "unkonventionell" parst. Probier doch mal, alle \q^2 etc. durch (\q)^2 bzw. pow(\q,2) etc. zu ersetzen.

(19 Apr '19, 01:51) Community

(\q)^2 musste ich eh, weil er sonst negative Wurzeln findet oder sowas. pow wäre noch so eine Idee.
Das war jetzt halt mehr der Reiz, das mal zu testen. Mit SageTeX wäre das eine Zeile.

(19 Apr '19, 03:09) cis

Ich sehe halt trotzdem viele Zeilen der Art \pgfmathsetmacro{\yIim}{sqrt(-\q^2+\p^3)}. Probier doch mal, ob es besser wird, wenn Du alle ^ ersetzt, z.B. hier \pgfmathsetmacro{\yIim}{sqrt(-pow(\q,2)+\p^3)} (ungerade Potenzen sind wurscht).

(20 Apr '19, 02:56) Community

Kleine Rückmeldung: Hat leider nicht geholfen.

(21 Apr '19, 19:34) cis

Bei wikipedia stehen geschlossene Formeln...

(22 Apr '19, 00:22) user0

@user0 Ja, ich weiß. Interessant ist da z.B. auch die PQRST-Formel. Da war mein Problem, dass schnell die "Dimensions too large" werden.

(22 Apr '19, 05:16) cis
Ergebnis 5 von 8 show 3 more comments
Deine Antwort auf die Frage: (Bemerkungen bitte oben als Kommentar)
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×13

gestellte Frage: 17 Apr '19, 20:30

Frage wurde gesehen: 1,940 Mal

zuletzt geändert: 22 Apr '19, 05:16