(tan (- (* (+ PI PI) z0) (* -1/2 PI)))

Percentage Accurate: 8.8% → 97.5%
Time: 11.7s
Alternatives: 8
Speedup: 1.0×

Specification

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

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

Alternative 1: 97.5% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(\color{blue}{\left(2 \cdot z0\right)} \cdot \pi + \pi\right)}{\sin \left(z0 \cdot \left(\pi + \pi\right)\right)} \]
    13. lower-*.f6497.5%

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

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

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

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

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

Alternative 2: 97.5% accurate, 0.6× speedup?

\[{\tan \left(\left(-z0\right) \cdot \left(\pi + \pi\right)\right)}^{-1} \]
(FPCore (z0)
  :precision binary64
  (pow (tan (* (- z0) (+ PI PI))) -1))
double code(double z0) {
	return pow(tan((-z0 * (((double) M_PI) + ((double) M_PI)))), -1.0);
}
public static double code(double z0) {
	return Math.pow(Math.tan((-z0 * (Math.PI + Math.PI))), -1.0);
}
def code(z0):
	return math.pow(math.tan((-z0 * (math.pi + math.pi))), -1.0)
function code(z0)
	return tan(Float64(Float64(-z0) * Float64(pi + pi))) ^ -1.0
end
function tmp = code(z0)
	tmp = tan((-z0 * (pi + pi))) ^ -1.0;
end
code[z0_] := N[Power[N[Tan[N[((-z0) * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], -1], $MachinePrecision]
{\tan \left(\left(-z0\right) \cdot \left(\pi + \pi\right)\right)}^{-1}
Derivation
  1. Initial program 8.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\tan \left(\left(-z0\right) \cdot \left(\pi + \pi\right)\right)}^{-1}} \]
  6. Add Preprocessing

Alternative 3: 97.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 10.7% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\ \;\;\;\;\tan \left(\left(\left(\left(z0 + z0\right) - \frac{-1}{2}\right) + 1\right) \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\tan \left(-\left(\left(\left(\frac{-1}{2} - z0\right) - z0\right) + 1\right) \cdot \pi\right)\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (if (<=
     z0
     -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424)
  (tan (* (+ (- (+ z0 z0) -1/2) 1) PI))
  (tan (- (* (+ (- (- -1/2 z0) z0) 1) PI)))))
double code(double z0) {
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = tan(((((z0 + z0) - -0.5) + 1.0) * ((double) M_PI)));
	} else {
		tmp = tan(-((((-0.5 - z0) - z0) + 1.0) * ((double) M_PI)));
	}
	return tmp;
}
public static double code(double z0) {
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = Math.tan(((((z0 + z0) - -0.5) + 1.0) * Math.PI));
	} else {
		tmp = Math.tan(-((((-0.5 - z0) - z0) + 1.0) * Math.PI));
	}
	return tmp;
}
def code(z0):
	tmp = 0
	if z0 <= -2.3e-308:
		tmp = math.tan(((((z0 + z0) - -0.5) + 1.0) * math.pi))
	else:
		tmp = math.tan(-((((-0.5 - z0) - z0) + 1.0) * math.pi))
	return tmp
function code(z0)
	tmp = 0.0
	if (z0 <= -2.3e-308)
		tmp = tan(Float64(Float64(Float64(Float64(z0 + z0) - -0.5) + 1.0) * pi));
	else
		tmp = tan(Float64(-Float64(Float64(Float64(Float64(-0.5 - z0) - z0) + 1.0) * pi)));
	end
	return tmp
end
function tmp_2 = code(z0)
	tmp = 0.0;
	if (z0 <= -2.3e-308)
		tmp = tan(((((z0 + z0) - -0.5) + 1.0) * pi));
	else
		tmp = tan(-((((-0.5 - z0) - z0) + 1.0) * pi));
	end
	tmp_2 = tmp;
end
code[z0_] := If[LessEqual[z0, -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424], N[Tan[N[(N[(N[(N[(z0 + z0), $MachinePrecision] - -1/2), $MachinePrecision] + 1), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], N[Tan[(-N[(N[(N[(N[(-1/2 - z0), $MachinePrecision] - z0), $MachinePrecision] + 1), $MachinePrecision] * Pi), $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\
\;\;\;\;\tan \left(\left(\left(\left(z0 + z0\right) - \frac{-1}{2}\right) + 1\right) \cdot \pi\right)\\

\mathbf{else}:\\
\;\;\;\;\tan \left(-\left(\left(\left(\frac{-1}{2} - z0\right) - z0\right) + 1\right) \cdot \pi\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -2.2999999999999999e-308

    1. Initial program 8.8%

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

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

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

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

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

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

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

    if -2.2999999999999999e-308 < z0

    1. Initial program 8.8%

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

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

        \[\leadsto \tan \color{blue}{\left(\left(\pi + \pi\right) \cdot z0 - \frac{-1}{2} \cdot \pi\right)} \]
      3. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 10.7% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\ \;\;\;\;\tan \left(\left(\left(\left(z0 + z0\right) - \frac{-1}{2}\right) + 1\right) \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\tan \left(-\left(\left(\frac{-1}{2} - \left(z0 + z0\right)\right) + 1\right) \cdot \pi\right)\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (if (<=
     z0
     -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424)
  (tan (* (+ (- (+ z0 z0) -1/2) 1) PI))
  (tan (- (* (+ (- -1/2 (+ z0 z0)) 1) PI)))))
double code(double z0) {
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = tan(((((z0 + z0) - -0.5) + 1.0) * ((double) M_PI)));
	} else {
		tmp = tan(-(((-0.5 - (z0 + z0)) + 1.0) * ((double) M_PI)));
	}
	return tmp;
}
public static double code(double z0) {
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = Math.tan(((((z0 + z0) - -0.5) + 1.0) * Math.PI));
	} else {
		tmp = Math.tan(-(((-0.5 - (z0 + z0)) + 1.0) * Math.PI));
	}
	return tmp;
}
def code(z0):
	tmp = 0
	if z0 <= -2.3e-308:
		tmp = math.tan(((((z0 + z0) - -0.5) + 1.0) * math.pi))
	else:
		tmp = math.tan(-(((-0.5 - (z0 + z0)) + 1.0) * math.pi))
	return tmp
function code(z0)
	tmp = 0.0
	if (z0 <= -2.3e-308)
		tmp = tan(Float64(Float64(Float64(Float64(z0 + z0) - -0.5) + 1.0) * pi));
	else
		tmp = tan(Float64(-Float64(Float64(Float64(-0.5 - Float64(z0 + z0)) + 1.0) * pi)));
	end
	return tmp
end
function tmp_2 = code(z0)
	tmp = 0.0;
	if (z0 <= -2.3e-308)
		tmp = tan(((((z0 + z0) - -0.5) + 1.0) * pi));
	else
		tmp = tan(-(((-0.5 - (z0 + z0)) + 1.0) * pi));
	end
	tmp_2 = tmp;
end
code[z0_] := If[LessEqual[z0, -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424], N[Tan[N[(N[(N[(N[(z0 + z0), $MachinePrecision] - -1/2), $MachinePrecision] + 1), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], N[Tan[(-N[(N[(N[(-1/2 - N[(z0 + z0), $MachinePrecision]), $MachinePrecision] + 1), $MachinePrecision] * Pi), $MachinePrecision])], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\
\;\;\;\;\tan \left(\left(\left(\left(z0 + z0\right) - \frac{-1}{2}\right) + 1\right) \cdot \pi\right)\\

\mathbf{else}:\\
\;\;\;\;\tan \left(-\left(\left(\frac{-1}{2} - \left(z0 + z0\right)\right) + 1\right) \cdot \pi\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -2.2999999999999999e-308

    1. Initial program 8.8%

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

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

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

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

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

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

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

    if -2.2999999999999999e-308 < z0

    1. Initial program 8.8%

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

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

        \[\leadsto \tan \color{blue}{\left(\left(\pi + \pi\right) \cdot z0 - \frac{-1}{2} \cdot \pi\right)} \]
      3. sub-negate-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 10.7% accurate, 1.0× speedup?

\[\begin{array}{l} t_0 := \left(z0 + z0\right) - \frac{-1}{2}\\ \mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\ \;\;\;\;\tan \left(\left(t\_0 + 1\right) \cdot \pi\right)\\ \mathbf{else}:\\ \;\;\;\;\tan \left(t\_0 \cdot \pi - \pi\right)\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (let* ((t_0 (- (+ z0 z0) -1/2)))
  (if (<=
       z0
       -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424)
    (tan (* (+ t_0 1) PI))
    (tan (- (* t_0 PI) PI)))))
double code(double z0) {
	double t_0 = (z0 + z0) - -0.5;
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = tan(((t_0 + 1.0) * ((double) M_PI)));
	} else {
		tmp = tan(((t_0 * ((double) M_PI)) - ((double) M_PI)));
	}
	return tmp;
}
public static double code(double z0) {
	double t_0 = (z0 + z0) - -0.5;
	double tmp;
	if (z0 <= -2.3e-308) {
		tmp = Math.tan(((t_0 + 1.0) * Math.PI));
	} else {
		tmp = Math.tan(((t_0 * Math.PI) - Math.PI));
	}
	return tmp;
}
def code(z0):
	t_0 = (z0 + z0) - -0.5
	tmp = 0
	if z0 <= -2.3e-308:
		tmp = math.tan(((t_0 + 1.0) * math.pi))
	else:
		tmp = math.tan(((t_0 * math.pi) - math.pi))
	return tmp
function code(z0)
	t_0 = Float64(Float64(z0 + z0) - -0.5)
	tmp = 0.0
	if (z0 <= -2.3e-308)
		tmp = tan(Float64(Float64(t_0 + 1.0) * pi));
	else
		tmp = tan(Float64(Float64(t_0 * pi) - pi));
	end
	return tmp
end
function tmp_2 = code(z0)
	t_0 = (z0 + z0) - -0.5;
	tmp = 0.0;
	if (z0 <= -2.3e-308)
		tmp = tan(((t_0 + 1.0) * pi));
	else
		tmp = tan(((t_0 * pi) - pi));
	end
	tmp_2 = tmp;
end
code[z0_] := Block[{t$95$0 = N[(N[(z0 + z0), $MachinePrecision] - -1/2), $MachinePrecision]}, If[LessEqual[z0, -290953239129259/12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424], N[Tan[N[(N[(t$95$0 + 1), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision], N[Tan[N[(N[(t$95$0 * Pi), $MachinePrecision] - Pi), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(z0 + z0\right) - \frac{-1}{2}\\
\mathbf{if}\;z0 \leq \frac{-290953239129259}{12650140831706913647030959169932331690597290610258882397306334876714396222999709180747523981339820280949192366519800744461863046086612092304188337496296156870094839017285397585279181733880826021327485479904546566785125467714043293663631459728072472271300628532022423097020838413451906408261645469290375391456731733818343424}:\\
\;\;\;\;\tan \left(\left(t\_0 + 1\right) \cdot \pi\right)\\

\mathbf{else}:\\
\;\;\;\;\tan \left(t\_0 \cdot \pi - \pi\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < -2.2999999999999999e-308

    1. Initial program 8.8%

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

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

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

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

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

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

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

    if -2.2999999999999999e-308 < z0

    1. Initial program 8.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\cos \left(z0 \cdot \left(\pi + \pi\right)\right)}{\sin \left(z0 \cdot \left(\pi + \pi\right)\right)}} \]
    4. Applied rewrites8.8%

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

Alternative 7: 8.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\cos \left(z0 \cdot \left(\pi + \pi\right)\right)}}{\mathsf{neg}\left(\sin \left(z0 \cdot \left(\pi + \pi\right)\right)\right)} \]
  5. Applied rewrites8.8%

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

Alternative 8: 8.6% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \tan \color{blue}{\left(\left(\left(\left(z0 + z0\right) - \frac{-1}{2}\right) + 2\right) \cdot \pi\right)} \]
    3. lower-*.f648.6%

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

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

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

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

      \[\leadsto \tan \left(\color{blue}{\left(\left(z0 + z0\right) - \left(\frac{-1}{2} - 2\right)\right)} \cdot \pi\right) \]
    8. metadata-eval8.6%

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

    \[\leadsto \tan \color{blue}{\left(\left(\left(z0 + z0\right) - \frac{-5}{2}\right) \cdot \pi\right)} \]
  7. Add Preprocessing

Reproduce

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