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

Percentage Accurate: 56.9% → 98.7%
Time: 8.8s
Alternatives: 11
Speedup: 1.0×

Specification

?
\[\cos \left(\left(\pi + \pi\right) \cdot z0\right) \]
(FPCore (z0)
  :precision binary64
  (cos (* (+ PI PI) z0)))
double code(double z0) {
	return cos(((((double) M_PI) + ((double) M_PI)) * z0));
}
public static double code(double z0) {
	return Math.cos(((Math.PI + Math.PI) * z0));
}
def code(z0):
	return math.cos(((math.pi + math.pi) * z0))
function code(z0)
	return cos(Float64(Float64(pi + pi) * z0))
end
function tmp = code(z0)
	tmp = cos(((pi + pi) * z0));
end
code[z0_] := N[Cos[N[(N[(Pi + Pi), $MachinePrecision] * z0), $MachinePrecision]], $MachinePrecision]
\cos \left(\left(\pi + \pi\right) \cdot z0\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 11 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: 56.9% accurate, 1.0× speedup?

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

Alternative 1: 98.7% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \left|z0\right| \cdot \pi\\ {\cos t\_0}^{2} + \sin t\_0 \cdot \sin \left(t\_0 + \pi\right) \end{array} \]
(FPCore (z0)
  :precision binary64
  (let* ((t_0 (* (fabs z0) PI)))
  (+ (pow (cos t_0) 2) (* (sin t_0) (sin (+ t_0 PI))))))
double code(double z0) {
	double t_0 = fabs(z0) * ((double) M_PI);
	return pow(cos(t_0), 2.0) + (sin(t_0) * sin((t_0 + ((double) M_PI))));
}
public static double code(double z0) {
	double t_0 = Math.abs(z0) * Math.PI;
	return Math.pow(Math.cos(t_0), 2.0) + (Math.sin(t_0) * Math.sin((t_0 + Math.PI)));
}
def code(z0):
	t_0 = math.fabs(z0) * math.pi
	return math.pow(math.cos(t_0), 2.0) + (math.sin(t_0) * math.sin((t_0 + math.pi)))
function code(z0)
	t_0 = Float64(abs(z0) * pi)
	return Float64((cos(t_0) ^ 2.0) + Float64(sin(t_0) * sin(Float64(t_0 + pi))))
end
function tmp = code(z0)
	t_0 = abs(z0) * pi;
	tmp = (cos(t_0) ^ 2.0) + (sin(t_0) * sin((t_0 + pi)));
end
code[z0_] := Block[{t$95$0 = N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[Power[N[Cos[t$95$0], $MachinePrecision], 2], $MachinePrecision] + N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[N[(t$95$0 + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|z0\right| \cdot \pi\\
{\cos t\_0}^{2} + \sin t\_0 \cdot \sin \left(t\_0 + \pi\right)
\end{array}
Derivation
  1. Initial program 56.9%

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

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

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

      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\pi + \pi\right) \cdot z0\right)\right)\right)\right)} \]
    4. remove-double-negN/A

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

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

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

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

      \[\leadsto \cos \color{blue}{\left(\pi \cdot z0 + \pi \cdot z0\right)} \]
    9. fp-cancel-sign-sub-invN/A

      \[\leadsto \cos \color{blue}{\left(\pi \cdot z0 - \left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \]
    10. cos-diffN/A

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

      \[\leadsto \color{blue}{\cos \left(\pi \cdot z0\right) \cdot \cos \left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right) + \sin \left(\pi \cdot z0\right) \cdot \sin \left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \]
  3. Applied rewrites56.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(z0 \cdot \pi\right) \cdot \cos \left(\left(-\pi\right) \cdot z0\right) + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \color{blue}{\pi}\right) \]
    11. lower-+.f6498.5%

      \[\leadsto \cos \left(z0 \cdot \pi\right) \cdot \cos \left(\left(-\pi\right) \cdot z0\right) + \sin \left(z0 \cdot \pi\right) \cdot \sin \color{blue}{\left(z0 \cdot \pi + \pi\right)} \]
  5. Applied rewrites98.5%

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

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

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

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

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

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

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

      \[\leadsto \cos \left(z0 \cdot \pi\right) \cdot \color{blue}{\cos \left(z0 \cdot \pi\right)} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
    8. lift-cos.f6498.5%

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

      \[\leadsto \color{blue}{\cos \left(z0 \cdot \pi\right) \cdot \cos \left(z0 \cdot \pi\right)} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
    10. pow2N/A

      \[\leadsto \color{blue}{{\cos \left(z0 \cdot \pi\right)}^{2}} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
    11. lower-pow.f6498.5%

      \[\leadsto \color{blue}{{\cos \left(z0 \cdot \pi\right)}^{2}} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
  7. Applied rewrites98.5%

    \[\leadsto \color{blue}{{\cos \left(z0 \cdot \pi\right)}^{2}} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
  8. Add Preprocessing

Alternative 2: 98.7% accurate, 0.3× speedup?

\[\frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) - z0 \cdot \pi\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) + z0\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
(FPCore (z0)
  :precision binary64
  (+
 (/
  (-
   (cos (- (- (* (- z0 -1/2) PI) (* -1/2 PI)) (* z0 PI)))
   (cos (- (* (+ (- z0 -1/2) z0) PI) (* -1/2 PI))))
  2)
 (+ 1/2 (* 1/2 (cos (* z0 (+ PI PI)))))))
double code(double z0) {
	return ((cos(((((z0 - -0.5) * ((double) M_PI)) - (-0.5 * ((double) M_PI))) - (z0 * ((double) M_PI)))) - cos(((((z0 - -0.5) + z0) * ((double) M_PI)) - (-0.5 * ((double) M_PI))))) / 2.0) + (0.5 + (0.5 * cos((z0 * (((double) M_PI) + ((double) M_PI))))));
}
public static double code(double z0) {
	return ((Math.cos(((((z0 - -0.5) * Math.PI) - (-0.5 * Math.PI)) - (z0 * Math.PI))) - Math.cos(((((z0 - -0.5) + z0) * Math.PI) - (-0.5 * Math.PI)))) / 2.0) + (0.5 + (0.5 * Math.cos((z0 * (Math.PI + Math.PI)))));
}
def code(z0):
	return ((math.cos(((((z0 - -0.5) * math.pi) - (-0.5 * math.pi)) - (z0 * math.pi))) - math.cos(((((z0 - -0.5) + z0) * math.pi) - (-0.5 * math.pi)))) / 2.0) + (0.5 + (0.5 * math.cos((z0 * (math.pi + math.pi)))))
function code(z0)
	return Float64(Float64(Float64(cos(Float64(Float64(Float64(Float64(z0 - -0.5) * pi) - Float64(-0.5 * pi)) - Float64(z0 * pi))) - cos(Float64(Float64(Float64(Float64(z0 - -0.5) + z0) * pi) - Float64(-0.5 * pi)))) / 2.0) + Float64(0.5 + Float64(0.5 * cos(Float64(z0 * Float64(pi + pi))))))
end
function tmp = code(z0)
	tmp = ((cos(((((z0 - -0.5) * pi) - (-0.5 * pi)) - (z0 * pi))) - cos(((((z0 - -0.5) + z0) * pi) - (-0.5 * pi)))) / 2.0) + (0.5 + (0.5 * cos((z0 * (pi + pi)))));
end
code[z0_] := N[(N[(N[(N[Cos[N[(N[(N[(N[(z0 - -1/2), $MachinePrecision] * Pi), $MachinePrecision] - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision] - N[(z0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(N[(N[(N[(z0 - -1/2), $MachinePrecision] + z0), $MachinePrecision] * Pi), $MachinePrecision] - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision] + N[(1/2 + N[(1/2 * N[Cos[N[(z0 * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) - z0 \cdot \pi\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) + z0\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right)
Derivation
  1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right)} \]
  3. Applied rewrites59.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) - z0 \cdot \pi\right) - \cos \color{blue}{\left(\left(z0 \cdot \pi + \left(z0 - \frac{-1}{2}\right) \cdot \pi\right) - \frac{-1}{2} \cdot \pi\right)}}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  7. Applied rewrites98.7%

    \[\leadsto \frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) - z0 \cdot \pi\right) - \cos \color{blue}{\left(\left(\left(z0 - \frac{-1}{2}\right) + z0\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right)}}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  8. Add Preprocessing

Alternative 3: 98.6% accurate, 0.3× speedup?

\[\frac{\cos \left(\pi \cdot \left(\left(\left|z0\right| - -1\right) - \left|z0\right|\right)\right) - \cos \left(\left(\left(\left|z0\right| - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + \left|z0\right| \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right)\right) \]
(FPCore (z0)
  :precision binary64
  (+
 (/
  (-
   (cos (* PI (- (- (fabs z0) -1) (fabs z0))))
   (cos
    (+ (- (* (- (fabs z0) -1/2) PI) (* -1/2 PI)) (* (fabs z0) PI))))
  2)
 (+ 1/2 (* 1/2 (cos (* (fabs z0) (+ PI PI)))))))
double code(double z0) {
	return ((cos((((double) M_PI) * ((fabs(z0) - -1.0) - fabs(z0)))) - cos(((((fabs(z0) - -0.5) * ((double) M_PI)) - (-0.5 * ((double) M_PI))) + (fabs(z0) * ((double) M_PI))))) / 2.0) + (0.5 + (0.5 * cos((fabs(z0) * (((double) M_PI) + ((double) M_PI))))));
}
public static double code(double z0) {
	return ((Math.cos((Math.PI * ((Math.abs(z0) - -1.0) - Math.abs(z0)))) - Math.cos(((((Math.abs(z0) - -0.5) * Math.PI) - (-0.5 * Math.PI)) + (Math.abs(z0) * Math.PI)))) / 2.0) + (0.5 + (0.5 * Math.cos((Math.abs(z0) * (Math.PI + Math.PI)))));
}
def code(z0):
	return ((math.cos((math.pi * ((math.fabs(z0) - -1.0) - math.fabs(z0)))) - math.cos(((((math.fabs(z0) - -0.5) * math.pi) - (-0.5 * math.pi)) + (math.fabs(z0) * math.pi)))) / 2.0) + (0.5 + (0.5 * math.cos((math.fabs(z0) * (math.pi + math.pi)))))
function code(z0)
	return Float64(Float64(Float64(cos(Float64(pi * Float64(Float64(abs(z0) - -1.0) - abs(z0)))) - cos(Float64(Float64(Float64(Float64(abs(z0) - -0.5) * pi) - Float64(-0.5 * pi)) + Float64(abs(z0) * pi)))) / 2.0) + Float64(0.5 + Float64(0.5 * cos(Float64(abs(z0) * Float64(pi + pi))))))
end
function tmp = code(z0)
	tmp = ((cos((pi * ((abs(z0) - -1.0) - abs(z0)))) - cos(((((abs(z0) - -0.5) * pi) - (-0.5 * pi)) + (abs(z0) * pi)))) / 2.0) + (0.5 + (0.5 * cos((abs(z0) * (pi + pi)))));
end
code[z0_] := N[(N[(N[(N[Cos[N[(Pi * N[(N[(N[Abs[z0], $MachinePrecision] - -1), $MachinePrecision] - N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(N[(N[(N[(N[Abs[z0], $MachinePrecision] - -1/2), $MachinePrecision] * Pi), $MachinePrecision] - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2), $MachinePrecision] + N[(1/2 + N[(1/2 * N[Cos[N[(N[Abs[z0], $MachinePrecision] * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\cos \left(\pi \cdot \left(\left(\left|z0\right| - -1\right) - \left|z0\right|\right)\right) - \cos \left(\left(\left(\left|z0\right| - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + \left|z0\right| \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right)\right)
Derivation
  1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right)} \]
  3. Applied rewrites59.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \color{blue}{\frac{-1}{2} \cdot \pi}\right) - z0 \cdot \pi\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + z0 \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
    5. distribute-rgt-out--N/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(\pi \cdot \left(\left(z0 - \color{blue}{-1}\right) - z0\right)\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + z0 \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
    14. lower--.f6498.7%

      \[\leadsto \frac{\cos \left(\pi \cdot \left(\color{blue}{\left(z0 - -1\right)} - z0\right)\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + z0 \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  7. Applied rewrites98.7%

    \[\leadsto \frac{\cos \color{blue}{\left(\pi \cdot \left(\left(z0 - -1\right) - z0\right)\right)} - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + z0 \cdot \pi\right)}{2} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  8. Add Preprocessing

Alternative 4: 98.6% accurate, 0.3× speedup?

\[\left(\sin \left(\left(\left(1 - \frac{-1}{\left|z0\right|}\right) \cdot \left|z0\right|\right) \cdot \pi\right) \cdot \sin \left(\left|z0\right| \cdot \pi\right) - \frac{-1}{2}\right) - \frac{-1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right) \]
(FPCore (z0)
  :precision binary64
  (-
 (-
  (*
   (sin (* (* (- 1 (/ -1 (fabs z0))) (fabs z0)) PI))
   (sin (* (fabs z0) PI)))
  -1/2)
 (* -1/2 (cos (* (fabs z0) (+ PI PI))))))
double code(double z0) {
	return ((sin((((1.0 - (-1.0 / fabs(z0))) * fabs(z0)) * ((double) M_PI))) * sin((fabs(z0) * ((double) M_PI)))) - -0.5) - (-0.5 * cos((fabs(z0) * (((double) M_PI) + ((double) M_PI)))));
}
public static double code(double z0) {
	return ((Math.sin((((1.0 - (-1.0 / Math.abs(z0))) * Math.abs(z0)) * Math.PI)) * Math.sin((Math.abs(z0) * Math.PI))) - -0.5) - (-0.5 * Math.cos((Math.abs(z0) * (Math.PI + Math.PI))));
}
def code(z0):
	return ((math.sin((((1.0 - (-1.0 / math.fabs(z0))) * math.fabs(z0)) * math.pi)) * math.sin((math.fabs(z0) * math.pi))) - -0.5) - (-0.5 * math.cos((math.fabs(z0) * (math.pi + math.pi))))
function code(z0)
	return Float64(Float64(Float64(sin(Float64(Float64(Float64(1.0 - Float64(-1.0 / abs(z0))) * abs(z0)) * pi)) * sin(Float64(abs(z0) * pi))) - -0.5) - Float64(-0.5 * cos(Float64(abs(z0) * Float64(pi + pi)))))
end
function tmp = code(z0)
	tmp = ((sin((((1.0 - (-1.0 / abs(z0))) * abs(z0)) * pi)) * sin((abs(z0) * pi))) - -0.5) - (-0.5 * cos((abs(z0) * (pi + pi))));
end
code[z0_] := N[(N[(N[(N[Sin[N[(N[(N[(1 - N[(-1 / N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -1/2), $MachinePrecision] - N[(-1/2 * N[Cos[N[(N[Abs[z0], $MachinePrecision] * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\sin \left(\left(\left(1 - \frac{-1}{\left|z0\right|}\right) \cdot \left|z0\right|\right) \cdot \pi\right) \cdot \sin \left(\left|z0\right| \cdot \pi\right) - \frac{-1}{2}\right) - \frac{-1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right)
Derivation
  1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right)} \]
  3. Applied rewrites59.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{\cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) - z0 \cdot \pi\right) - \cos \left(\left(\left(z0 - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + z0 \cdot \pi\right)}{2} + \frac{1}{2}\right) - \left(\mathsf{neg}\left(\frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right)\right)} \]
  7. Applied rewrites98.5%

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

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

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

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

      \[\leadsto \left(\sin \left(\left(\color{blue}{\left(1 - \frac{-1}{z0}\right)} \cdot z0\right) \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) - \frac{-1}{2}\right) - \frac{-1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right) \]
    5. lower-unsound-/.f6498.5%

      \[\leadsto \left(\sin \left(\left(\left(1 - \color{blue}{\frac{-1}{z0}}\right) \cdot z0\right) \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) - \frac{-1}{2}\right) - \frac{-1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right) \]
  9. Applied rewrites98.5%

    \[\leadsto \left(\sin \left(\color{blue}{\left(\left(1 - \frac{-1}{z0}\right) \cdot z0\right)} \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi\right) - \frac{-1}{2}\right) - \frac{-1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right) \]
  10. Add Preprocessing

Alternative 5: 98.5% accurate, 0.3× speedup?

\[\sin \left(\left|z0\right| \cdot \pi\right) \cdot \sin \left(\left(\left|z0\right| - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right)\right) \]
(FPCore (z0)
  :precision binary64
  (+
 (*
  (sin (* (fabs z0) PI))
  (sin (- (* (- (fabs z0) -1/2) PI) (* -1/2 PI))))
 (+ 1/2 (* 1/2 (cos (* (fabs z0) (+ PI PI)))))))
double code(double z0) {
	return (sin((fabs(z0) * ((double) M_PI))) * sin((((fabs(z0) - -0.5) * ((double) M_PI)) - (-0.5 * ((double) M_PI))))) + (0.5 + (0.5 * cos((fabs(z0) * (((double) M_PI) + ((double) M_PI))))));
}
public static double code(double z0) {
	return (Math.sin((Math.abs(z0) * Math.PI)) * Math.sin((((Math.abs(z0) - -0.5) * Math.PI) - (-0.5 * Math.PI)))) + (0.5 + (0.5 * Math.cos((Math.abs(z0) * (Math.PI + Math.PI)))));
}
def code(z0):
	return (math.sin((math.fabs(z0) * math.pi)) * math.sin((((math.fabs(z0) - -0.5) * math.pi) - (-0.5 * math.pi)))) + (0.5 + (0.5 * math.cos((math.fabs(z0) * (math.pi + math.pi)))))
function code(z0)
	return Float64(Float64(sin(Float64(abs(z0) * pi)) * sin(Float64(Float64(Float64(abs(z0) - -0.5) * pi) - Float64(-0.5 * pi)))) + Float64(0.5 + Float64(0.5 * cos(Float64(abs(z0) * Float64(pi + pi))))))
end
function tmp = code(z0)
	tmp = (sin((abs(z0) * pi)) * sin((((abs(z0) - -0.5) * pi) - (-0.5 * pi)))) + (0.5 + (0.5 * cos((abs(z0) * (pi + pi)))));
end
code[z0_] := N[(N[(N[Sin[N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(N[(N[Abs[z0], $MachinePrecision] - -1/2), $MachinePrecision] * Pi), $MachinePrecision] - N[(-1/2 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1/2 + N[(1/2 * N[Cos[N[(N[Abs[z0], $MachinePrecision] * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sin \left(\left|z0\right| \cdot \pi\right) \cdot \sin \left(\left(\left|z0\right| - \frac{-1}{2}\right) \cdot \pi - \frac{-1}{2} \cdot \pi\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right)\right)
Derivation
  1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right)} \]
  3. Applied rewrites59.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(z0 \cdot \pi\right) \cdot \sin \left(\left(z0 \cdot \pi + \frac{1}{2} \cdot \pi\right) - \color{blue}{\pi \cdot \frac{-1}{2}}\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
    15. lower--.f6498.7%

      \[\leadsto \sin \left(z0 \cdot \pi\right) \cdot \sin \color{blue}{\left(\left(z0 \cdot \pi + \frac{1}{2} \cdot \pi\right) - \pi \cdot \frac{-1}{2}\right)} + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  5. Applied rewrites98.6%

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

Alternative 6: 98.5% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := \left|z0\right| \cdot \pi\\ \left(\frac{1}{2} + \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right) \cdot \frac{1}{2}\right) + \sin t\_0 \cdot \sin \left(t\_0 + \pi\right) \end{array} \]
(FPCore (z0)
  :precision binary64
  (let* ((t_0 (* (fabs z0) PI)))
  (+
   (+ 1/2 (* (cos (* (fabs z0) (+ PI PI))) 1/2))
   (* (sin t_0) (sin (+ t_0 PI))))))
double code(double z0) {
	double t_0 = fabs(z0) * ((double) M_PI);
	return (0.5 + (cos((fabs(z0) * (((double) M_PI) + ((double) M_PI)))) * 0.5)) + (sin(t_0) * sin((t_0 + ((double) M_PI))));
}
public static double code(double z0) {
	double t_0 = Math.abs(z0) * Math.PI;
	return (0.5 + (Math.cos((Math.abs(z0) * (Math.PI + Math.PI))) * 0.5)) + (Math.sin(t_0) * Math.sin((t_0 + Math.PI)));
}
def code(z0):
	t_0 = math.fabs(z0) * math.pi
	return (0.5 + (math.cos((math.fabs(z0) * (math.pi + math.pi))) * 0.5)) + (math.sin(t_0) * math.sin((t_0 + math.pi)))
function code(z0)
	t_0 = Float64(abs(z0) * pi)
	return Float64(Float64(0.5 + Float64(cos(Float64(abs(z0) * Float64(pi + pi))) * 0.5)) + Float64(sin(t_0) * sin(Float64(t_0 + pi))))
end
function tmp = code(z0)
	t_0 = abs(z0) * pi;
	tmp = (0.5 + (cos((abs(z0) * (pi + pi))) * 0.5)) + (sin(t_0) * sin((t_0 + pi)));
end
code[z0_] := Block[{t$95$0 = N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[(1/2 + N[(N[Cos[N[(N[Abs[z0], $MachinePrecision] * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[N[(t$95$0 + Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|z0\right| \cdot \pi\\
\left(\frac{1}{2} + \cos \left(\left|z0\right| \cdot \left(\pi + \pi\right)\right) \cdot \frac{1}{2}\right) + \sin t\_0 \cdot \sin \left(t\_0 + \pi\right)
\end{array}
Derivation
  1. Initial program 56.9%

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

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

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

      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\left(\pi + \pi\right) \cdot z0\right)\right)\right)\right)} \]
    4. remove-double-negN/A

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

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

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

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

      \[\leadsto \cos \color{blue}{\left(\pi \cdot z0 + \pi \cdot z0\right)} \]
    9. fp-cancel-sign-sub-invN/A

      \[\leadsto \cos \color{blue}{\left(\pi \cdot z0 - \left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \]
    10. cos-diffN/A

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

      \[\leadsto \color{blue}{\cos \left(\pi \cdot z0\right) \cdot \cos \left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right) + \sin \left(\pi \cdot z0\right) \cdot \sin \left(\left(\mathsf{neg}\left(\pi\right)\right) \cdot z0\right)} \]
  3. Applied rewrites56.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(z0 \cdot \pi\right) \cdot \cos \left(\left(-\pi\right) \cdot z0\right) + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \color{blue}{\pi}\right) \]
    11. lower-+.f6498.5%

      \[\leadsto \cos \left(z0 \cdot \pi\right) \cdot \cos \left(\left(-\pi\right) \cdot z0\right) + \sin \left(z0 \cdot \pi\right) \cdot \sin \color{blue}{\left(z0 \cdot \pi + \pi\right)} \]
  5. Applied rewrites98.5%

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

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

      \[\leadsto \color{blue}{\cos \left(z0 \cdot \pi\right)} \cdot \cos \left(\left(-\pi\right) \cdot z0\right) + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
    3. remove-double-negN/A

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\mathsf{neg}\left(\left(-\pi\right) \cdot z0\right)\right) \cdot \color{blue}{\cos \left(\mathsf{neg}\left(\left(-\pi\right) \cdot z0\right)\right)} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
    11. sqr-cos-aN/A

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(\frac{1}{2} + \cos \left(z0 \cdot \left(\pi + \pi\right)\right) \cdot \frac{1}{2}\right)} + \sin \left(z0 \cdot \pi\right) \cdot \sin \left(z0 \cdot \pi + \pi\right) \]
  8. Add Preprocessing

Alternative 7: 59.2% accurate, 0.3× speedup?

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0)) < 0.10000000000000001

    1. Initial program 56.9%

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

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

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

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

        \[\leadsto \cos \left(\color{blue}{\left(2 \cdot \pi\right)} \cdot z0\right) \]
      5. associate-*l*N/A

        \[\leadsto \cos \color{blue}{\left(2 \cdot \left(\pi \cdot z0\right)\right)} \]
      6. cos-2N/A

        \[\leadsto \color{blue}{\cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right) - \sin \left(\pi \cdot z0\right) \cdot \sin \left(\pi \cdot z0\right)} \]
      7. lower--.f64N/A

        \[\leadsto \color{blue}{\cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right) - \sin \left(\pi \cdot z0\right) \cdot \sin \left(\pi \cdot z0\right)} \]
    3. Applied rewrites56.9%

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

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

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

    if 0.10000000000000001 < (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0))

    1. Initial program 56.9%

      \[\cos \left(\left(\pi + \pi\right) \cdot z0\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 59.1% accurate, 0.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0)) < 0.10000000000000001

    1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.10000000000000001 < (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0))

    1. Initial program 56.9%

      \[\cos \left(\left(\pi + \pi\right) \cdot z0\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 59.1% accurate, 0.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0)) < -0.02

    1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sin \left(z0 \cdot \pi + \left(z0 \cdot \pi - \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)} \cdot \pi\right)\right) \]
      13. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

    if -0.02 < (cos.f64 (*.f64 (+.f64 (PI.f64) (PI.f64)) z0))

    1. Initial program 56.9%

      \[\cos \left(\left(\pi + \pi\right) \cdot z0\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 59.0% accurate, 0.3× speedup?

\[\sin \left(z0 \cdot \pi\right) \cdot \cos \left(\left(z0 - \frac{-1}{2}\right) \cdot \pi\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
(FPCore (z0)
  :precision binary64
  (+
 (* (sin (* z0 PI)) (cos (* (- z0 -1/2) PI)))
 (+ 1/2 (* 1/2 (cos (* z0 (+ PI PI)))))))
double code(double z0) {
	return (sin((z0 * ((double) M_PI))) * cos(((z0 - -0.5) * ((double) M_PI)))) + (0.5 + (0.5 * cos((z0 * (((double) M_PI) + ((double) M_PI))))));
}
public static double code(double z0) {
	return (Math.sin((z0 * Math.PI)) * Math.cos(((z0 - -0.5) * Math.PI))) + (0.5 + (0.5 * Math.cos((z0 * (Math.PI + Math.PI)))));
}
def code(z0):
	return (math.sin((z0 * math.pi)) * math.cos(((z0 - -0.5) * math.pi))) + (0.5 + (0.5 * math.cos((z0 * (math.pi + math.pi)))))
function code(z0)
	return Float64(Float64(sin(Float64(z0 * pi)) * cos(Float64(Float64(z0 - -0.5) * pi))) + Float64(0.5 + Float64(0.5 * cos(Float64(z0 * Float64(pi + pi))))))
end
function tmp = code(z0)
	tmp = (sin((z0 * pi)) * cos(((z0 - -0.5) * pi))) + (0.5 + (0.5 * cos((z0 * (pi + pi)))));
end
code[z0_] := N[(N[(N[Sin[N[(z0 * Pi), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(z0 - -1/2), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1/2 + N[(1/2 * N[Cos[N[(z0 * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sin \left(z0 \cdot \pi\right) \cdot \cos \left(\left(z0 - \frac{-1}{2}\right) \cdot \pi\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right)
Derivation
  1. Initial program 56.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0 + \frac{\mathsf{PI}\left(\right)}{2}\right) + \cos \left(\pi \cdot z0\right) \cdot \cos \left(\pi \cdot z0\right)} \]
  3. Applied rewrites59.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \sin \left(z0 \cdot \pi\right) \cdot \cos \left(\color{blue}{\left(z0 - \frac{-1}{2}\right)} \cdot \pi\right) + \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(z0 \cdot \left(\pi + \pi\right)\right)\right) \]
  5. Applied rewrites59.0%

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

Reproduce

?
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0)
  :name "(cos (* (+ PI PI) z0))"
  :precision binary64
  (cos (* (+ PI PI) z0)))