tan-example (used to crash)

Percentage Accurate: 78.4% → 99.7%
Time: 38.4s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\left(\left(\left(x = 0 \lor 0.5884142 \leq x \land x \leq 505.5909\right) \land \left(-1.796658 \cdot 10^{+308} \leq y \land y \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq y \land y \leq 1.751224 \cdot 10^{+308}\right)\right) \land \left(-1.776707 \cdot 10^{+308} \leq z \land z \leq -8.599796 \cdot 10^{-310} \lor 3.293145 \cdot 10^{-311} \leq z \land z \leq 1.725154 \cdot 10^{+308}\right)\right) \land \left(-1.796658 \cdot 10^{+308} \leq a \land a \leq -9.425585 \cdot 10^{-310} \lor 1.284938 \cdot 10^{-309} \leq a \land a \leq 1.751224 \cdot 10^{+308}\right)\]
\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}

Sampling outcomes in binary64 precision:

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 14 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: 78.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}

Alternative 1: 99.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan y \cdot \tan z\\ x + \left(\frac{\tan y + \tan z}{1 - {t\_0}^{3}} \cdot \left(1 + t\_0 \cdot \left(1 + t\_0\right)\right) - \tan a\right) \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (* (tan y) (tan z))))
   (+
    x
    (-
     (*
      (/ (+ (tan y) (tan z)) (- 1.0 (pow t_0 3.0)))
      (+ 1.0 (* t_0 (+ 1.0 t_0))))
     (tan a)))))
double code(double x, double y, double z, double a) {
	double t_0 = tan(y) * tan(z);
	return x + ((((tan(y) + tan(z)) / (1.0 - pow(t_0, 3.0))) * (1.0 + (t_0 * (1.0 + t_0)))) - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: t_0
    t_0 = tan(y) * tan(z)
    code = x + ((((tan(y) + tan(z)) / (1.0d0 - (t_0 ** 3.0d0))) * (1.0d0 + (t_0 * (1.0d0 + t_0)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	double t_0 = Math.tan(y) * Math.tan(z);
	return x + ((((Math.tan(y) + Math.tan(z)) / (1.0 - Math.pow(t_0, 3.0))) * (1.0 + (t_0 * (1.0 + t_0)))) - Math.tan(a));
}
def code(x, y, z, a):
	t_0 = math.tan(y) * math.tan(z)
	return x + ((((math.tan(y) + math.tan(z)) / (1.0 - math.pow(t_0, 3.0))) * (1.0 + (t_0 * (1.0 + t_0)))) - math.tan(a))
function code(x, y, z, a)
	t_0 = Float64(tan(y) * tan(z))
	return Float64(x + Float64(Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - (t_0 ^ 3.0))) * Float64(1.0 + Float64(t_0 * Float64(1.0 + t_0)))) - tan(a)))
end
function tmp = code(x, y, z, a)
	t_0 = tan(y) * tan(z);
	tmp = x + ((((tan(y) + tan(z)) / (1.0 - (t_0 ^ 3.0))) * (1.0 + (t_0 * (1.0 + t_0)))) - tan(a));
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]}, N[(x + N[(N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[Power[t$95$0, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(t$95$0 * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan y \cdot \tan z\\
x + \left(\frac{\tan y + \tan z}{1 - {t\_0}^{3}} \cdot \left(1 + t\_0 \cdot \left(1 + t\_0\right)\right) - \tan a\right)
\end{array}
\end{array}
Derivation
  1. Initial program 79.3%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. tan-sum99.7%

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    2. div-inv99.7%

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  4. Applied egg-rr99.7%

    \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  5. Step-by-step derivation
    1. associate-*r/99.7%

      \[\leadsto x + \left(\color{blue}{\frac{\left(\tan y + \tan z\right) \cdot 1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    2. *-rgt-identity99.7%

      \[\leadsto x + \left(\frac{\color{blue}{\tan y + \tan z}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
  6. Simplified99.7%

    \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  7. Step-by-step derivation
    1. flip3--99.7%

      \[\leadsto x + \left(\frac{\tan y + \tan z}{\color{blue}{\frac{{1}^{3} - {\left(\tan y \cdot \tan z\right)}^{3}}{1 \cdot 1 + \left(\left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z\right) + 1 \cdot \left(\tan y \cdot \tan z\right)\right)}}} - \tan a\right) \]
    2. associate-/r/99.7%

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{{1}^{3} - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(1 \cdot 1 + \left(\left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z\right) + 1 \cdot \left(\tan y \cdot \tan z\right)\right)\right)} - \tan a\right) \]
    3. metadata-eval99.7%

      \[\leadsto x + \left(\frac{\tan y + \tan z}{\color{blue}{1} - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(1 \cdot 1 + \left(\left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z\right) + 1 \cdot \left(\tan y \cdot \tan z\right)\right)\right) - \tan a\right) \]
    4. metadata-eval99.7%

      \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(\color{blue}{1} + \left(\left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z\right) + 1 \cdot \left(\tan y \cdot \tan z\right)\right)\right) - \tan a\right) \]
    5. distribute-rgt-out99.7%

      \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(1 + \color{blue}{\left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z + 1\right)}\right) - \tan a\right) \]
  8. Applied egg-rr99.7%

    \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(1 + \left(\tan y \cdot \tan z\right) \cdot \left(\tan y \cdot \tan z + 1\right)\right)} - \tan a\right) \]
  9. Final simplification99.7%

    \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - {\left(\tan y \cdot \tan z\right)}^{3}} \cdot \left(1 + \left(\tan y \cdot \tan z\right) \cdot \left(1 + \tan y \cdot \tan z\right)\right) - \tan a\right) \]
  10. Add Preprocessing

Alternative 2: 88.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan \left(y + z\right)\\ \mathbf{if}\;\tan a \leq -0.002:\\ \;\;\;\;x + \left(t\_0 + \sin a \cdot \frac{-1}{\cos a}\right)\\ \mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t\_0 - \log \left(e^{\tan a}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (tan (+ y z))))
   (if (<= (tan a) -0.002)
     (+ x (+ t_0 (* (sin a) (/ -1.0 (cos a)))))
     (if (<= (tan a) 2e-6)
       (+ x (- (* (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z))))) a))
       (+ x (- t_0 (log (exp (tan a)))))))))
double code(double x, double y, double z, double a) {
	double t_0 = tan((y + z));
	double tmp;
	if (tan(a) <= -0.002) {
		tmp = x + (t_0 + (sin(a) * (-1.0 / cos(a))));
	} else if (tan(a) <= 2e-6) {
		tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a);
	} else {
		tmp = x + (t_0 - log(exp(tan(a))));
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: t_0
    real(8) :: tmp
    t_0 = tan((y + z))
    if (tan(a) <= (-0.002d0)) then
        tmp = x + (t_0 + (sin(a) * ((-1.0d0) / cos(a))))
    else if (tan(a) <= 2d-6) then
        tmp = x + (((tan(y) + tan(z)) * (1.0d0 / (1.0d0 - (tan(y) * tan(z))))) - a)
    else
        tmp = x + (t_0 - log(exp(tan(a))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double t_0 = Math.tan((y + z));
	double tmp;
	if (Math.tan(a) <= -0.002) {
		tmp = x + (t_0 + (Math.sin(a) * (-1.0 / Math.cos(a))));
	} else if (Math.tan(a) <= 2e-6) {
		tmp = x + (((Math.tan(y) + Math.tan(z)) * (1.0 / (1.0 - (Math.tan(y) * Math.tan(z))))) - a);
	} else {
		tmp = x + (t_0 - Math.log(Math.exp(Math.tan(a))));
	}
	return tmp;
}
def code(x, y, z, a):
	t_0 = math.tan((y + z))
	tmp = 0
	if math.tan(a) <= -0.002:
		tmp = x + (t_0 + (math.sin(a) * (-1.0 / math.cos(a))))
	elif math.tan(a) <= 2e-6:
		tmp = x + (((math.tan(y) + math.tan(z)) * (1.0 / (1.0 - (math.tan(y) * math.tan(z))))) - a)
	else:
		tmp = x + (t_0 - math.log(math.exp(math.tan(a))))
	return tmp
function code(x, y, z, a)
	t_0 = tan(Float64(y + z))
	tmp = 0.0
	if (tan(a) <= -0.002)
		tmp = Float64(x + Float64(t_0 + Float64(sin(a) * Float64(-1.0 / cos(a)))));
	elseif (tan(a) <= 2e-6)
		tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z))))) - a));
	else
		tmp = Float64(x + Float64(t_0 - log(exp(tan(a)))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	t_0 = tan((y + z));
	tmp = 0.0;
	if (tan(a) <= -0.002)
		tmp = x + (t_0 + (sin(a) * (-1.0 / cos(a))));
	elseif (tan(a) <= 2e-6)
		tmp = x + (((tan(y) + tan(z)) * (1.0 / (1.0 - (tan(y) * tan(z))))) - a);
	else
		tmp = x + (t_0 - log(exp(tan(a))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(t$95$0 + N[(N[Sin[a], $MachinePrecision] * N[(-1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-6], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Log[N[Exp[N[Tan[a], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(t\_0 + \sin a \cdot \frac{-1}{\cos a}\right)\\

\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \log \left(e^{\tan a}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (tan.f64 a) < -2e-3

    1. Initial program 82.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. tan-quot82.7%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
      2. div-inv82.7%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]
    4. Applied egg-rr82.7%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]

    if -2e-3 < (tan.f64 a) < 1.99999999999999991e-6

    1. Initial program 75.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 75.8%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
    4. Step-by-step derivation
      1. tan-sum99.7%

        \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
      2. div-inv99.7%

        \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - a\right) \]

    if 1.99999999999999991e-6 < (tan.f64 a)

    1. Initial program 84.1%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp84.1%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
    4. Applied egg-rr84.1%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -0.002:\\ \;\;\;\;x + \left(\tan \left(y + z\right) + \sin a \cdot \frac{-1}{\cos a}\right)\\ \mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z} - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \log \left(e^{\tan a}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan \left(y + z\right)\\ \mathbf{if}\;\tan a \leq -0.002:\\ \;\;\;\;x + \left(t\_0 + \sin a \cdot \frac{-1}{\cos a}\right)\\ \mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t\_0 - \log \left(e^{\tan a}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (tan (+ y z))))
   (if (<= (tan a) -0.002)
     (+ x (+ t_0 (* (sin a) (/ -1.0 (cos a)))))
     (if (<= (tan a) 2e-6)
       (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) a))
       (+ x (- t_0 (log (exp (tan a)))))))))
double code(double x, double y, double z, double a) {
	double t_0 = tan((y + z));
	double tmp;
	if (tan(a) <= -0.002) {
		tmp = x + (t_0 + (sin(a) * (-1.0 / cos(a))));
	} else if (tan(a) <= 2e-6) {
		tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
	} else {
		tmp = x + (t_0 - log(exp(tan(a))));
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: t_0
    real(8) :: tmp
    t_0 = tan((y + z))
    if (tan(a) <= (-0.002d0)) then
        tmp = x + (t_0 + (sin(a) * ((-1.0d0) / cos(a))))
    else if (tan(a) <= 2d-6) then
        tmp = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - a)
    else
        tmp = x + (t_0 - log(exp(tan(a))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double t_0 = Math.tan((y + z));
	double tmp;
	if (Math.tan(a) <= -0.002) {
		tmp = x + (t_0 + (Math.sin(a) * (-1.0 / Math.cos(a))));
	} else if (Math.tan(a) <= 2e-6) {
		tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - a);
	} else {
		tmp = x + (t_0 - Math.log(Math.exp(Math.tan(a))));
	}
	return tmp;
}
def code(x, y, z, a):
	t_0 = math.tan((y + z))
	tmp = 0
	if math.tan(a) <= -0.002:
		tmp = x + (t_0 + (math.sin(a) * (-1.0 / math.cos(a))))
	elif math.tan(a) <= 2e-6:
		tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - a)
	else:
		tmp = x + (t_0 - math.log(math.exp(math.tan(a))))
	return tmp
function code(x, y, z, a)
	t_0 = tan(Float64(y + z))
	tmp = 0.0
	if (tan(a) <= -0.002)
		tmp = Float64(x + Float64(t_0 + Float64(sin(a) * Float64(-1.0 / cos(a)))));
	elseif (tan(a) <= 2e-6)
		tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - a));
	else
		tmp = Float64(x + Float64(t_0 - log(exp(tan(a)))));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	t_0 = tan((y + z));
	tmp = 0.0;
	if (tan(a) <= -0.002)
		tmp = x + (t_0 + (sin(a) * (-1.0 / cos(a))));
	elseif (tan(a) <= 2e-6)
		tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - a);
	else
		tmp = x + (t_0 - log(exp(tan(a))));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Tan[a], $MachinePrecision], -0.002], N[(x + N[(t$95$0 + N[(N[Sin[a], $MachinePrecision] * N[(-1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Tan[a], $MachinePrecision], 2e-6], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 - N[Log[N[Exp[N[Tan[a], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;\tan a \leq -0.002:\\
\;\;\;\;x + \left(t\_0 + \sin a \cdot \frac{-1}{\cos a}\right)\\

\mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\
\;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(t\_0 - \log \left(e^{\tan a}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (tan.f64 a) < -2e-3

    1. Initial program 82.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. tan-quot82.7%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
      2. div-inv82.7%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]
    4. Applied egg-rr82.7%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]

    if -2e-3 < (tan.f64 a) < 1.99999999999999991e-6

    1. Initial program 75.8%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 75.8%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
    4. Step-by-step derivation
      1. tan-sum99.7%

        \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
      2. div-inv99.7%

        \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    5. Applied egg-rr99.5%

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - a\right) \]
    6. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto x + \left(\color{blue}{\frac{\left(\tan y + \tan z\right) \cdot 1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
      2. *-rgt-identity99.7%

        \[\leadsto x + \left(\frac{\color{blue}{\tan y + \tan z}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
    7. Simplified99.5%

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - a\right) \]

    if 1.99999999999999991e-6 < (tan.f64 a)

    1. Initial program 84.1%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp84.1%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
    4. Applied egg-rr84.1%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -0.002:\\ \;\;\;\;x + \left(\tan \left(y + z\right) + \sin a \cdot \frac{-1}{\cos a}\right)\\ \mathbf{elif}\;\tan a \leq 2 \cdot 10^{-6}:\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \log \left(e^{\tan a}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Derivation
  1. Initial program 79.3%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. tan-sum99.7%

      \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    2. div-inv99.7%

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  4. Applied egg-rr99.7%

    \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  5. Step-by-step derivation
    1. associate-*r/99.7%

      \[\leadsto x + \left(\color{blue}{\frac{\left(\tan y + \tan z\right) \cdot 1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
    2. *-rgt-identity99.7%

      \[\leadsto x + \left(\frac{\color{blue}{\tan y + \tan z}}{1 - \tan y \cdot \tan z} - \tan a\right) \]
  6. Simplified99.7%

    \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  7. Add Preprocessing

Alternative 5: 78.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) + \sin a \cdot \frac{-1}{\cos a}\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+ x (+ (tan (+ y z)) (* (sin a) (/ -1.0 (cos a))))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) + (sin(a) * (-1.0 / cos(a))));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) + (sin(a) * ((-1.0d0) / cos(a))))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) + (Math.sin(a) * (-1.0 / Math.cos(a))));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) + (math.sin(a) * (-1.0 / math.cos(a))))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) + Float64(sin(a) * Float64(-1.0 / cos(a)))))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) + (sin(a) * (-1.0 / cos(a))));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[a], $MachinePrecision] * N[(-1.0 / N[Cos[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) + \sin a \cdot \frac{-1}{\cos a}\right)
\end{array}
Derivation
  1. Initial program 79.3%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. tan-quot79.3%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\frac{\sin a}{\cos a}}\right) \]
    2. div-inv79.3%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]
  4. Applied egg-rr79.3%

    \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\sin a \cdot \frac{1}{\cos a}}\right) \]
  5. Final simplification79.3%

    \[\leadsto x + \left(\tan \left(y + z\right) + \sin a \cdot \frac{-1}{\cos a}\right) \]
  6. Add Preprocessing

Alternative 6: 68.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.0145 \lor \neg \left(a \leq 5 \cdot 10^{-17}\right):\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -0.0145) (not (<= a 5e-17)))
   (+ x (- (tan z) (tan a)))
   (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -0.0145) || !(a <= 5e-17)) {
		tmp = x + (tan(z) - tan(a));
	} else {
		tmp = x + (tan((y + z)) - a);
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((a <= (-0.0145d0)) .or. (.not. (a <= 5d-17))) then
        tmp = x + (tan(z) - tan(a))
    else
        tmp = x + (tan((y + z)) - a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -0.0145) || !(a <= 5e-17)) {
		tmp = x + (Math.tan(z) - Math.tan(a));
	} else {
		tmp = x + (Math.tan((y + z)) - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -0.0145) or not (a <= 5e-17):
		tmp = x + (math.tan(z) - math.tan(a))
	else:
		tmp = x + (math.tan((y + z)) - a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -0.0145) || !(a <= 5e-17))
		tmp = Float64(x + Float64(tan(z) - tan(a)));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((a <= -0.0145) || ~((a <= 5e-17)))
		tmp = x + (tan(z) - tan(a));
	else
		tmp = x + (tan((y + z)) - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.0145], N[Not[LessEqual[a, 5e-17]], $MachinePrecision]], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0145 \lor \neg \left(a \leq 5 \cdot 10^{-17}\right):\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -0.0145000000000000007 or 4.9999999999999999e-17 < a

    1. Initial program 83.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 66.1%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Step-by-step derivation
      1. tan-quot66.1%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. *-un-lft-identity66.1%

        \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    5. Applied egg-rr66.1%

      \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    6. Step-by-step derivation
      1. *-lft-identity66.1%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
    7. Simplified66.1%

      \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]

    if -0.0145000000000000007 < a < 4.9999999999999999e-17

    1. Initial program 75.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 75.1%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.0145 \lor \neg \left(a \leq 5 \cdot 10^{-17}\right):\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.0145:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \mathbf{elif}\;a \leq 1.55 \cdot 10^{-16}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \tan z\right) - \tan a\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= a -0.0145)
   (+ x (- (tan z) (tan a)))
   (if (<= a 1.55e-16) (+ x (- (tan (+ y z)) a)) (- (+ x (tan z)) (tan a)))))
double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -0.0145) {
		tmp = x + (tan(z) - tan(a));
	} else if (a <= 1.55e-16) {
		tmp = x + (tan((y + z)) - a);
	} else {
		tmp = (x + tan(z)) - tan(a);
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if (a <= (-0.0145d0)) then
        tmp = x + (tan(z) - tan(a))
    else if (a <= 1.55d-16) then
        tmp = x + (tan((y + z)) - a)
    else
        tmp = (x + tan(z)) - tan(a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (a <= -0.0145) {
		tmp = x + (Math.tan(z) - Math.tan(a));
	} else if (a <= 1.55e-16) {
		tmp = x + (Math.tan((y + z)) - a);
	} else {
		tmp = (x + Math.tan(z)) - Math.tan(a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if a <= -0.0145:
		tmp = x + (math.tan(z) - math.tan(a))
	elif a <= 1.55e-16:
		tmp = x + (math.tan((y + z)) - a)
	else:
		tmp = (x + math.tan(z)) - math.tan(a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (a <= -0.0145)
		tmp = Float64(x + Float64(tan(z) - tan(a)));
	elseif (a <= 1.55e-16)
		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
	else
		tmp = Float64(Float64(x + tan(z)) - tan(a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (a <= -0.0145)
		tmp = x + (tan(z) - tan(a));
	elseif (a <= 1.55e-16)
		tmp = x + (tan((y + z)) - a);
	else
		tmp = (x + tan(z)) - tan(a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[a, -0.0145], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 1.55e-16], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0145:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\

\mathbf{elif}\;a \leq 1.55 \cdot 10^{-16}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x + \tan z\right) - \tan a\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if a < -0.0145000000000000007

    1. Initial program 83.5%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 69.5%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Step-by-step derivation
      1. tan-quot69.5%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. *-un-lft-identity69.5%

        \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    5. Applied egg-rr69.5%

      \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    6. Step-by-step derivation
      1. *-lft-identity69.5%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
    7. Simplified69.5%

      \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]

    if -0.0145000000000000007 < a < 1.55e-16

    1. Initial program 75.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 75.1%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]

    if 1.55e-16 < a

    1. Initial program 83.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 62.1%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Step-by-step derivation
      1. tan-quot62.0%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. associate-+r-62.0%

        \[\leadsto \color{blue}{\left(x + \tan z\right) - \tan a} \]
    5. Applied egg-rr62.0%

      \[\leadsto \color{blue}{\left(x + \tan z\right) - \tan a} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 59.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-7}:\\ \;\;\;\;x + \left(\tan a + \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= (+ y z) -2e-7)
   (+ x (+ (tan a) (tan (+ y z))))
   (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-7) {
		tmp = x + (tan(a) + tan((y + z)));
	} else {
		tmp = x + (tan(z) - tan(a));
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((y + z) <= (-2d-7)) then
        tmp = x + (tan(a) + tan((y + z)))
    else
        tmp = x + (tan(z) - tan(a))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-7) {
		tmp = x + (Math.tan(a) + Math.tan((y + z)));
	} else {
		tmp = x + (Math.tan(z) - Math.tan(a));
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (y + z) <= -2e-7:
		tmp = x + (math.tan(a) + math.tan((y + z)))
	else:
		tmp = x + (math.tan(z) - math.tan(a))
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (Float64(y + z) <= -2e-7)
		tmp = Float64(x + Float64(tan(a) + tan(Float64(y + z))));
	else
		tmp = Float64(x + Float64(tan(z) - tan(a)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((y + z) <= -2e-7)
		tmp = x + (tan(a) + tan((y + z)));
	else
		tmp = x + (tan(z) - tan(a));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2e-7], N[(x + N[(N[Tan[a], $MachinePrecision] + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -2 \cdot 10^{-7}:\\
\;\;\;\;x + \left(\tan a + \tan \left(y + z\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 y z) < -1.9999999999999999e-7

    1. Initial program 71.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg71.2%

        \[\leadsto x + \color{blue}{\left(\tan \left(y + z\right) + \left(-\tan a\right)\right)} \]
    4. Applied egg-rr71.2%

      \[\leadsto x + \color{blue}{\left(\tan \left(y + z\right) + \left(-\tan a\right)\right)} \]
    5. Step-by-step derivation
      1. rem-square-sqrt38.0%

        \[\leadsto x + \left(\tan \left(y + z\right) + \color{blue}{\sqrt{-\tan a} \cdot \sqrt{-\tan a}}\right) \]
      2. fabs-sqr38.0%

        \[\leadsto x + \left(\tan \left(y + z\right) + \color{blue}{\left|\sqrt{-\tan a} \cdot \sqrt{-\tan a}\right|}\right) \]
      3. rem-square-sqrt59.4%

        \[\leadsto x + \left(\tan \left(y + z\right) + \left|\color{blue}{-\tan a}\right|\right) \]
      4. fabs-neg59.4%

        \[\leadsto x + \left(\tan \left(y + z\right) + \color{blue}{\left|\tan a\right|}\right) \]
      5. rem-square-sqrt21.4%

        \[\leadsto x + \left(\tan \left(y + z\right) + \left|\color{blue}{\sqrt{\tan a} \cdot \sqrt{\tan a}}\right|\right) \]
      6. fabs-sqr21.4%

        \[\leadsto x + \left(\tan \left(y + z\right) + \color{blue}{\sqrt{\tan a} \cdot \sqrt{\tan a}}\right) \]
      7. rem-square-sqrt46.6%

        \[\leadsto x + \left(\tan \left(y + z\right) + \color{blue}{\tan a}\right) \]
      8. +-commutative46.6%

        \[\leadsto x + \left(\tan \color{blue}{\left(z + y\right)} + \tan a\right) \]
    6. Simplified46.6%

      \[\leadsto x + \color{blue}{\left(\tan \left(z + y\right) + \tan a\right)} \]

    if -1.9999999999999999e-7 < (+.f64 y z)

    1. Initial program 83.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 70.5%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Step-by-step derivation
      1. tan-quot70.5%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. *-un-lft-identity70.5%

        \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    5. Applied egg-rr70.5%

      \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    6. Step-by-step derivation
      1. *-lft-identity70.5%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
    7. Simplified70.5%

      \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-7}:\\ \;\;\;\;x + \left(\tan a + \tan \left(y + z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 64.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-8}:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= y -9.2e-8) (+ x (tan (+ y z))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
	double tmp;
	if (y <= -9.2e-8) {
		tmp = x + tan((y + z));
	} else {
		tmp = x + (tan(z) - tan(a));
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if (y <= (-9.2d-8)) then
        tmp = x + tan((y + z))
    else
        tmp = x + (tan(z) - tan(a))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (y <= -9.2e-8) {
		tmp = x + Math.tan((y + z));
	} else {
		tmp = x + (Math.tan(z) - Math.tan(a));
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if y <= -9.2e-8:
		tmp = x + math.tan((y + z))
	else:
		tmp = x + (math.tan(z) - math.tan(a))
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (y <= -9.2e-8)
		tmp = Float64(x + tan(Float64(y + z)));
	else
		tmp = Float64(x + Float64(tan(z) - tan(a)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (y <= -9.2e-8)
		tmp = x + tan((y + z));
	else
		tmp = x + (tan(z) - tan(a));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[y, -9.2e-8], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{-8}:\\
\;\;\;\;x + \tan \left(y + z\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -9.2000000000000003e-8

    1. Initial program 57.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp57.0%

        \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
    4. Applied egg-rr57.0%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{\log \left(e^{\tan a}\right)}\right) \]
    5. Taylor expanded in a around 0 44.2%

      \[\leadsto x + \left(\tan \left(y + z\right) - \log \color{blue}{1}\right) \]

    if -9.2000000000000003e-8 < y

    1. Initial program 85.5%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 74.6%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Step-by-step derivation
      1. tan-quot74.6%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. *-un-lft-identity74.6%

        \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    5. Applied egg-rr74.6%

      \[\leadsto x + \left(\color{blue}{1 \cdot \tan z} - \tan a\right) \]
    6. Step-by-step derivation
      1. *-lft-identity74.6%

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
    7. Simplified74.6%

      \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification67.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-8}:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 78.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Derivation
  1. Initial program 79.3%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 11: 55.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -400.0) (not (<= a 31.0)))
   (+ x (- z (tan a)))
   (- (+ x (tan (+ y z))) a)))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -400.0) || !(a <= 31.0)) {
		tmp = x + (z - tan(a));
	} else {
		tmp = (x + tan((y + z))) - a;
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((a <= (-400.0d0)) .or. (.not. (a <= 31.0d0))) then
        tmp = x + (z - tan(a))
    else
        tmp = (x + tan((y + z))) - a
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -400.0) || !(a <= 31.0)) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = (x + Math.tan((y + z))) - a;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -400.0) or not (a <= 31.0):
		tmp = x + (z - math.tan(a))
	else:
		tmp = (x + math.tan((y + z))) - a
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -400.0) || !(a <= 31.0))
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = Float64(Float64(x + tan(Float64(y + z))) - a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((a <= -400.0) || ~((a <= 31.0)))
		tmp = x + (z - tan(a));
	else
		tmp = (x + tan((y + z))) - a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -400.0], N[Not[LessEqual[a, 31.0]], $MachinePrecision]], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\
\;\;\;\;x + \left(z - \tan a\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -400 or 31 < a

    1. Initial program 84.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.3%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Taylor expanded in z around 0 40.2%

      \[\leadsto x + \left(\color{blue}{z} - \tan a\right) \]

    if -400 < a < 31

    1. Initial program 75.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 72.9%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
    4. Step-by-step derivation
      1. associate-+r-72.9%

        \[\leadsto \color{blue}{\left(x + \tan \left(y + z\right)\right) - a} \]
    5. Applied egg-rr72.9%

      \[\leadsto \color{blue}{\left(x + \tan \left(y + z\right)\right) - a} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \tan \left(y + z\right)\right) - a\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 55.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -400.0) (not (<= a 31.0)))
   (+ x (- z (tan a)))
   (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -400.0) || !(a <= 31.0)) {
		tmp = x + (z - tan(a));
	} else {
		tmp = x + (tan((y + z)) - a);
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((a <= (-400.0d0)) .or. (.not. (a <= 31.0d0))) then
        tmp = x + (z - tan(a))
    else
        tmp = x + (tan((y + z)) - a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -400.0) || !(a <= 31.0)) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = x + (Math.tan((y + z)) - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -400.0) or not (a <= 31.0):
		tmp = x + (z - math.tan(a))
	else:
		tmp = x + (math.tan((y + z)) - a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -400.0) || !(a <= 31.0))
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = Float64(x + Float64(tan(Float64(y + z)) - a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((a <= -400.0) || ~((a <= 31.0)))
		tmp = x + (z - tan(a));
	else
		tmp = x + (tan((y + z)) - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -400.0], N[Not[LessEqual[a, 31.0]], $MachinePrecision]], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\
\;\;\;\;x + \left(z - \tan a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -400 or 31 < a

    1. Initial program 84.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 68.3%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Taylor expanded in z around 0 40.2%

      \[\leadsto x + \left(\color{blue}{z} - \tan a\right) \]

    if -400 < a < 31

    1. Initial program 75.6%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0 72.9%

      \[\leadsto x + \left(\tan \left(y + z\right) - \color{blue}{a}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -400 \lor \neg \left(a \leq 31\right):\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan \left(y + z\right) - a\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 36.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 1.2:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z a) :precision binary64 (if (<= z 1.2) (+ x (- z (tan a))) x))
double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= 1.2) {
		tmp = x + (z - tan(a));
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if (z <= 1.2d0) then
        tmp = x + (z - tan(a))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= 1.2) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if z <= 1.2:
		tmp = x + (z - math.tan(a))
	else:
		tmp = x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (z <= 1.2)
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (z <= 1.2)
		tmp = x + (z - tan(a));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[z, 1.2], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.2:\\
\;\;\;\;x + \left(z - \tan a\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 1.19999999999999996

    1. Initial program 86.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 65.4%

      \[\leadsto x + \left(\color{blue}{\frac{\sin z}{\cos z}} - \tan a\right) \]
    4. Taylor expanded in z around 0 46.3%

      \[\leadsto x + \left(\color{blue}{z} - \tan a\right) \]

    if 1.19999999999999996 < z

    1. Initial program 56.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 23.1%

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

Alternative 14: 32.0% accurate, 207.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
	return x;
}
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x
end function
public static double code(double x, double y, double z, double a) {
	return x;
}
def code(x, y, z, a):
	return x
function code(x, y, z, a)
	return x
end
function tmp = code(x, y, z, a)
	tmp = x;
end
code[x_, y_, z_, a_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 79.3%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 34.5%

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024086 
(FPCore (x y z a)
  :name "tan-example (used to crash)"
  :precision binary64
  :pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
  (+ x (- (tan (+ y z)) (tan a))))