\documentclass[a4paper]{article}
\usepackage{bbm}
\title{Stuff}
\author{Rik Snel}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{fp}
\usepackage{amsmath}
\usepackage{a4wide}
\input{vec2d}
\parindent0pt
\parskip .5ex
\begin{document}
\maketitle

\section{Solving the quadratic equation}

The general quadratic equation is
\[
	ax^2+bx+c=0
\]
with $a\not=0$.

To make life easier, we divide by $a$ and do some seemingly useless stuff
\[
	x^2 + 2\cdot\frac{b}{2a} x + \frac{c}{a} = 0.
\]

We define $\beta = \frac{b}{2a}$ and $\gamma = \frac{c}{a}$, so we have
\[
	x^2 + 2\beta x + \gamma = 0.
\]

Now we define $x = z - \beta$ and substitute this in the equation. Notice that $x^2 = z^2 - 2\beta z + \beta^2$. We get
\[
	z^2 - 2\beta z + \beta^2 + 2\beta(z - \beta) + \gamma = 0,
\]
which can be simplified to
\[
	z^2 = \beta^2 - \gamma.
\]

We solve this equation by taking the square root
\[
	x = \pm\sqrt{\beta^2 - \gamma} - \beta.
\]

By substituting the definitions of $\beta$ and $\gamma$ we find the usual formula
\[
	x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\]

\section{Solving the cubic equation}

The general cubic equation is
\[
	ax^3 + bx^2 + cx + d = 0,
\]
with $a\not=0$.

To make life easier, we divide by $a$ and do some seemingly useless stuff
\[
	x^3 + 3\cdot\frac{b}{3a} x^2 + 3\cdot\frac{c}{3a}x + \frac{d}{a} = 0.
\]

We define $\beta = \frac{b}{3a}$, $\gamma = \frac{c}{3a}$ and $\delta = \frac{d}{a}$, so we have
\[
	x^3 + 3\beta x^2 + 3\gamma x + \delta = 0.
\]

Now we define $x = z - \beta$ and substitute this in the equation. Notice
that $x^3 = z^3 - 3\beta z^2 + 3\beta^2 z - \beta^3$.
We get
\[
	z^3 - 3\beta z^2 + 3\beta^2 z - \beta^3 + 3\beta(z^2 - 2\beta z + \beta^2) + 3\gamma(z - \beta) + \delta = 0,
\]
which can be simplified to
\[
	z^3 - 3 (\beta^2 - \gamma) z - (3\beta \gamma - 2\beta^3 - \delta) = 0
\]
we define $p = \beta^2 - \gamma$ and $q = 3\beta \gamma - 2\beta^3 - \delta$.

Now we have the equation
\[
	z^3 - 3pz - q = 0.
\]

Notice that if $z = u+v$, then $z^2 = u^2+2uv+v^2$ and $z^3 = u^3 + 3u^2 v + 3u v^2 + v^3$. Of which the latter
can be rewritten as
\[
	z^3 -3uvz -u^3-v^3 = 0.
\]

If we can find $u$ and $v$ such that $p = uv \wedge q = u^3 + v^3$ then we have solved the cubic equation.
Writing $v=\frac{p}{u}$ and $q = u^3 + \frac{p^3}{u^3}$ gives a quadratic equation in $u^3$
\[
	(u^3)^2 - qu^3 + p^3 = 0,
\]
which has the following solutions
\[
	u^3 = \frac{q \pm \sqrt{q^2-4p^3}}{2} \wedge v^3 = q - u^3 = \frac{2q}{2} - \frac{q \pm \sqrt{q^2-4p^3}}{2} = \frac{q \mp \sqrt{q^2-4p^3}}{2}.
\]

Whichever solution we take, we get the same solution for $x$
\[
	x = \root 3 \of{\frac{q+\sqrt{q^2-4p^3}}{2}} + \root3\of{\frac{q-\sqrt{q^2-4p^3}}{2}} - \beta.
\]

In terms of $\beta$, $\gamma$ and $\delta$ this reads
\begin{multline}
	x = \root 3 \of{\frac{3\beta \gamma - 2\beta^3 - \delta + \sqrt{4\beta^3\delta - 3\beta^2\gamma^2 - 6\beta\gamma\delta+4\gamma^3+\delta^2}}{2}} \\
	+ \root 3 \of{\frac{3\beta \gamma - 2\beta^3 - \delta - \sqrt{4\beta^3\delta - 3\beta^2\gamma^2-6\beta\gamma\delta +4\gamma^3+\delta^2}}{2}} - \beta
\end{multline}

%Tmp
%\begin{multline}
%	x = \root 3 \of{\frac{3\cdot\frac{b}{3a}\cdot \frac{c}{3a} - 2\left(\frac{b}{3a}\right)^3 - \frac{d}a + \sqrt{4\left(\frac{b}{3a}\right)^3\frac{d}a - 3\left(\frac{b}{3a}\right)^2\left(\frac{c}{3a}\right)^2 - 6\cdot\frac{b}{3a}\cdot\frac{c}{3a}\cdot\frac{d}{a}+4\left(\frac{c}{3a}\right)^3+\left(\frac{d}{a}\right)^2}}{2}} \\
%	+ \root 3 \of{\frac{3\cdot\frac{b}{3a}\cdot \frac{c}{3a} - 2\left(\frac{b}{3a}\right)^3 - \frac{d}a - \sqrt{4\left(\frac{b}{3a}\right)^3\frac{d}a - 3\left(\frac{b}{3a}\right)^2\left(\frac{c}{3a}\right)^2 - 6\cdot\frac{b}{3a}\cdot\frac{c}{3a}\cdot\frac{d}{a}+4\left(\frac{c}{3a}\right)^3+\left(\frac{d}{a}\right)^2}}{2}} - \frac{b}{3a}
%\end{multline}

%Tmp2
%\begin{multline}
%	x = \root 3 \of{\frac{\frac{bc}{3a^2} - \frac{2b^3}{27a^3} - \frac{d}a + \sqrt{\frac{4b^3d}{27a^4} - \frac{b^2c^2}{27a^4} - \frac{2bcd}{3a^3}+\frac{4c^3}{27a^3}+\frac{d^2}{a^2}}}{2}} \\
%	+ \root 3 \of{\frac{\frac{bc}{3a^2} - \frac{2b^3}{27a^3} - \frac{d}a - \sqrt{\frac{4b^3d}{27a^4} - \frac{b^2c^2}{27a^4} - \frac{2bcd}{3a^3}+\frac{4c^3}{27a^3}+\frac{d^2}{a^2}}}{2}} - \frac{b}{3a}
%\end{multline}

%Tmp3
%\begin{multline}
%	x = \root 3 \of{\frac{\frac{9abc}{27a^3} - \frac{2b^3}{27a^3} - \frac{27a^2d}{27a^3} + \sqrt{\frac{12b^3d}{81a^4} - \frac{3b^2c^2}{81a^4} - \frac{54abcd}{81a^4}+\frac{12ac^3}{81a^4}+\frac{81a^2d^2}{81a^4}}}{2}} \\
%	+ \root 3 \of{\frac{\frac{9abc}{27a^3} - \frac{2b^3}{27a^3} - \frac{27a^2d}{27a^3} - \sqrt{\frac{12b^3d}{81a^4} - \frac{3b^2c^2}{81a^4} - \frac{54abcd}{81a^4}+\frac{12ac^3}{81a^4}+\frac{81a^2d^2}{81a^4}}}{2}} - \frac{b}{3a}
%\end{multline}

And finally in terms of $a$, $b$, $c$ and $d$ this reads
\begin{multline}
	x = \frac1{3a}\root 3 \of{\frac{9abc - 2b^3 - 27a^2d + 3a\sqrt{12b^3d - 3b^2c^2 - 54abcd+12ac^3+81a^2d^2}}{2}} \\
	+ \frac1{3a}\root 3 \of{\frac{9abc - 2b^3 - 27a^2d - 3a\sqrt{12b^3d - 3b^2c^2 - 54abcd+12ac^3+81a^2d^2}}{2}}  - \frac{b}{3a}
\end{multline}

Example
\[
	(x+7)(x+1)(x-2) = x^3 + 6x^2 -9x-14 = 0
\]
this gives $\beta = \frac63 = 2$, $\gamma =-\frac{9}{3}= -3$ and $\delta=-14$. In turn, this leads to $p = 2^2 + 3 = 7$ and $q = 3\cdot2\cdot -3 - 2\cdot 2^3 + 14 = -20$.
So the solution for $x$ is
\[
	x = \root 3 \of{\frac{-20+\sqrt{-972}}{2}} + \root3\of{\frac{-20-\sqrt{-972}}{2}} - 2.
\]
%assuming that somehow $\sqrt{-972} = 2\sqrt{-243}$ holds, we can simplify this to
%\[
%	x = \root 3 \of{-10 + \sqrt{-243}} + \root 3 \of{-10 + \sqrt{-243}} - 2.
%\]

Second example
\[
	x^3-18009x-932480
\]
gives
\[
	x = \root3\of{466240+9011\sqrt{13}} + \root3\of{466240-9011\sqrt{13}}.
\]

\section{Solving the quartic equation}

The general quartic equation is
\[
	ax^4 + bx^3 + cx^2 + dx + e = 0,
\]
with $a\not=0$.

To make life easier, we divide by $a$ and do some seemingly useless stuff
\[
	x^4 + 4\cdot\frac{b}{4a} x^3 + 3\cdot\frac{c}{3a}x^2 + 3\cdot\frac{d}{3a}x + 3\cdot\frac{e}{3a} = 0.
\]

We define $\beta = \frac{b}{4a}$, $\gamma = \frac{c}{3a}$, $\delta = \frac{d}{3a}$ and $\varepsilon = \frac{e}{3a}$, so we have
\[
	x^4 + 4\beta x^3 + 3\gamma x^2 + 3\delta x  + 3\varepsilon = 0.
\]

Now we define $x = z - \beta$ and substitute this in the equation. Notice
that $x^4 = z^4 - 4\beta z^3 + 6\beta^2 z^2 - 4\beta^3z + \beta^4$.
We get
\[
	z^4 - 4\beta z^3 + 6\beta^2 z^2 - 4\beta^3z + \beta^4 + 4\beta (z^3 - 3\beta z^2 + 3\beta^2 z - \beta^3) + 3\gamma (z^2 - 2\beta z + \beta^2) + 3\delta(z - \beta) + 3\varepsilon = 0,
\]
which can be simplified to
\[
	z^4+ 3(\gamma - 2\beta^2) z^2 + (8\beta^3 - 3\beta\gamma + 3\delta) z + 3(\beta^2\gamma  - \beta^4 - \beta\delta + \varepsilon) = 0
\]
we define $\ldots$.

\end{document}
