tan-example (used to crash)

Percentage Accurate: 79.7% → 99.7%
Time: 20.2s
Alternatives: 13
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 13 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.7% 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.4× speedup?

\[\begin{array}{l} \\ x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (-
   (* (+ (tan y) (tan z)) (/ 1.0 (+ 1.0 (+ 1.0 (- -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 / (1.0 + (1.0 + (-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 / (1.0d0 + (1.0d0 + ((-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 / (1.0 + (1.0 + (-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 / (1.0 + (1.0 + (-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(1.0 + Float64(1.0 + 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 / (1.0 + (1.0 + (-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[(1.0 + N[(1.0 + N[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[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. expm1-log1p-u91.9%

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ x + \left(\frac{\tan y + \tan z}{1 + \left(1 + \left(-1 - \tan y \cdot \tan z\right)\right)} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (-
   (/ (+ (tan y) (tan z)) (+ 1.0 (+ 1.0 (- -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 + (1.0 + (-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 + (1.0d0 + ((-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 + (1.0 + (-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 + (1.0 + (-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(1.0 + 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 + (1.0 + (-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[(1.0 + N[(-1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[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. expm1-log1p-u91.9%

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

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

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

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

    \[\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) \]
  9. Final simplification99.7%

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

Alternative 3: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ x + \left(\left(\tan y + \tan z\right) \cdot \frac{1}{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 (- 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 / (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 / (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 / (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 / (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(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 / (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[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

    \[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: 89.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 78.3%

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

    if -2.05e-4 < a < 0.75

    1. Initial program 82.6%

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

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

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

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

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

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

Alternative 6: 89.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 78.3%

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

    if -2.14999999999999995e-4 < a < 0.75

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -0.000215 \lor \neg \left(a \leq 0.75\right):\\ \;\;\;\;x + \left(\tan \left(y + z\right) - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - 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.32 \lor \neg \left(a \leq 1.7 \cdot 10^{-55}\right):\\ \;\;\;\;x + \left(\tan y - \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.32) (not (<= a 1.7e-55)))
   (+ x (- (tan y) (tan a)))
   (+ x (- (tan (+ y z)) a))))
double code(double x, double y, double z, double a) {
	double tmp;
	if ((a <= -0.32) || !(a <= 1.7e-55)) {
		tmp = x + (tan(y) - 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.32d0)) .or. (.not. (a <= 1.7d-55))) then
        tmp = x + (tan(y) - 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.32) || !(a <= 1.7e-55)) {
		tmp = x + (Math.tan(y) - Math.tan(a));
	} else {
		tmp = x + (Math.tan((y + z)) - a);
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if (a <= -0.32) or not (a <= 1.7e-55):
		tmp = x + (math.tan(y) - 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.32) || !(a <= 1.7e-55))
		tmp = Float64(x + Float64(tan(y) - 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.32) || ~((a <= 1.7e-55)))
		tmp = x + (tan(y) - tan(a));
	else
		tmp = x + (tan((y + z)) - a);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := If[Or[LessEqual[a, -0.32], N[Not[LessEqual[a, 1.7e-55]], $MachinePrecision]], N[(x + N[(N[Tan[y], $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.32 \lor \neg \left(a \leq 1.7 \cdot 10^{-55}\right):\\
\;\;\;\;x + \left(\tan y - \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.320000000000000007 or 1.69999999999999986e-55 < a

    1. Initial program 77.2%

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

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

    if -0.320000000000000007 < a < 1.69999999999999986e-55

    1. Initial program 84.4%

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

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

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

Alternative 8: 60.9% accurate, 1.0× speedup?

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

    1. Initial program 72.9%

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

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

    if -1e-13 < (+.f64 y z)

    1. Initial program 85.0%

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

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

Alternative 9: 79.7% 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 80.4%

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

Alternative 10: 50.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.75:\\
\;\;\;\;x\\

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

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


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

    1. Initial program 77.7%

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

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

    if -1.75 < a < 0.71999999999999997

    1. Initial program 83.2%

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

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

Alternative 11: 40.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6:\\
\;\;\;\;x\\

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

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


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

    1. Initial program 77.7%

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

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

    if -1.6000000000000001 < a < 0.71999999999999997

    1. Initial program 83.2%

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

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

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

Alternative 12: 36.1% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 61.5%

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

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

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

    if -5.40000000000000009e-11 < y

    1. Initial program 87.2%

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

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

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

Alternative 13: 31.7% 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 80.4%

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

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

Reproduce

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