Average Error: 15.5 → 0.7
Time: 13.6s
Precision: 64
Internal Precision: 1344
$\left(2 \cdot \cos \left(\frac{z}{2}\right) - 3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2}\right) + 1$
$\begin{array}{l} \mathbf{if}\;z \le -0.034010819601945096:\\ \;\;\;\;1 + \left(\cos \left(\frac{z}{2}\right) \cdot 2 - \cos \left(\frac{z}{2}\right) \cdot \left(3 \cdot \cos \left(\frac{z}{2}\right)\right)\right)\\ \mathbf{elif}\;z \le 0.03416508920843485:\\ \;\;\;\;\left({z}^{6} \cdot \frac{47}{23040} + {z}^{2} \cdot \frac{1}{2}\right) - {z}^{4} \cdot \frac{11}{192}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\frac{z}{2}\right) \cdot 2 - \sqrt[3]{\left(\left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)}\\ \end{array}$

# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if z < -0.034010819601945096

1. Initial program 1.2

$\left(2 \cdot \cos \left(\frac{z}{2}\right) - 3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2}\right) + 1$
2. Using strategy rm
3. Applied unpow21.2

$\leadsto \left(2 \cdot \cos \left(\frac{z}{2}\right) - 3 \cdot \color{blue}{\left(\cos \left(\frac{z}{2}\right) \cdot \cos \left(\frac{z}{2}\right)\right)}\right) + 1$
4. Applied associate-*r*1.2

$\leadsto \left(2 \cdot \cos \left(\frac{z}{2}\right) - \color{blue}{\left(3 \cdot \cos \left(\frac{z}{2}\right)\right) \cdot \cos \left(\frac{z}{2}\right)}\right) + 1$

## if -0.034010819601945096 < z < 0.03416508920843485

1. Initial program 30.0

$\left(2 \cdot \cos \left(\frac{z}{2}\right) - 3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2}\right) + 1$
2. Taylor expanded around 0 0.0

$\leadsto \color{blue}{\left(\frac{47}{23040} \cdot {z}^{6} + \frac{1}{2} \cdot {z}^{2}\right) - \frac{11}{192} \cdot {z}^{4}}$

## if 0.03416508920843485 < z

1. Initial program 1.2

$\left(2 \cdot \cos \left(\frac{z}{2}\right) - 3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2}\right) + 1$
2. Using strategy rm
3. Applied associate-+l-1.1

$\leadsto \color{blue}{2 \cdot \cos \left(\frac{z}{2}\right) - \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)}$
4. Using strategy rm

$\leadsto 2 \cdot \cos \left(\frac{z}{2}\right) - \color{blue}{\sqrt[3]{\left(\left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)}}$
3. Recombined 3 regimes into one program.
4. Final simplification0.7

$\leadsto \begin{array}{l} \mathbf{if}\;z \le -0.034010819601945096:\\ \;\;\;\;1 + \left(\cos \left(\frac{z}{2}\right) \cdot 2 - \cos \left(\frac{z}{2}\right) \cdot \left(3 \cdot \cos \left(\frac{z}{2}\right)\right)\right)\\ \mathbf{elif}\;z \le 0.03416508920843485:\\ \;\;\;\;\left({z}^{6} \cdot \frac{47}{23040} + {z}^{2} \cdot \frac{1}{2}\right) - {z}^{4} \cdot \frac{11}{192}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(\frac{z}{2}\right) \cdot 2 - \sqrt[3]{\left(\left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)\right) \cdot \left(3 \cdot {\left(\cos \left(\frac{z}{2}\right)\right)}^{2} - 1\right)}\\ \end{array}$

# Runtime

Time bar (total: 13.6s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)'
(FPCore (z)
:name "(2*cos(z/2) - 3*cos(z/2)^2 +1)"
(+ (- (* 2 (cos (/ z 2))) (* 3 (pow (cos (/ z 2)) 2))) 1))