(cos (* -2 (atan (* (/ z1 z2) (tan (* PI (+ 1/2 (+ z0 z0))))))))

Percentage Accurate: 67.3% → 98.3%
Time: 6.7s
Alternatives: 7
Speedup: 1.2×

Specification

?
\[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
(FPCore (z1 z2 z0)
  :precision binary64
  (cos (* -2.0 (atan (* (/ z1 z2) (tan (* PI (+ 0.5 (+ z0 z0)))))))))
double code(double z1, double z2, double z0) {
	return cos((-2.0 * atan(((z1 / z2) * tan((((double) M_PI) * (0.5 + (z0 + z0))))))));
}
public static double code(double z1, double z2, double z0) {
	return Math.cos((-2.0 * Math.atan(((z1 / z2) * Math.tan((Math.PI * (0.5 + (z0 + z0))))))));
}
def code(z1, z2, z0):
	return math.cos((-2.0 * math.atan(((z1 / z2) * math.tan((math.pi * (0.5 + (z0 + z0))))))))
function code(z1, z2, z0)
	return cos(Float64(-2.0 * atan(Float64(Float64(z1 / z2) * tan(Float64(pi * Float64(0.5 + Float64(z0 + z0))))))))
end
function tmp = code(z1, z2, z0)
	tmp = cos((-2.0 * atan(((z1 / z2) * tan((pi * (0.5 + (z0 + z0))))))));
end
code[z1_, z2_, z0_] := N[Cos[N[(-2.0 * N[ArcTan[N[(N[(z1 / z2), $MachinePrecision] * N[Tan[N[(Pi * N[(0.5 + N[(z0 + z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right)

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 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: 67.3% accurate, 1.0× speedup?

\[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
(FPCore (z1 z2 z0)
  :precision binary64
  (cos (* -2.0 (atan (* (/ z1 z2) (tan (* PI (+ 0.5 (+ z0 z0)))))))))
double code(double z1, double z2, double z0) {
	return cos((-2.0 * atan(((z1 / z2) * tan((((double) M_PI) * (0.5 + (z0 + z0))))))));
}
public static double code(double z1, double z2, double z0) {
	return Math.cos((-2.0 * Math.atan(((z1 / z2) * Math.tan((Math.PI * (0.5 + (z0 + z0))))))));
}
def code(z1, z2, z0):
	return math.cos((-2.0 * math.atan(((z1 / z2) * math.tan((math.pi * (0.5 + (z0 + z0))))))))
function code(z1, z2, z0)
	return cos(Float64(-2.0 * atan(Float64(Float64(z1 / z2) * tan(Float64(pi * Float64(0.5 + Float64(z0 + z0))))))))
end
function tmp = code(z1, z2, z0)
	tmp = cos((-2.0 * atan(((z1 / z2) * tan((pi * (0.5 + (z0 + z0))))))));
end
code[z1_, z2_, z0_] := N[Cos[N[(-2.0 * N[ArcTan[N[(N[(z1 / z2), $MachinePrecision] * N[Tan[N[(Pi * N[(0.5 + N[(z0 + z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right)

Alternative 1: 98.3% accurate, 0.8× speedup?

\[\begin{array}{l} t_0 := \left(\pi \cdot \pi\right) \cdot \pi\\ \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{z1 \cdot \left(\left(\left(\left(-0.08888888888888889 \cdot \left(z0 \cdot z0\right)\right) \cdot \left(t\_0 \cdot t\_0\right) - -64.9393940226683\right) \cdot \left(z0 \cdot z0\right) - 2 \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(z0 \cdot z0\right) - -1\right)}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right) \end{array} \]
(FPCore (z1 z2 z0)
  :precision binary64
  (let* ((t_0 (* (* PI PI) PI)))
  (cos
   (*
    -2.0
    (-
     (atan
      (/
       (*
        z1
        (-
         (*
          (-
           (*
            (-
             (* (* -0.08888888888888889 (* z0 z0)) (* t_0 t_0))
             -64.9393940226683)
            (* z0 z0))
           (* 2.0 (* PI PI)))
          (* z0 z0))
         -1.0))
       (* z2 (sin (* PI (+ z0 z0)))))))))))
double code(double z1, double z2, double z0) {
	double t_0 = (((double) M_PI) * ((double) M_PI)) * ((double) M_PI);
	return cos((-2.0 * -atan(((z1 * (((((((-0.08888888888888889 * (z0 * z0)) * (t_0 * t_0)) - -64.9393940226683) * (z0 * z0)) - (2.0 * (((double) M_PI) * ((double) M_PI)))) * (z0 * z0)) - -1.0)) / (z2 * sin((((double) M_PI) * (z0 + z0))))))));
}
public static double code(double z1, double z2, double z0) {
	double t_0 = (Math.PI * Math.PI) * Math.PI;
	return Math.cos((-2.0 * -Math.atan(((z1 * (((((((-0.08888888888888889 * (z0 * z0)) * (t_0 * t_0)) - -64.9393940226683) * (z0 * z0)) - (2.0 * (Math.PI * Math.PI))) * (z0 * z0)) - -1.0)) / (z2 * Math.sin((Math.PI * (z0 + z0))))))));
}
def code(z1, z2, z0):
	t_0 = (math.pi * math.pi) * math.pi
	return math.cos((-2.0 * -math.atan(((z1 * (((((((-0.08888888888888889 * (z0 * z0)) * (t_0 * t_0)) - -64.9393940226683) * (z0 * z0)) - (2.0 * (math.pi * math.pi))) * (z0 * z0)) - -1.0)) / (z2 * math.sin((math.pi * (z0 + z0))))))))
function code(z1, z2, z0)
	t_0 = Float64(Float64(pi * pi) * pi)
	return cos(Float64(-2.0 * Float64(-atan(Float64(Float64(z1 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.08888888888888889 * Float64(z0 * z0)) * Float64(t_0 * t_0)) - -64.9393940226683) * Float64(z0 * z0)) - Float64(2.0 * Float64(pi * pi))) * Float64(z0 * z0)) - -1.0)) / Float64(z2 * sin(Float64(pi * Float64(z0 + z0)))))))))
end
function tmp = code(z1, z2, z0)
	t_0 = (pi * pi) * pi;
	tmp = cos((-2.0 * -atan(((z1 * (((((((-0.08888888888888889 * (z0 * z0)) * (t_0 * t_0)) - -64.9393940226683) * (z0 * z0)) - (2.0 * (pi * pi))) * (z0 * z0)) - -1.0)) / (z2 * sin((pi * (z0 + z0))))))));
end
code[z1_, z2_, z0_] := Block[{t$95$0 = N[(N[(Pi * Pi), $MachinePrecision] * Pi), $MachinePrecision]}, N[Cos[N[(-2.0 * (-N[ArcTan[N[(N[(z1 * N[(N[(N[(N[(N[(N[(N[(-0.08888888888888889 * N[(z0 * z0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] - -64.9393940226683), $MachinePrecision] * N[(z0 * z0), $MachinePrecision]), $MachinePrecision] - N[(2.0 * N[(Pi * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(z0 * z0), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] / N[(z2 * N[Sin[N[(Pi * N[(z0 + z0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \left(\pi \cdot \pi\right) \cdot \pi\\
\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{z1 \cdot \left(\left(\left(\left(-0.08888888888888889 \cdot \left(z0 \cdot z0\right)\right) \cdot \left(t\_0 \cdot t\_0\right) - -64.9393940226683\right) \cdot \left(z0 \cdot z0\right) - 2 \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(z0 \cdot z0\right) - -1\right)}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 67.3%

    \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
    4. tan-quotN/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
    5. frac-timesN/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
  3. Applied rewrites76.6%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
  4. Taylor expanded in z0 around 0

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\pi}^{2} + {z0}^{2} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\pi}^{6}\right) + \frac{2}{3} \cdot {\pi}^{4}\right)\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + \color{blue}{{z0}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {z0}^{2} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)}\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    2. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \color{blue}{\left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {z0}^{2} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)}\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    3. lower-pow.f64N/A

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \color{blue}{{z0}^{2} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    5. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + \color{blue}{{z0}^{2}} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    6. lower-pow.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\mathsf{PI}\left(\right)}^{2} + {z0}^{\color{blue}{2}} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    7. lower-PI.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\pi}^{2} + {z0}^{2} \cdot \left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\pi}^{2} + {z0}^{2} \cdot \color{blue}{\left(\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right) + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    9. lower-pow.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\pi}^{2} + {z0}^{2} \cdot \left(\color{blue}{\frac{-4}{45} \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{6}\right)} + \frac{2}{3} \cdot {\mathsf{PI}\left(\right)}^{4}\right)\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  6. Applied rewrites98.3%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + {z0}^{2} \cdot \left(-2 \cdot {\pi}^{2} + {z0}^{2} \cdot \left(-0.08888888888888889 \cdot \left({z0}^{2} \cdot {\pi}^{6}\right) + 0.6666666666666666 \cdot {\pi}^{4}\right)\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  7. Applied rewrites98.3%

    \[\leadsto \cos \left(-2 \cdot \color{blue}{\left(-\tan^{-1} \left(\frac{z1 \cdot \left(\left(\left(\left(-0.08888888888888889 \cdot \left(z0 \cdot z0\right)\right) \cdot \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right) - -0.6666666666666666 \cdot {\pi}^{4}\right) \cdot \left(z0 \cdot z0\right) - 2 \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(z0 \cdot z0\right) - -1\right)}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)}\right) \]
  8. Evaluated real constant98.3%

    \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{z1 \cdot \left(\left(\left(\left(-0.08888888888888889 \cdot \left(z0 \cdot z0\right)\right) \cdot \left(\left(\left(\pi \cdot \pi\right) \cdot \pi\right) \cdot \left(\left(\pi \cdot \pi\right) \cdot \pi\right)\right) - -64.9393940226683\right) \cdot \left(z0 \cdot z0\right) - 2 \cdot \left(\pi \cdot \pi\right)\right) \cdot \left(z0 \cdot z0\right) - -1\right)}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right) \]
  9. Add Preprocessing

Alternative 2: 94.0% accurate, 1.0× speedup?

\[\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(-19.739208802178716 \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right) \]
(FPCore (z1 z2 z0)
  :precision binary64
  (cos
 (*
  -2.0
  (-
   (atan
    (/
     (* (- (* (* -19.739208802178716 z0) z0) -1.0) z1)
     (* z2 (sin (* PI (+ z0 z0))))))))))
double code(double z1, double z2, double z0) {
	return cos((-2.0 * -atan((((((-19.739208802178716 * z0) * z0) - -1.0) * z1) / (z2 * sin((((double) M_PI) * (z0 + z0))))))));
}
public static double code(double z1, double z2, double z0) {
	return Math.cos((-2.0 * -Math.atan((((((-19.739208802178716 * z0) * z0) - -1.0) * z1) / (z2 * Math.sin((Math.PI * (z0 + z0))))))));
}
def code(z1, z2, z0):
	return math.cos((-2.0 * -math.atan((((((-19.739208802178716 * z0) * z0) - -1.0) * z1) / (z2 * math.sin((math.pi * (z0 + z0))))))))
function code(z1, z2, z0)
	return cos(Float64(-2.0 * Float64(-atan(Float64(Float64(Float64(Float64(Float64(-19.739208802178716 * z0) * z0) - -1.0) * z1) / Float64(z2 * sin(Float64(pi * Float64(z0 + z0)))))))))
end
function tmp = code(z1, z2, z0)
	tmp = cos((-2.0 * -atan((((((-19.739208802178716 * z0) * z0) - -1.0) * z1) / (z2 * sin((pi * (z0 + z0))))))));
end
code[z1_, z2_, z0_] := N[Cos[N[(-2.0 * (-N[ArcTan[N[(N[(N[(N[(N[(-19.739208802178716 * z0), $MachinePrecision] * z0), $MachinePrecision] - -1.0), $MachinePrecision] * z1), $MachinePrecision] / N[(z2 * N[Sin[N[(Pi * N[(z0 + z0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(-19.739208802178716 \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right)
Derivation
  1. Initial program 67.3%

    \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
    4. tan-quotN/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
    5. frac-timesN/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
  3. Applied rewrites76.6%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
  4. Taylor expanded in z0 around 0

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

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

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

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    6. lower-PI.f6494.0%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  6. Applied rewrites94.0%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
  7. Applied rewrites94.0%

    \[\leadsto \cos \left(-2 \cdot \color{blue}{\left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)}\right) \]
  8. Evaluated real constant94.0%

    \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(-19.739208802178716 \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)\right) \]
  9. Add Preprocessing

Alternative 3: 91.7% accurate, 0.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(t\_0 \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 z1 z2) < 1.4e8

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)}\right) \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \mathsf{PI}\left(\right)}}{\color{blue}{z0}}\right)\right) \]
    6. Applied rewrites75.7%

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)\right) \]
      2. add-flipN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
    8. Applied rewrites75.8%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot \frac{2}{3}\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot \frac{2}{3}\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      5. lift-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      6. associate-*r/N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\pi \cdot z1}{z2} \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      11. lower-*.f6484.4%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
    10. Applied rewrites84.4%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]

    if 1.4e8 < (/.f64 z1 z2)

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 91.4% accurate, 1.2× speedup?

\[\begin{array}{l} t_0 := \left|z2\right| \cdot \pi\\ \mathbf{if}\;\left|z2\right| \leq 6 \cdot 10^{-74}:\\ \;\;\;\;\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot t\_0\right)}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{\left|z2\right|} - \frac{z1}{t\_0} \cdot 0.5}{z0}\right)\right)\\ \end{array} \]
(FPCore (z1 z2 z0)
  :precision binary64
  (let* ((t_0 (* (fabs z2) PI)))
  (if (<= (fabs z2) 6e-74)
    (cos
     (*
      -2.0
      (-
       (atan
        (/
         (* (- (* (* (* (* PI PI) -2.0) z0) z0) -1.0) z1)
         (* 2.0 (* z0 t_0)))))))
    (cos
     (*
      -2.0
      (atan
       (/
        (-
         (/ (* (* PI z1) (* 0.6666666666666666 (* z0 z0))) (fabs z2))
         (* (/ z1 t_0) 0.5))
        z0)))))))
double code(double z1, double z2, double z0) {
	double t_0 = fabs(z2) * ((double) M_PI);
	double tmp;
	if (fabs(z2) <= 6e-74) {
		tmp = cos((-2.0 * -atan((((((((((double) M_PI) * ((double) M_PI)) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	} else {
		tmp = cos((-2.0 * atan((((((((double) M_PI) * z1) * (0.6666666666666666 * (z0 * z0))) / fabs(z2)) - ((z1 / t_0) * 0.5)) / z0))));
	}
	return tmp;
}
public static double code(double z1, double z2, double z0) {
	double t_0 = Math.abs(z2) * Math.PI;
	double tmp;
	if (Math.abs(z2) <= 6e-74) {
		tmp = Math.cos((-2.0 * -Math.atan((((((((Math.PI * Math.PI) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	} else {
		tmp = Math.cos((-2.0 * Math.atan((((((Math.PI * z1) * (0.6666666666666666 * (z0 * z0))) / Math.abs(z2)) - ((z1 / t_0) * 0.5)) / z0))));
	}
	return tmp;
}
def code(z1, z2, z0):
	t_0 = math.fabs(z2) * math.pi
	tmp = 0
	if math.fabs(z2) <= 6e-74:
		tmp = math.cos((-2.0 * -math.atan((((((((math.pi * math.pi) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))))
	else:
		tmp = math.cos((-2.0 * math.atan((((((math.pi * z1) * (0.6666666666666666 * (z0 * z0))) / math.fabs(z2)) - ((z1 / t_0) * 0.5)) / z0))))
	return tmp
function code(z1, z2, z0)
	t_0 = Float64(abs(z2) * pi)
	tmp = 0.0
	if (abs(z2) <= 6e-74)
		tmp = cos(Float64(-2.0 * Float64(-atan(Float64(Float64(Float64(Float64(Float64(Float64(Float64(pi * pi) * -2.0) * z0) * z0) - -1.0) * z1) / Float64(2.0 * Float64(z0 * t_0)))))));
	else
		tmp = cos(Float64(-2.0 * atan(Float64(Float64(Float64(Float64(Float64(pi * z1) * Float64(0.6666666666666666 * Float64(z0 * z0))) / abs(z2)) - Float64(Float64(z1 / t_0) * 0.5)) / z0))));
	end
	return tmp
end
function tmp_2 = code(z1, z2, z0)
	t_0 = abs(z2) * pi;
	tmp = 0.0;
	if (abs(z2) <= 6e-74)
		tmp = cos((-2.0 * -atan((((((((pi * pi) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	else
		tmp = cos((-2.0 * atan((((((pi * z1) * (0.6666666666666666 * (z0 * z0))) / abs(z2)) - ((z1 / t_0) * 0.5)) / z0))));
	end
	tmp_2 = tmp;
end
code[z1_, z2_, z0_] := Block[{t$95$0 = N[(N[Abs[z2], $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[Abs[z2], $MachinePrecision], 6e-74], N[Cos[N[(-2.0 * (-N[ArcTan[N[(N[(N[(N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * -2.0), $MachinePrecision] * z0), $MachinePrecision] * z0), $MachinePrecision] - -1.0), $MachinePrecision] * z1), $MachinePrecision] / N[(2.0 * N[(z0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[Cos[N[(-2.0 * N[ArcTan[N[(N[(N[(N[(N[(Pi * z1), $MachinePrecision] * N[(0.6666666666666666 * N[(z0 * z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Abs[z2], $MachinePrecision]), $MachinePrecision] - N[(N[(z1 / t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|z2\right| \cdot \pi\\
\mathbf{if}\;\left|z2\right| \leq 6 \cdot 10^{-74}:\\
\;\;\;\;\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot t\_0\right)}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{\left|z2\right|} - \frac{z1}{t\_0} \cdot 0.5}{z0}\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 6.0000000000000001e-74

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

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

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

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
      6. lower-PI.f6494.0%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    7. Applied rewrites94.0%

      \[\leadsto \cos \left(-2 \cdot \color{blue}{\left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)}\right) \]
    8. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{\color{blue}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}}\right)\right)\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \color{blue}{\left(z0 \cdot \left(z2 \cdot \mathsf{PI}\left(\right)\right)\right)}}\right)\right)\right) \]
      2. lower-*.f64N/A

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

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot \left(z2 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}\right)\right)\right) \]
      4. lower-PI.f6481.4%

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}\right)\right)\right) \]
    10. Applied rewrites81.4%

      \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{\color{blue}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}}\right)\right)\right) \]

    if 6.0000000000000001e-74 < z2

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)}\right) \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \mathsf{PI}\left(\right)}}{\color{blue}{z0}}\right)\right) \]
    6. Applied rewrites75.7%

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)\right) \]
      2. add-flipN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
    8. Applied rewrites75.8%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot \frac{2}{3}\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      2. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot \frac{2}{3}\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      3. associate-*l*N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      4. lift-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      5. lift-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\pi \cdot \frac{z1}{z2}\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      6. associate-*r/N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\pi \cdot z1}{z2} \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right) - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      7. associate-*l/N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      8. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      10. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(\frac{2}{3} \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot \frac{1}{2}}{z0}\right)\right) \]
      11. lower-*.f6484.4%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
    10. Applied rewrites84.4%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\frac{\left(\pi \cdot z1\right) \cdot \left(0.6666666666666666 \cdot \left(z0 \cdot z0\right)\right)}{z2} - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 88.5% accurate, 1.2× speedup?

\[\begin{array}{l} t_0 := \left|z2\right| \cdot \pi\\ \mathbf{if}\;\left|z2\right| \leq 6.8 \cdot 10^{-56}:\\ \;\;\;\;\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot t\_0\right)}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{\left|z2\right|}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{t\_0} \cdot 0.5}{z0}\right)\right)\\ \end{array} \]
(FPCore (z1 z2 z0)
  :precision binary64
  (let* ((t_0 (* (fabs z2) PI)))
  (if (<= (fabs z2) 6.8e-56)
    (cos
     (*
      -2.0
      (-
       (atan
        (/
         (* (- (* (* (* (* PI PI) -2.0) z0) z0) -1.0) z1)
         (* 2.0 (* z0 t_0)))))))
    (cos
     (*
      -2.0
      (atan
       (/
        (-
         (* (* (* PI (/ z1 (fabs z2))) 0.6666666666666666) (* z0 z0))
         (* (/ z1 t_0) 0.5))
        z0)))))))
double code(double z1, double z2, double z0) {
	double t_0 = fabs(z2) * ((double) M_PI);
	double tmp;
	if (fabs(z2) <= 6.8e-56) {
		tmp = cos((-2.0 * -atan((((((((((double) M_PI) * ((double) M_PI)) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	} else {
		tmp = cos((-2.0 * atan((((((((double) M_PI) * (z1 / fabs(z2))) * 0.6666666666666666) * (z0 * z0)) - ((z1 / t_0) * 0.5)) / z0))));
	}
	return tmp;
}
public static double code(double z1, double z2, double z0) {
	double t_0 = Math.abs(z2) * Math.PI;
	double tmp;
	if (Math.abs(z2) <= 6.8e-56) {
		tmp = Math.cos((-2.0 * -Math.atan((((((((Math.PI * Math.PI) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	} else {
		tmp = Math.cos((-2.0 * Math.atan((((((Math.PI * (z1 / Math.abs(z2))) * 0.6666666666666666) * (z0 * z0)) - ((z1 / t_0) * 0.5)) / z0))));
	}
	return tmp;
}
def code(z1, z2, z0):
	t_0 = math.fabs(z2) * math.pi
	tmp = 0
	if math.fabs(z2) <= 6.8e-56:
		tmp = math.cos((-2.0 * -math.atan((((((((math.pi * math.pi) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))))
	else:
		tmp = math.cos((-2.0 * math.atan((((((math.pi * (z1 / math.fabs(z2))) * 0.6666666666666666) * (z0 * z0)) - ((z1 / t_0) * 0.5)) / z0))))
	return tmp
function code(z1, z2, z0)
	t_0 = Float64(abs(z2) * pi)
	tmp = 0.0
	if (abs(z2) <= 6.8e-56)
		tmp = cos(Float64(-2.0 * Float64(-atan(Float64(Float64(Float64(Float64(Float64(Float64(Float64(pi * pi) * -2.0) * z0) * z0) - -1.0) * z1) / Float64(2.0 * Float64(z0 * t_0)))))));
	else
		tmp = cos(Float64(-2.0 * atan(Float64(Float64(Float64(Float64(Float64(pi * Float64(z1 / abs(z2))) * 0.6666666666666666) * Float64(z0 * z0)) - Float64(Float64(z1 / t_0) * 0.5)) / z0))));
	end
	return tmp
end
function tmp_2 = code(z1, z2, z0)
	t_0 = abs(z2) * pi;
	tmp = 0.0;
	if (abs(z2) <= 6.8e-56)
		tmp = cos((-2.0 * -atan((((((((pi * pi) * -2.0) * z0) * z0) - -1.0) * z1) / (2.0 * (z0 * t_0))))));
	else
		tmp = cos((-2.0 * atan((((((pi * (z1 / abs(z2))) * 0.6666666666666666) * (z0 * z0)) - ((z1 / t_0) * 0.5)) / z0))));
	end
	tmp_2 = tmp;
end
code[z1_, z2_, z0_] := Block[{t$95$0 = N[(N[Abs[z2], $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[Abs[z2], $MachinePrecision], 6.8e-56], N[Cos[N[(-2.0 * (-N[ArcTan[N[(N[(N[(N[(N[(N[(N[(Pi * Pi), $MachinePrecision] * -2.0), $MachinePrecision] * z0), $MachinePrecision] * z0), $MachinePrecision] - -1.0), $MachinePrecision] * z1), $MachinePrecision] / N[(2.0 * N[(z0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[Cos[N[(-2.0 * N[ArcTan[N[(N[(N[(N[(N[(Pi * N[(z1 / N[Abs[z2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * N[(z0 * z0), $MachinePrecision]), $MachinePrecision] - N[(N[(z1 / t$95$0), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] / z0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|z2\right| \cdot \pi\\
\mathbf{if}\;\left|z2\right| \leq 6.8 \cdot 10^{-56}:\\
\;\;\;\;\cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot t\_0\right)}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{\left|z2\right|}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{t\_0} \cdot 0.5}{z0}\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z2 < 6.7999999999999996e-56

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

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

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

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
      6. lower-PI.f6494.0%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    6. Applied rewrites94.0%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\color{blue}{\left(1 + -2 \cdot \left({z0}^{2} \cdot {\pi}^{2}\right)\right)} \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)\right) \]
    7. Applied rewrites94.0%

      \[\leadsto \cos \left(-2 \cdot \color{blue}{\left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{z2 \cdot \sin \left(\pi \cdot \left(z0 + z0\right)\right)}\right)\right)}\right) \]
    8. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{\color{blue}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}}\right)\right)\right) \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \color{blue}{\left(z0 \cdot \left(z2 \cdot \mathsf{PI}\left(\right)\right)\right)}}\right)\right)\right) \]
      2. lower-*.f64N/A

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

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot \left(z2 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)\right)}\right)\right)\right) \]
      4. lower-PI.f6481.4%

        \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}\right)\right)\right) \]
    10. Applied rewrites81.4%

      \[\leadsto \cos \left(-2 \cdot \left(-\tan^{-1} \left(\frac{\left(\left(\left(\left(\pi \cdot \pi\right) \cdot -2\right) \cdot z0\right) \cdot z0 - -1\right) \cdot z1}{\color{blue}{2 \cdot \left(z0 \cdot \left(z2 \cdot \pi\right)\right)}}\right)\right)\right) \]

    if 6.7999999999999996e-56 < z2

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)}\right) \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \mathsf{PI}\left(\right)}}{\color{blue}{z0}}\right)\right) \]
    6. Applied rewrites75.7%

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)\right) \]
      2. add-flipN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
    8. Applied rewrites75.8%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 86.0% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;\tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right) \leq 8:\\ \;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(-0.5 \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \pi\right)}\right)\right)\\ \end{array} \]
(FPCore (z1 z2 z0)
  :precision binary64
  (if (<= (tan (* PI (+ 0.5 (+ z0 z0)))) 8.0)
  (cos (* -2.0 (atan (* 0.6666666666666666 (/ (* z0 (* z1 PI)) z2)))))
  (cos (* -2.0 (atan (* -0.5 (/ z1 (* z0 (* z2 PI)))))))))
double code(double z1, double z2, double z0) {
	double tmp;
	if (tan((((double) M_PI) * (0.5 + (z0 + z0)))) <= 8.0) {
		tmp = cos((-2.0 * atan((0.6666666666666666 * ((z0 * (z1 * ((double) M_PI))) / z2)))));
	} else {
		tmp = cos((-2.0 * atan((-0.5 * (z1 / (z0 * (z2 * ((double) M_PI))))))));
	}
	return tmp;
}
public static double code(double z1, double z2, double z0) {
	double tmp;
	if (Math.tan((Math.PI * (0.5 + (z0 + z0)))) <= 8.0) {
		tmp = Math.cos((-2.0 * Math.atan((0.6666666666666666 * ((z0 * (z1 * Math.PI)) / z2)))));
	} else {
		tmp = Math.cos((-2.0 * Math.atan((-0.5 * (z1 / (z0 * (z2 * Math.PI)))))));
	}
	return tmp;
}
def code(z1, z2, z0):
	tmp = 0
	if math.tan((math.pi * (0.5 + (z0 + z0)))) <= 8.0:
		tmp = math.cos((-2.0 * math.atan((0.6666666666666666 * ((z0 * (z1 * math.pi)) / z2)))))
	else:
		tmp = math.cos((-2.0 * math.atan((-0.5 * (z1 / (z0 * (z2 * math.pi)))))))
	return tmp
function code(z1, z2, z0)
	tmp = 0.0
	if (tan(Float64(pi * Float64(0.5 + Float64(z0 + z0)))) <= 8.0)
		tmp = cos(Float64(-2.0 * atan(Float64(0.6666666666666666 * Float64(Float64(z0 * Float64(z1 * pi)) / z2)))));
	else
		tmp = cos(Float64(-2.0 * atan(Float64(-0.5 * Float64(z1 / Float64(z0 * Float64(z2 * pi)))))));
	end
	return tmp
end
function tmp_2 = code(z1, z2, z0)
	tmp = 0.0;
	if (tan((pi * (0.5 + (z0 + z0)))) <= 8.0)
		tmp = cos((-2.0 * atan((0.6666666666666666 * ((z0 * (z1 * pi)) / z2)))));
	else
		tmp = cos((-2.0 * atan((-0.5 * (z1 / (z0 * (z2 * pi)))))));
	end
	tmp_2 = tmp;
end
code[z1_, z2_, z0_] := If[LessEqual[N[Tan[N[(Pi * N[(0.5 + N[(z0 + z0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 8.0], N[Cos[N[(-2.0 * N[ArcTan[N[(0.6666666666666666 * N[(N[(z0 * N[(z1 * Pi), $MachinePrecision]), $MachinePrecision] / z2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Cos[N[(-2.0 * N[ArcTan[N[(-0.5 * N[(z1 / N[(z0 * N[(z2 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right) \leq 8:\\
\;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot \tan^{-1} \left(-0.5 \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \pi\right)}\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (tan.f64 (*.f64 (PI.f64) (+.f64 #s(literal 1/2 binary64) (+.f64 z0 z0)))) < 8

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)}\right) \]
    5. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \mathsf{PI}\left(\right)}}{\color{blue}{z0}}\right)\right) \]
    6. Applied rewrites75.7%

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)\right) \]
      2. add-flipN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
      3. lower--.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
    8. Applied rewrites75.8%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
    9. Taylor expanded in z0 around inf

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \color{blue}{\frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}}\right)\right) \]
    10. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{\color{blue}{z2}}\right)\right) \]
      2. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
      5. lower-PI.f6466.1%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}\right)\right) \]
    11. Applied rewrites66.1%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \color{blue}{\frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}}\right)\right) \]

    if 8 < (tan.f64 (*.f64 (PI.f64) (+.f64 #s(literal 1/2 binary64) (+.f64 z0 z0))))

    1. Initial program 67.3%

      \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
      4. tan-quotN/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
      5. frac-timesN/A

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

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

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
    3. Applied rewrites76.6%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
    4. Taylor expanded in z0 around 0

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1}{2} \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \pi\right)}\right)}\right) \]
    5. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1}{2} \cdot \color{blue}{\frac{z1}{z0 \cdot \left(z2 \cdot \mathsf{PI}\left(\right)\right)}}\right)\right) \]
      2. lower-/.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1}{2} \cdot \frac{z1}{\color{blue}{z0 \cdot \left(z2 \cdot \mathsf{PI}\left(\right)\right)}}\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1}{2} \cdot \frac{z1}{z0 \cdot \color{blue}{\left(z2 \cdot \mathsf{PI}\left(\right)\right)}}\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1}{2} \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right)}\right)\right) \]
      5. lower-PI.f6466.5%

        \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(-0.5 \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \pi\right)}\right)\right) \]
    6. Applied rewrites66.5%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(-0.5 \cdot \frac{z1}{z0 \cdot \left(z2 \cdot \pi\right)}\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 66.1% accurate, 1.4× speedup?

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

    \[\cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \tan \left(\pi \cdot \left(0.5 + \left(z0 + z0\right)\right)\right)\right)\right) \]
  2. Step-by-step derivation
    1. lift-*.f64N/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\tan \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}\right)\right) \]
    4. tan-quotN/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{z1}{z2} \cdot \color{blue}{\frac{\sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}}\right)\right) \]
    5. frac-timesN/A

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

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{z1 \cdot \sin \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right)}{\cos \left(\pi \cdot \left(\frac{1}{2} + \left(z0 + z0\right)\right)\right) \cdot z2}\right)}\right) \]
  3. Applied rewrites76.6%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{\cos \left(\left(z0 + z0\right) \cdot \pi\right) \cdot z1}{\left(-\sin \left(\left(z0 + z0\right) \cdot \pi\right)\right) \cdot z2}\right)}\right) \]
  4. Taylor expanded in z0 around 0

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \color{blue}{\left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)}\right) \]
  5. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \mathsf{PI}\left(\right)}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \mathsf{PI}\left(\right)}}{\color{blue}{z0}}\right)\right) \]
  6. Applied rewrites75.7%

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

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) + \frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}}{z0}\right)\right) \]
    2. add-flipN/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
    3. lower--.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{-1 \cdot \left({z0}^{2} \cdot \left(-1 \cdot \frac{z1 \cdot \pi}{z2} - \frac{-1}{3} \cdot \frac{z1 \cdot \pi}{z2}\right)\right) - \left(\mathsf{neg}\left(\frac{-1}{2} \cdot \frac{z1}{z2 \cdot \pi}\right)\right)}{z0}\right)\right) \]
  8. Applied rewrites75.8%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{\left(\left(\pi \cdot \frac{z1}{z2}\right) \cdot 0.6666666666666666\right) \cdot \left(z0 \cdot z0\right) - \frac{z1}{z2 \cdot \pi} \cdot 0.5}{z0}\right)\right) \]
  9. Taylor expanded in z0 around inf

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \color{blue}{\frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}}\right)\right) \]
  10. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{\color{blue}{z2}}\right)\right) \]
    2. lower-/.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
    3. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(\frac{2}{3} \cdot \frac{z0 \cdot \left(z1 \cdot \mathsf{PI}\left(\right)\right)}{z2}\right)\right) \]
    5. lower-PI.f6466.1%

      \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}\right)\right) \]
  11. Applied rewrites66.1%

    \[\leadsto \cos \left(-2 \cdot \tan^{-1} \left(0.6666666666666666 \cdot \color{blue}{\frac{z0 \cdot \left(z1 \cdot \pi\right)}{z2}}\right)\right) \]
  12. Add Preprocessing

Reproduce

?
herbie shell --seed 2025250 
(FPCore (z1 z2 z0)
  :name "(cos (* -2 (atan (* (/ z1 z2) (tan (* PI (+ 1/2 (+ z0 z0))))))))"
  :precision binary64
  (cos (* -2.0 (atan (* (/ z1 z2) (tan (* PI (+ 0.5 (+ z0 z0)))))))))