tan-example (used to crash)

Percentage Accurate: 79.6% → 99.7%
Time: 36.8s
Alternatives: 10
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 10 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: 79.6% 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.3× speedup?

\[\begin{array}{l} \\ x + \left(\frac{\tan y + \tan z}{1 - \frac{\sin y \cdot \sin z}{\cos y \cdot \cos z}} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (-
   (/ (+ (tan y) (tan z)) (- 1.0 (/ (* (sin y) (sin z)) (* (cos y) (cos z)))))
   (tan a))))
double code(double x, double y, double z, double a) {
	return x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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 - ((sin(y) * sin(z)) / (cos(y) * cos(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.sin(y) * Math.sin(z)) / (Math.cos(y) * Math.cos(z))))) - Math.tan(a));
}
def code(x, y, z, a):
	return x + (((math.tan(y) + math.tan(z)) / (1.0 - ((math.sin(y) * math.sin(z)) / (math.cos(y) * math.cos(z))))) - math.tan(a))
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(Float64(sin(y) * sin(z)) / Float64(cos(y) * cos(z))))) - tan(a)))
end
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) + tan(z)) / (1.0 - ((sin(y) * sin(z)) / (cos(y) * cos(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[(N[Sin[y], $MachinePrecision] * N[Sin[z], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[y], $MachinePrecision] * N[Cos[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. 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) \]
  3. 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) \]
  4. 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) \]
  5. Simplified99.7%

    \[\leadsto x + \left(\color{blue}{\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  6. Taylor expanded in y around inf 99.7%

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

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

Alternative 2: 89.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\tan a \leq -0.001 \lor \neg \left(\tan a \leq 2 \cdot 10^{-15}\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)} - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= (tan a) -0.001) (not (<= (tan a) 2e-15)))
   (+ x (- (tan (+ y z)) (tan a)))
   (+
    x
    (-
     (/ (+ (tan y) (tan z)) (+ 1.0 (+ 1.0 (- -1.0 (* (tan y) (tan z))))))
     a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((tan(a) <= -0.001) || !(tan(a) <= 2e-15)) {
		tmp = x + (tan((y + z)) - tan(a));
	} else {
		tmp = x + (((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(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 ((tan(a) <= (-0.001d0)) .or. (.not. (tan(a) <= 2d-15))) then
        tmp = x + (tan((y + z)) - tan(a))
    else
        tmp = x + (((tan(y) + tan(z)) / (1.0d0 + (1.0d0 + ((-1.0d0) - (tan(y) * tan(z)))))) - a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((Math.tan(a) <= -0.001) || !(Math.tan(a) <= 2e-15)) {
		tmp = x + (Math.tan((y + z)) - Math.tan(a));
	} else {
		tmp = x + (((Math.tan(y) + Math.tan(z)) / (1.0 + (1.0 + (-1.0 - (Math.tan(y) * Math.tan(z)))))) - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (math.tan(a) <= -0.001) or not (math.tan(a) <= 2e-15):
		tmp = x + (math.tan((y + z)) - math.tan(a))
	else:
		tmp = x + (((math.tan(y) + math.tan(z)) / (1.0 + (1.0 + (-1.0 - (math.tan(y) * math.tan(z)))))) - a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((tan(a) <= -0.001) || !(tan(a) <= 2e-15))
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	else
		tmp = Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 + Float64(1.0 + Float64(-1.0 - Float64(tan(y) * tan(z)))))) - a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((tan(a) <= -0.001) || ~((tan(a) <= 2e-15)))
		tmp = x + (tan((y + z)) - tan(a));
	else
		tmp = x + (((tan(y) + tan(z)) / (1.0 + (1.0 + (-1.0 - (tan(y) * tan(z)))))) - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.001], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 2e-15]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(1.0 + N[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 82.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]

    if -1e-3 < (tan.f64 a) < 2.0000000000000002e-15

    1. Initial program 74.3%

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

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

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

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

        \[\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.6%

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

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

        \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y \cdot \tan z\right)\right)}} - \tan a\right) \]
      2. expm1-udef92.2%

        \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - \color{blue}{\left(e^{\mathsf{log1p}\left(\tan y \cdot \tan z\right)} - 1\right)}} - \tan a\right) \]
      3. log1p-udef92.2%

        \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - \left(e^{\color{blue}{\log \left(1 + \tan y \cdot \tan z\right)}} - 1\right)} - \tan a\right) \]
      4. add-exp-log99.6%

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

      \[\leadsto x + \left(\frac{\tan y + \tan z}{1 - \color{blue}{\left(\left(1 + \tan y \cdot \tan z\right) - 1\right)}} - \tan a\right) \]
    8. Taylor expanded in a around 0 99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -0.001 \lor \neg \left(\tan a \leq 2 \cdot 10^{-15}\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)} - a\right)\\ \end{array} \]

Alternative 3: 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 78.8%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. 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) \]
  3. 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) \]
  4. 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) \]
  5. Simplified99.7%

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

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

Alternative 4: 89.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \leq -0.00048 \lor \neg \left(a \leq 2.8 \cdot 10^{-14}\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (or (<= a -0.00048) (not (<= a 2.8e-14)))
   (+ x (- (tan (+ y z)) (tan a)))
   (+ (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (- x a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -0.00048) || !(a <= 2.8e-14)) {
		tmp = x + (tan((y + z)) - tan(a));
	} else {
		tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - 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.00048d0)) .or. (.not. (a <= 2.8d-14))) then
        tmp = x + (tan((y + z)) - tan(a))
    else
        tmp = ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) + (x - a)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -0.00048) || !(a <= 2.8e-14)) {
		tmp = x + (Math.tan((y + z)) - Math.tan(a));
	} else {
		tmp = ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) + (x - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -0.00048) or not (a <= 2.8e-14):
		tmp = x + (math.tan((y + z)) - math.tan(a))
	else:
		tmp = ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) + (x - a)
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if ((a <= -0.00048) || !(a <= 2.8e-14))
		tmp = Float64(x + Float64(tan(Float64(y + z)) - tan(a)));
	else
		tmp = Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) + Float64(x - a));
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((a <= -0.00048) || ~((a <= 2.8e-14)))
		tmp = x + (tan((y + z)) - tan(a));
	else
		tmp = ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) + (x - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.00048], N[Not[LessEqual[a, 2.8e-14]], $MachinePrecision]], N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[(x - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.00048 \lor \neg \left(a \leq 2.8 \cdot 10^{-14}\right):\\
\;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -4.80000000000000012e-4 or 2.8000000000000001e-14 < a

    1. Initial program 82.7%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]

    if -4.80000000000000012e-4 < a < 2.8000000000000001e-14

    1. Initial program 74.3%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-74.3%

        \[\leadsto \color{blue}{\left(x + \tan \left(y + z\right)\right) - \tan a} \]
      2. +-commutative74.3%

        \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + x\right)} - \tan a \]
      3. associate--l+74.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.00048 \lor \neg \left(a \leq 2.8 \cdot 10^{-14}\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} + \left(x - a\right)\\ \end{array} \]

Alternative 5: 60.2% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 81.3%

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

      \[\leadsto x + \left(\color{blue}{\frac{\sin y}{\cos y}} - \tan a\right) \]
    3. Step-by-step derivation
      1. tan-quot72.8%

        \[\leadsto x + \left(\color{blue}{\tan y} - \tan a\right) \]
      2. expm1-log1p-u66.1%

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      3. expm1-udef66.1%

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

      \[\leadsto x + \left(\color{blue}{\left(e^{\mathsf{log1p}\left(\tan y\right)} - 1\right)} - \tan a\right) \]
    5. Step-by-step derivation
      1. expm1-def66.1%

        \[\leadsto x + \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan y\right)\right)} - \tan a\right) \]
      2. expm1-log1p72.8%

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

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

    if 4.9999999999999998e-8 < (+.f64 y z)

    1. Initial program 75.1%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-75.0%

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

        \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + x\right)} - \tan a \]
      3. associate--l+75.0%

        \[\leadsto \color{blue}{\tan \left(y + z\right) + \left(x - \tan a\right)} \]
    3. Simplified75.0%

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\frac{1}{\frac{x + \tan a}{x \cdot x - {\tan a}^{2}}}} \]
    6. Taylor expanded in x around inf 50.0%

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

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

Alternative 6: 79.6% 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 78.8%

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. Final simplification78.8%

    \[\leadsto x + \left(\tan \left(y + z\right) - \tan a\right) \]

Alternative 7: 59.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -10000000 \lor \neg \left(y + z \leq 5 \cdot 10^{-8}\right):\\
\;\;\;\;\tan \left(y + z\right) + \frac{1}{\frac{1}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 y z) < -1e7 or 4.9999999999999998e-8 < (+.f64 y z)

    1. Initial program 71.4%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-71.3%

        \[\leadsto \color{blue}{\left(x + \tan \left(y + z\right)\right) - \tan a} \]
      2. +-commutative71.3%

        \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + x\right)} - \tan a \]
      3. associate--l+71.3%

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

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

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

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

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

      \[\leadsto \tan \left(y + z\right) + \color{blue}{\frac{1}{\frac{x + \tan a}{x \cdot x - {\tan a}^{2}}}} \]
    6. Taylor expanded in x around inf 45.5%

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

    if -1e7 < (+.f64 y z) < 4.9999999999999998e-8

    1. Initial program 99.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y + z \leq -10000000 \lor \neg \left(y + z \leq 5 \cdot 10^{-8}\right):\\ \;\;\;\;\tan \left(y + z\right) + \frac{1}{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - \tan a\right)\\ \end{array} \]

Alternative 8: 55.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -8.8 \cdot 10^{+24} \lor \neg \left(a \leq 0.24\right):\\
\;\;\;\;x + \left(y - \tan a\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -8.80000000000000007e24 or 0.23999999999999999 < a

    1. Initial program 81.8%

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

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

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

    if -8.80000000000000007e24 < a < 0.23999999999999999

    1. Initial program 75.9%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Step-by-step derivation
      1. associate-+r-75.8%

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

        \[\leadsto \color{blue}{\left(\tan \left(y + z\right) + x\right)} - \tan a \]
      3. associate--l+75.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8.8 \cdot 10^{+24} \lor \neg \left(a \leq 0.24\right):\\ \;\;\;\;x + \left(y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\tan \left(y + z\right) + \left(x - a\right)\\ \end{array} \]

Alternative 9: 40.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -18000000:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-54}:\\ \;\;\;\;x + \left(y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= y -18000000.0) x (if (<= y 8.2e-54) (+ x (- y (tan a))) x)))
double code(double x, double y, double z, double a) {
	double tmp;
	if (y <= -18000000.0) {
		tmp = x;
	} else if (y <= 8.2e-54) {
		tmp = x + (y - 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 (y <= (-18000000.0d0)) then
        tmp = x
    else if (y <= 8.2d-54) then
        tmp = x + (y - 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 (y <= -18000000.0) {
		tmp = x;
	} else if (y <= 8.2e-54) {
		tmp = x + (y - Math.tan(a));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if y <= -18000000.0:
		tmp = x
	elif y <= 8.2e-54:
		tmp = x + (y - math.tan(a))
	else:
		tmp = x
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (y <= -18000000.0)
		tmp = x;
	elseif (y <= 8.2e-54)
		tmp = Float64(x + Float64(y - tan(a)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (y <= -18000000.0)
		tmp = x;
	elseif (y <= 8.2e-54)
		tmp = x + (y - tan(a));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[LessEqual[y, -18000000.0], x, If[LessEqual[y, 8.2e-54], N[(x + N[(y - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -18000000:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.8e7 or 8.2000000000000001e-54 < y

    1. Initial program 63.6%

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

      \[\leadsto \color{blue}{x} \]

    if -1.8e7 < y < 8.2000000000000001e-54

    1. Initial program 99.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -18000000:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-54}:\\ \;\;\;\;x + \left(y - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 10: 31.5% 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 78.8%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification31.6%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023275 
(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))))