(cos (* PI (+ z0 z0)))

Percentage Accurate: 57.5% → 98.5%
Time: 1.7s
Alternatives: 6
Speedup: 109.0×

Specification

?
\[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
(FPCore (z0)
  :precision binary64
  (cos (* PI (+ z0 z0))))
double code(double z0) {
	return cos((((double) M_PI) * (z0 + z0)));
}
public static double code(double z0) {
	return Math.cos((Math.PI * (z0 + z0)));
}
def code(z0):
	return math.cos((math.pi * (z0 + z0)))
function code(z0)
	return cos(Float64(pi * Float64(z0 + z0)))
end
function tmp = code(z0)
	tmp = cos((pi * (z0 + z0)));
end
code[z0_] := N[Cos[N[(Pi * N[(z0 + z0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos \left(\pi \cdot \left(z0 + z0\right)\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 57.5% accurate, 1.0× speedup?

\[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
(FPCore (z0)
  :precision binary64
  (cos (* PI (+ z0 z0))))
double code(double z0) {
	return cos((((double) M_PI) * (z0 + z0)));
}
public static double code(double z0) {
	return Math.cos((Math.PI * (z0 + z0)));
}
def code(z0):
	return math.cos((math.pi * (z0 + z0)))
function code(z0)
	return cos(Float64(pi * Float64(z0 + z0)))
end
function tmp = code(z0)
	tmp = cos((pi * (z0 + z0)));
end
code[z0_] := N[Cos[N[(Pi * N[(z0 + z0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos \left(\pi \cdot \left(z0 + z0\right)\right)

Alternative 1: 98.5% accurate, 0.3× speedup?

\[\begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 85000:\\ \;\;\;\;\left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot \left|z0\right|\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \frac{\cos \left(\pi \cdot \left|z0\right| - \left(-\pi\right) \cdot \left|z0\right|\right) - \cos 0}{2}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (if (<= (fabs z0) 85000.0)
  (+
   (+ 0.5 (* 0.5 (sin (+ (* (* -2.0 (fabs z0)) PI) (* PI 0.5)))))
   (/
    (- (cos (- (* PI (fabs z0)) (* (- PI) (fabs z0)))) (cos 0.0))
    2.0))
  1.0))
double code(double z0) {
	double tmp;
	if (fabs(z0) <= 85000.0) {
		tmp = (0.5 + (0.5 * sin((((-2.0 * fabs(z0)) * ((double) M_PI)) + (((double) M_PI) * 0.5))))) + ((cos(((((double) M_PI) * fabs(z0)) - (-((double) M_PI) * fabs(z0)))) - cos(0.0)) / 2.0);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
public static double code(double z0) {
	double tmp;
	if (Math.abs(z0) <= 85000.0) {
		tmp = (0.5 + (0.5 * Math.sin((((-2.0 * Math.abs(z0)) * Math.PI) + (Math.PI * 0.5))))) + ((Math.cos(((Math.PI * Math.abs(z0)) - (-Math.PI * Math.abs(z0)))) - Math.cos(0.0)) / 2.0);
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(z0):
	tmp = 0
	if math.fabs(z0) <= 85000.0:
		tmp = (0.5 + (0.5 * math.sin((((-2.0 * math.fabs(z0)) * math.pi) + (math.pi * 0.5))))) + ((math.cos(((math.pi * math.fabs(z0)) - (-math.pi * math.fabs(z0)))) - math.cos(0.0)) / 2.0)
	else:
		tmp = 1.0
	return tmp
function code(z0)
	tmp = 0.0
	if (abs(z0) <= 85000.0)
		tmp = Float64(Float64(0.5 + Float64(0.5 * sin(Float64(Float64(Float64(-2.0 * abs(z0)) * pi) + Float64(pi * 0.5))))) + Float64(Float64(cos(Float64(Float64(pi * abs(z0)) - Float64(Float64(-pi) * abs(z0)))) - cos(0.0)) / 2.0));
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(z0)
	tmp = 0.0;
	if (abs(z0) <= 85000.0)
		tmp = (0.5 + (0.5 * sin((((-2.0 * abs(z0)) * pi) + (pi * 0.5))))) + ((cos(((pi * abs(z0)) - (-pi * abs(z0)))) - cos(0.0)) / 2.0);
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[z0_] := If[LessEqual[N[Abs[z0], $MachinePrecision], 85000.0], N[(N[(0.5 + N[(0.5 * N[Sin[N[(N[(N[(-2.0 * N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[N[(N[(Pi * N[Abs[z0], $MachinePrecision]), $MachinePrecision] - N[((-Pi) * N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Cos[0.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\mathbf{if}\;\left|z0\right| \leq 85000:\\
\;\;\;\;\left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot \left|z0\right|\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \frac{\cos \left(\pi \cdot \left|z0\right| - \left(-\pi\right) \cdot \left|z0\right|\right) - \cos 0}{2}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < 85000

    1. Initial program 57.5%

      \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
    2. Applied rewrites57.5%

      \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\left(-\pi\right) \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right)} \]
    3. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\sin \left(\left(-\pi\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      2. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \color{blue}{\left(\left(-\pi\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      3. lift-neg.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)} \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      4. distribute-lft-neg-outN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \color{blue}{\left(\mathsf{neg}\left(\pi \cdot z0\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      5. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\mathsf{neg}\left(\color{blue}{z0 \cdot \pi}\right)\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\mathsf{neg}\left(\color{blue}{z0 \cdot \pi}\right)\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      7. sin-neg-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\sin \left(z0 \cdot \pi\right)\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      8. cos-+PI/2-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(z0 \cdot \pi + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      9. lower-cos.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(z0 \cdot \pi + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + z0 \cdot \pi\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      11. lower-+.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + z0 \cdot \pi\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      12. lift-PI.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{\color{blue}{\pi}}{2} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      13. mult-flipN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{\pi \cdot \frac{1}{2}} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      14. metadata-evalN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\pi \cdot \color{blue}{\frac{1}{2}} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      15. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{\frac{1}{2} \cdot \pi} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      16. lower-*.f6459.6%

        \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{0.5 \cdot \pi} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      17. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \color{blue}{z0 \cdot \pi}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      18. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \color{blue}{\pi \cdot z0}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      19. lower-*.f6459.6%

        \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(0.5 \cdot \pi + \color{blue}{\pi \cdot z0}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
    4. Applied rewrites59.6%

      \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(0.5 \cdot \pi + \pi \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
    5. Step-by-step derivation
      1. lift-cos.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(\left(z0 + z0\right) \cdot \pi\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      2. cos-neg-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      3. sin-+PI/2-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      4. lower-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      5. lift-PI.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\color{blue}{\pi}}{2}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      6. mult-flip-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      7. metadata-evalN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      8. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      9. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      10. lower-+.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \color{blue}{\left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{1}{2} \cdot \pi\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      11. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right) \cdot \pi}\right)\right) + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      12. distribute-lft-neg-inN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\mathsf{neg}\left(\left(z0 + z0\right)\right)\right) \cdot \pi} + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      13. lower-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\mathsf{neg}\left(\left(z0 + z0\right)\right)\right) \cdot \pi} + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      14. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right)}\right)\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      15. count-2N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{2 \cdot z0}\right)\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      16. distribute-lft-neg-inN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\left(\mathsf{neg}\left(2\right)\right) \cdot z0\right)} \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      17. metadata-evalN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\color{blue}{-2} \cdot z0\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      18. lower-*.f6460.9%

        \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\color{blue}{\left(-2 \cdot z0\right)} \cdot \pi + 0.5 \cdot \pi\right)\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      19. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      20. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      21. lower-*.f6460.9%

        \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\pi \cdot 0.5}\right)\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
    6. Applied rewrites60.9%

      \[\leadsto \left(0.5 + 0.5 \cdot \color{blue}{\sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot 0.5\right)}\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\sin \left(z0 \cdot \pi\right) \cdot \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right)} \]
      3. lift-sin.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\sin \left(z0 \cdot \pi\right)} \cdot \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \]
      4. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \color{blue}{\left(z0 \cdot \pi\right)} \cdot \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \]
      5. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \color{blue}{\left(\pi \cdot z0\right)} \cdot \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \]
      6. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \color{blue}{\left(\pi \cdot z0\right)} \cdot \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \]
      7. lift-cos.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \color{blue}{\cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right)} \]
      8. lift-+.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \color{blue}{\left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right)} \]
      9. +-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \color{blue}{\left(\pi \cdot z0 + \frac{1}{2} \cdot \pi\right)} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \color{blue}{\frac{1}{2} \cdot \pi}\right) \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \color{blue}{\pi \cdot \frac{1}{2}}\right) \]
      12. metadata-evalN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \pi \cdot \color{blue}{\frac{1}{2}}\right) \]
      13. mult-flip-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \color{blue}{\frac{\pi}{2}}\right) \]
      14. lift-PI.f64N/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right) \]
      15. cos-+PI/2-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin \left(\pi \cdot z0\right)\right)\right)} \]
      16. sin-neg-revN/A

        \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\pi \cdot z0\right) \cdot \color{blue}{\sin \left(\mathsf{neg}\left(\pi \cdot z0\right)\right)} \]
    8. Applied rewrites56.8%

      \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \color{blue}{\frac{\cos \left(\pi \cdot z0 - \left(-\pi\right) \cdot z0\right) - \cos 0}{2}} \]

    if 85000 < z0

    1. Initial program 57.5%

      \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
    2. Taylor expanded in z0 around 0

      \[\leadsto \color{blue}{1} \]
    3. Step-by-step derivation
      1. Applied rewrites97.2%

        \[\leadsto \color{blue}{1} \]
    4. Recombined 2 regimes into one program.
    5. Add Preprocessing

    Alternative 2: 98.5% accurate, 0.3× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 85000:\\ \;\;\;\;\left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot \left|z0\right|\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \sin \left(\left(-\pi\right) \cdot \left|z0\right|\right) \cdot \sin \left(\left|z0\right| \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
    (FPCore (z0)
      :precision binary64
      (if (<= (fabs z0) 85000.0)
      (+
       (+ 0.5 (* 0.5 (sin (+ (* (* -2.0 (fabs z0)) PI) (* PI 0.5)))))
       (* (sin (* (- PI) (fabs z0))) (sin (* (fabs z0) PI))))
      1.0))
    double code(double z0) {
    	double tmp;
    	if (fabs(z0) <= 85000.0) {
    		tmp = (0.5 + (0.5 * sin((((-2.0 * fabs(z0)) * ((double) M_PI)) + (((double) M_PI) * 0.5))))) + (sin((-((double) M_PI) * fabs(z0))) * sin((fabs(z0) * ((double) M_PI))));
    	} else {
    		tmp = 1.0;
    	}
    	return tmp;
    }
    
    public static double code(double z0) {
    	double tmp;
    	if (Math.abs(z0) <= 85000.0) {
    		tmp = (0.5 + (0.5 * Math.sin((((-2.0 * Math.abs(z0)) * Math.PI) + (Math.PI * 0.5))))) + (Math.sin((-Math.PI * Math.abs(z0))) * Math.sin((Math.abs(z0) * Math.PI)));
    	} else {
    		tmp = 1.0;
    	}
    	return tmp;
    }
    
    def code(z0):
    	tmp = 0
    	if math.fabs(z0) <= 85000.0:
    		tmp = (0.5 + (0.5 * math.sin((((-2.0 * math.fabs(z0)) * math.pi) + (math.pi * 0.5))))) + (math.sin((-math.pi * math.fabs(z0))) * math.sin((math.fabs(z0) * math.pi)))
    	else:
    		tmp = 1.0
    	return tmp
    
    function code(z0)
    	tmp = 0.0
    	if (abs(z0) <= 85000.0)
    		tmp = Float64(Float64(0.5 + Float64(0.5 * sin(Float64(Float64(Float64(-2.0 * abs(z0)) * pi) + Float64(pi * 0.5))))) + Float64(sin(Float64(Float64(-pi) * abs(z0))) * sin(Float64(abs(z0) * pi))));
    	else
    		tmp = 1.0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(z0)
    	tmp = 0.0;
    	if (abs(z0) <= 85000.0)
    		tmp = (0.5 + (0.5 * sin((((-2.0 * abs(z0)) * pi) + (pi * 0.5))))) + (sin((-pi * abs(z0))) * sin((abs(z0) * pi)));
    	else
    		tmp = 1.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[z0_] := If[LessEqual[N[Abs[z0], $MachinePrecision], 85000.0], N[(N[(0.5 + N[(0.5 * N[Sin[N[(N[(N[(-2.0 * N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision] + N[(Pi * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[((-Pi) * N[Abs[z0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
    
    \begin{array}{l}
    \mathbf{if}\;\left|z0\right| \leq 85000:\\
    \;\;\;\;\left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot \left|z0\right|\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \sin \left(\left(-\pi\right) \cdot \left|z0\right|\right) \cdot \sin \left(\left|z0\right| \cdot \pi\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;1\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z0 < 85000

      1. Initial program 57.5%

        \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
      2. Applied rewrites57.5%

        \[\leadsto \color{blue}{\left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\left(-\pi\right) \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right)} \]
      3. Step-by-step derivation
        1. lift-sin.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\sin \left(\left(-\pi\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        2. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \color{blue}{\left(\left(-\pi\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        3. lift-neg.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)} \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        4. distribute-lft-neg-outN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \color{blue}{\left(\mathsf{neg}\left(\pi \cdot z0\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        5. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\mathsf{neg}\left(\color{blue}{z0 \cdot \pi}\right)\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        6. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \sin \left(\mathsf{neg}\left(\color{blue}{z0 \cdot \pi}\right)\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        7. sin-neg-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\sin \left(z0 \cdot \pi\right)\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        8. cos-+PI/2-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(z0 \cdot \pi + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        9. lower-cos.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(z0 \cdot \pi + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        10. +-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + z0 \cdot \pi\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        11. lower-+.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + z0 \cdot \pi\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        12. lift-PI.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{\color{blue}{\pi}}{2} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        13. mult-flipN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{\pi \cdot \frac{1}{2}} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        14. metadata-evalN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\pi \cdot \color{blue}{\frac{1}{2}} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        15. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{\frac{1}{2} \cdot \pi} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        16. lower-*.f6459.6%

          \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\color{blue}{0.5 \cdot \pi} + z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        17. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \color{blue}{z0 \cdot \pi}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        18. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \color{blue}{\pi \cdot z0}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        19. lower-*.f6459.6%

          \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \cos \left(0.5 \cdot \pi + \color{blue}{\pi \cdot z0}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      4. Applied rewrites59.6%

        \[\leadsto \left(0.5 + 0.5 \cdot \cos \left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\cos \left(0.5 \cdot \pi + \pi \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
      5. Step-by-step derivation
        1. lift-cos.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(\left(z0 + z0\right) \cdot \pi\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        2. cos-neg-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        3. sin-+PI/2-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        4. lower-sin.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \color{blue}{\sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        5. lift-PI.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{\color{blue}{\pi}}{2}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        6. mult-flip-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        7. metadata-evalN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \pi \cdot \color{blue}{\frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        8. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        9. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        10. lower-+.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \color{blue}{\left(\left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right) + \frac{1}{2} \cdot \pi\right)}\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        11. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right) \cdot \pi}\right)\right) + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        12. distribute-lft-neg-inN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\mathsf{neg}\left(\left(z0 + z0\right)\right)\right) \cdot \pi} + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        13. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\mathsf{neg}\left(\left(z0 + z0\right)\right)\right) \cdot \pi} + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        14. lift-+.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right)}\right)\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        15. count-2N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\mathsf{neg}\left(\color{blue}{2 \cdot z0}\right)\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        16. distribute-lft-neg-inN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\color{blue}{\left(\left(\mathsf{neg}\left(2\right)\right) \cdot z0\right)} \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        17. metadata-evalN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(\color{blue}{-2} \cdot z0\right) \cdot \pi + \frac{1}{2} \cdot \pi\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        18. lower-*.f6460.9%

          \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\color{blue}{\left(-2 \cdot z0\right)} \cdot \pi + 0.5 \cdot \pi\right)\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        19. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\frac{1}{2} \cdot \pi}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        20. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\pi \cdot \frac{1}{2}}\right)\right) + \cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        21. lower-*.f6460.9%

          \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \color{blue}{\pi \cdot 0.5}\right)\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      6. Applied rewrites60.9%

        \[\leadsto \left(0.5 + 0.5 \cdot \color{blue}{\sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot 0.5\right)}\right) + \cos \left(0.5 \cdot \pi + \pi \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      7. Step-by-step derivation
        1. lift-cos.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\cos \left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        2. lift-+.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \color{blue}{\left(\frac{1}{2} \cdot \pi + \pi \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        3. +-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \color{blue}{\left(\pi \cdot z0 + \frac{1}{2} \cdot \pi\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        4. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \left(\pi \cdot z0 + \color{blue}{\frac{1}{2} \cdot \pi}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        5. *-commutativeN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \left(\pi \cdot z0 + \color{blue}{\pi \cdot \frac{1}{2}}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        6. metadata-evalN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \left(\pi \cdot z0 + \pi \cdot \color{blue}{\frac{1}{2}}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        7. mult-flip-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \left(\pi \cdot z0 + \color{blue}{\frac{\pi}{2}}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        8. lift-PI.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \cos \left(\pi \cdot z0 + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        9. cos-+PI/2-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\sin \left(\pi \cdot z0\right)\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        10. sin-neg-revN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\sin \left(\mathsf{neg}\left(\pi \cdot z0\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        11. lower-sin.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \color{blue}{\sin \left(\mathsf{neg}\left(\pi \cdot z0\right)\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        12. lift-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \left(\mathsf{neg}\left(\color{blue}{\pi \cdot z0}\right)\right) \cdot \sin \left(z0 \cdot \pi\right) \]
        13. distribute-lft-neg-outN/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \color{blue}{\left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        14. lower-*.f64N/A

          \[\leadsto \left(\frac{1}{2} + \frac{1}{2} \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot \frac{1}{2}\right)\right) + \sin \color{blue}{\left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]
        15. lower-neg.f6456.8%

          \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \sin \left(\color{blue}{\left(-\pi\right)} \cdot z0\right) \cdot \sin \left(z0 \cdot \pi\right) \]
      8. Applied rewrites56.8%

        \[\leadsto \left(0.5 + 0.5 \cdot \sin \left(\left(-2 \cdot z0\right) \cdot \pi + \pi \cdot 0.5\right)\right) + \color{blue}{\sin \left(\left(-\pi\right) \cdot z0\right)} \cdot \sin \left(z0 \cdot \pi\right) \]

      if 85000 < z0

      1. Initial program 57.5%

        \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
      2. Taylor expanded in z0 around 0

        \[\leadsto \color{blue}{1} \]
      3. Step-by-step derivation
        1. Applied rewrites97.2%

          \[\leadsto \color{blue}{1} \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 3: 98.5% accurate, 0.9× speedup?

      \[\begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 85000:\\ \;\;\;\;\sin \left(\left(0.5 - \left(\left|z0\right| + \left|z0\right|\right)\right) \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
      (FPCore (z0)
        :precision binary64
        (if (<= (fabs z0) 85000.0)
        (sin (* (- 0.5 (+ (fabs z0) (fabs z0))) PI))
        1.0))
      double code(double z0) {
      	double tmp;
      	if (fabs(z0) <= 85000.0) {
      		tmp = sin(((0.5 - (fabs(z0) + fabs(z0))) * ((double) M_PI)));
      	} else {
      		tmp = 1.0;
      	}
      	return tmp;
      }
      
      public static double code(double z0) {
      	double tmp;
      	if (Math.abs(z0) <= 85000.0) {
      		tmp = Math.sin(((0.5 - (Math.abs(z0) + Math.abs(z0))) * Math.PI));
      	} else {
      		tmp = 1.0;
      	}
      	return tmp;
      }
      
      def code(z0):
      	tmp = 0
      	if math.fabs(z0) <= 85000.0:
      		tmp = math.sin(((0.5 - (math.fabs(z0) + math.fabs(z0))) * math.pi))
      	else:
      		tmp = 1.0
      	return tmp
      
      function code(z0)
      	tmp = 0.0
      	if (abs(z0) <= 85000.0)
      		tmp = sin(Float64(Float64(0.5 - Float64(abs(z0) + abs(z0))) * pi));
      	else
      		tmp = 1.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(z0)
      	tmp = 0.0;
      	if (abs(z0) <= 85000.0)
      		tmp = sin(((0.5 - (abs(z0) + abs(z0))) * pi));
      	else
      		tmp = 1.0;
      	end
      	tmp_2 = tmp;
      end
      
      code[z0_] := If[LessEqual[N[Abs[z0], $MachinePrecision], 85000.0], N[Sin[N[(N[(0.5 - N[(N[Abs[z0], $MachinePrecision] + N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], 1.0]
      
      \begin{array}{l}
      \mathbf{if}\;\left|z0\right| \leq 85000:\\
      \;\;\;\;\sin \left(\left(0.5 - \left(\left|z0\right| + \left|z0\right|\right)\right) \cdot \pi\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;1\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z0 < 85000

        1. Initial program 57.5%

          \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
        2. Step-by-step derivation
          1. lift-cos.f64N/A

            \[\leadsto \color{blue}{\cos \left(\pi \cdot \left(z0 + z0\right)\right)} \]
          2. sin-+PI/2-revN/A

            \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(z0 + z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
          3. lower-sin.f64N/A

            \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(z0 + z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
          4. +-commutativeN/A

            \[\leadsto \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + \pi \cdot \left(z0 + z0\right)\right)} \]
          5. lift-PI.f64N/A

            \[\leadsto \sin \left(\frac{\color{blue}{\pi}}{2} + \pi \cdot \left(z0 + z0\right)\right) \]
          6. mult-flipN/A

            \[\leadsto \sin \left(\color{blue}{\pi \cdot \frac{1}{2}} + \pi \cdot \left(z0 + z0\right)\right) \]
          7. lift-*.f64N/A

            \[\leadsto \sin \left(\pi \cdot \frac{1}{2} + \color{blue}{\pi \cdot \left(z0 + z0\right)}\right) \]
          8. distribute-lft-outN/A

            \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
          9. lower-*.f64N/A

            \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
          10. lower-+.f64N/A

            \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(\frac{1}{2} + \left(z0 + z0\right)\right)}\right) \]
          11. metadata-eval57.5%

            \[\leadsto \sin \left(\pi \cdot \left(\color{blue}{0.5} + \left(z0 + z0\right)\right)\right) \]
        3. Applied rewrites57.5%

          \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)} \]
        4. Step-by-step derivation
          1. lift-sin.f64N/A

            \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
          2. lift-*.f64N/A

            \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
          3. lift-+.f64N/A

            \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(\frac{1}{2} + \left(z0 + z0\right)\right)}\right) \]
          4. +-commutativeN/A

            \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(\left(z0 + z0\right) + \frac{1}{2}\right)}\right) \]
          5. distribute-lft-inN/A

            \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(z0 + z0\right) + \pi \cdot \frac{1}{2}\right)} \]
          6. *-commutativeN/A

            \[\leadsto \sin \left(\color{blue}{\left(z0 + z0\right) \cdot \pi} + \pi \cdot \frac{1}{2}\right) \]
          7. lift-*.f64N/A

            \[\leadsto \sin \left(\color{blue}{\left(z0 + z0\right) \cdot \pi} + \pi \cdot \frac{1}{2}\right) \]
          8. metadata-evalN/A

            \[\leadsto \sin \left(\left(z0 + z0\right) \cdot \pi + \pi \cdot \color{blue}{\frac{1}{2}}\right) \]
          9. mult-flipN/A

            \[\leadsto \sin \left(\left(z0 + z0\right) \cdot \pi + \color{blue}{\frac{\pi}{2}}\right) \]
          10. lift-PI.f64N/A

            \[\leadsto \sin \left(\left(z0 + z0\right) \cdot \pi + \frac{\color{blue}{\mathsf{PI}\left(\right)}}{2}\right) \]
          11. sin-+PI/2-revN/A

            \[\leadsto \color{blue}{\cos \left(\left(z0 + z0\right) \cdot \pi\right)} \]
          12. cos-neg-revN/A

            \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\left(z0 + z0\right) \cdot \pi\right)\right)} \]
          13. lift-*.f64N/A

            \[\leadsto \cos \left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right) \cdot \pi}\right)\right) \]
          14. *-commutativeN/A

            \[\leadsto \cos \left(\mathsf{neg}\left(\color{blue}{\pi \cdot \left(z0 + z0\right)}\right)\right) \]
          15. distribute-rgt-neg-inN/A

            \[\leadsto \cos \color{blue}{\left(\pi \cdot \left(\mathsf{neg}\left(\left(z0 + z0\right)\right)\right)\right)} \]
          16. lift-+.f64N/A

            \[\leadsto \cos \left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{\left(z0 + z0\right)}\right)\right)\right) \]
          17. count-2N/A

            \[\leadsto \cos \left(\pi \cdot \left(\mathsf{neg}\left(\color{blue}{2 \cdot z0}\right)\right)\right) \]
          18. distribute-lft-neg-inN/A

            \[\leadsto \cos \left(\pi \cdot \color{blue}{\left(\left(\mathsf{neg}\left(2\right)\right) \cdot z0\right)}\right) \]
          19. metadata-evalN/A

            \[\leadsto \cos \left(\pi \cdot \left(\color{blue}{-2} \cdot z0\right)\right) \]
          20. lift-*.f64N/A

            \[\leadsto \cos \left(\pi \cdot \color{blue}{\left(-2 \cdot z0\right)}\right) \]
          21. sin-+PI/2-revN/A

            \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(-2 \cdot z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
        5. Applied rewrites57.5%

          \[\leadsto \color{blue}{\sin \left(\left(0.5 - \left(z0 + z0\right)\right) \cdot \pi\right)} \]

        if 85000 < z0

        1. Initial program 57.5%

          \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
        2. Taylor expanded in z0 around 0

          \[\leadsto \color{blue}{1} \]
        3. Step-by-step derivation
          1. Applied rewrites97.2%

            \[\leadsto \color{blue}{1} \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 4: 98.5% accurate, 0.9× speedup?

        \[\begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 85000:\\ \;\;\;\;\sin \left(\pi \cdot \left(0.5 + \left(\left|z0\right| + \left|z0\right|\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
        (FPCore (z0)
          :precision binary64
          (if (<= (fabs z0) 85000.0)
          (sin (* PI (+ 0.5 (+ (fabs z0) (fabs z0)))))
          1.0))
        double code(double z0) {
        	double tmp;
        	if (fabs(z0) <= 85000.0) {
        		tmp = sin((((double) M_PI) * (0.5 + (fabs(z0) + fabs(z0)))));
        	} else {
        		tmp = 1.0;
        	}
        	return tmp;
        }
        
        public static double code(double z0) {
        	double tmp;
        	if (Math.abs(z0) <= 85000.0) {
        		tmp = Math.sin((Math.PI * (0.5 + (Math.abs(z0) + Math.abs(z0)))));
        	} else {
        		tmp = 1.0;
        	}
        	return tmp;
        }
        
        def code(z0):
        	tmp = 0
        	if math.fabs(z0) <= 85000.0:
        		tmp = math.sin((math.pi * (0.5 + (math.fabs(z0) + math.fabs(z0)))))
        	else:
        		tmp = 1.0
        	return tmp
        
        function code(z0)
        	tmp = 0.0
        	if (abs(z0) <= 85000.0)
        		tmp = sin(Float64(pi * Float64(0.5 + Float64(abs(z0) + abs(z0)))));
        	else
        		tmp = 1.0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(z0)
        	tmp = 0.0;
        	if (abs(z0) <= 85000.0)
        		tmp = sin((pi * (0.5 + (abs(z0) + abs(z0)))));
        	else
        		tmp = 1.0;
        	end
        	tmp_2 = tmp;
        end
        
        code[z0_] := If[LessEqual[N[Abs[z0], $MachinePrecision], 85000.0], N[Sin[N[(Pi * N[(0.5 + N[(N[Abs[z0], $MachinePrecision] + N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
        
        \begin{array}{l}
        \mathbf{if}\;\left|z0\right| \leq 85000:\\
        \;\;\;\;\sin \left(\pi \cdot \left(0.5 + \left(\left|z0\right| + \left|z0\right|\right)\right)\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;1\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z0 < 85000

          1. Initial program 57.5%

            \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
          2. Step-by-step derivation
            1. lift-cos.f64N/A

              \[\leadsto \color{blue}{\cos \left(\pi \cdot \left(z0 + z0\right)\right)} \]
            2. sin-+PI/2-revN/A

              \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(z0 + z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
            3. lower-sin.f64N/A

              \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(z0 + z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
            4. +-commutativeN/A

              \[\leadsto \sin \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{2} + \pi \cdot \left(z0 + z0\right)\right)} \]
            5. lift-PI.f64N/A

              \[\leadsto \sin \left(\frac{\color{blue}{\pi}}{2} + \pi \cdot \left(z0 + z0\right)\right) \]
            6. mult-flipN/A

              \[\leadsto \sin \left(\color{blue}{\pi \cdot \frac{1}{2}} + \pi \cdot \left(z0 + z0\right)\right) \]
            7. lift-*.f64N/A

              \[\leadsto \sin \left(\pi \cdot \frac{1}{2} + \color{blue}{\pi \cdot \left(z0 + z0\right)}\right) \]
            8. distribute-lft-outN/A

              \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
            9. lower-*.f64N/A

              \[\leadsto \sin \color{blue}{\left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)} \]
            10. lower-+.f64N/A

              \[\leadsto \sin \left(\pi \cdot \color{blue}{\left(\frac{1}{2} + \left(z0 + z0\right)\right)}\right) \]
            11. metadata-eval57.5%

              \[\leadsto \sin \left(\pi \cdot \left(\color{blue}{0.5} + \left(z0 + z0\right)\right)\right) \]
          3. Applied rewrites57.5%

            \[\leadsto \color{blue}{\sin \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)} \]

          if 85000 < z0

          1. Initial program 57.5%

            \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
          2. Taylor expanded in z0 around 0

            \[\leadsto \color{blue}{1} \]
          3. Step-by-step derivation
            1. Applied rewrites97.2%

              \[\leadsto \color{blue}{1} \]
          4. Recombined 2 regimes into one program.
          5. Add Preprocessing

          Alternative 5: 98.5% accurate, 0.9× speedup?

          \[\begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 85000:\\ \;\;\;\;\cos \left(\pi \cdot \left(\left|z0\right| + \left|z0\right|\right)\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
          (FPCore (z0)
            :precision binary64
            (if (<= (fabs z0) 85000.0) (cos (* PI (+ (fabs z0) (fabs z0)))) 1.0))
          double code(double z0) {
          	double tmp;
          	if (fabs(z0) <= 85000.0) {
          		tmp = cos((((double) M_PI) * (fabs(z0) + fabs(z0))));
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          public static double code(double z0) {
          	double tmp;
          	if (Math.abs(z0) <= 85000.0) {
          		tmp = Math.cos((Math.PI * (Math.abs(z0) + Math.abs(z0))));
          	} else {
          		tmp = 1.0;
          	}
          	return tmp;
          }
          
          def code(z0):
          	tmp = 0
          	if math.fabs(z0) <= 85000.0:
          		tmp = math.cos((math.pi * (math.fabs(z0) + math.fabs(z0))))
          	else:
          		tmp = 1.0
          	return tmp
          
          function code(z0)
          	tmp = 0.0
          	if (abs(z0) <= 85000.0)
          		tmp = cos(Float64(pi * Float64(abs(z0) + abs(z0))));
          	else
          		tmp = 1.0;
          	end
          	return tmp
          end
          
          function tmp_2 = code(z0)
          	tmp = 0.0;
          	if (abs(z0) <= 85000.0)
          		tmp = cos((pi * (abs(z0) + abs(z0))));
          	else
          		tmp = 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[z0_] := If[LessEqual[N[Abs[z0], $MachinePrecision], 85000.0], N[Cos[N[(Pi * N[(N[Abs[z0], $MachinePrecision] + N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1.0]
          
          \begin{array}{l}
          \mathbf{if}\;\left|z0\right| \leq 85000:\\
          \;\;\;\;\cos \left(\pi \cdot \left(\left|z0\right| + \left|z0\right|\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;1\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if z0 < 85000

            1. Initial program 57.5%

              \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]

            if 85000 < z0

            1. Initial program 57.5%

              \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
            2. Taylor expanded in z0 around 0

              \[\leadsto \color{blue}{1} \]
            3. Step-by-step derivation
              1. Applied rewrites97.2%

                \[\leadsto \color{blue}{1} \]
            4. Recombined 2 regimes into one program.
            5. Add Preprocessing

            Alternative 6: 97.2% accurate, 109.0× speedup?

            \[1 \]
            (FPCore (z0)
              :precision binary64
              1.0)
            double code(double z0) {
            	return 1.0;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(z0)
            use fmin_fmax_functions
                real(8), intent (in) :: z0
                code = 1.0d0
            end function
            
            public static double code(double z0) {
            	return 1.0;
            }
            
            def code(z0):
            	return 1.0
            
            function code(z0)
            	return 1.0
            end
            
            function tmp = code(z0)
            	tmp = 1.0;
            end
            
            code[z0_] := 1.0
            
            1
            
            Derivation
            1. Initial program 57.5%

              \[\cos \left(\pi \cdot \left(z0 + z0\right)\right) \]
            2. Taylor expanded in z0 around 0

              \[\leadsto \color{blue}{1} \]
            3. Step-by-step derivation
              1. Applied rewrites97.2%

                \[\leadsto \color{blue}{1} \]
              2. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2025250 
              (FPCore (z0)
                :name "(cos (* PI (+ z0 z0)))"
                :precision binary64
                (cos (* PI (+ z0 z0))))