tan-example (used to crash)

Percentage Accurate: 79.5% → 99.7%
Time: 41.0s
Alternatives: 11
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 11 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.5% 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(\left(\tan y + \tan z\right) \cdot \frac{-1}{\mathsf{fma}\left(\tan y, \tan z, -1\right)} - \tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+ x (- (* (+ (tan y) (tan z)) (/ -1.0 (fma (tan y) (tan z) -1.0))) (tan a))))
double code(double x, double y, double z, double a) {
	return x + (((tan(y) + tan(z)) * (-1.0 / fma(tan(y), tan(z), -1.0))) - tan(a));
}
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) * Float64(-1.0 / fma(tan(y), tan(z), -1.0))) - 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] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

      \[\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. Step-by-step derivation
    1. associate--l+99.7%

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

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

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

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

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

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

      \[\leadsto x + \left(\left(\tan y + \tan z\right) \cdot \left(1 \cdot \frac{1}{\color{blue}{0} - \mathsf{fma}\left(\tan y, \tan z, -1\right)}\right) - \tan a\right) \]
    4. sub0-neg99.7%

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

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

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

      \[\leadsto x + \left(\left(\tan y + \tan z\right) \cdot \frac{\color{blue}{--1}}{-\mathsf{fma}\left(\tan y, \tan z, -1\right)} - \tan a\right) \]
    3. distribute-neg-frac99.7%

      \[\leadsto x + \left(\left(\tan y + \tan z\right) \cdot \color{blue}{\left(-\frac{-1}{-\mathsf{fma}\left(\tan y, \tan z, -1\right)}\right)} - \tan a\right) \]
    4. distribute-neg-frac299.7%

      \[\leadsto x + \left(\left(\tan y + \tan z\right) \cdot \color{blue}{\frac{-1}{-\left(-\mathsf{fma}\left(\tan y, \tan z, -1\right)\right)}} - \tan a\right) \]
    5. remove-double-neg99.7%

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

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

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

Alternative 2: 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 76.9%

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

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

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 76.9%

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

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

Alternative 4: 80.0% accurate, 0.7× speedup?

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

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

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

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

      \[\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. Step-by-step derivation
    1. associate--l+99.7%

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

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

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

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

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

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

Alternative 5: 41.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left({x}^{3}\right)}^{0.3333333333333333}\\ \mathbf{if}\;z \leq -1.35:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.00065:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (pow (pow x 3.0) 0.3333333333333333)))
   (if (<= z -1.35) t_0 (if (<= z 0.00065) (+ x (- z (tan a))) t_0))))
double code(double x, double y, double z, double a) {
	double t_0 = pow(pow(x, 3.0), 0.3333333333333333);
	double tmp;
	if (z <= -1.35) {
		tmp = t_0;
	} else if (z <= 0.00065) {
		tmp = x + (z - tan(a));
	} else {
		tmp = t_0;
	}
	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 = (x ** 3.0d0) ** 0.3333333333333333d0
    if (z <= (-1.35d0)) then
        tmp = t_0
    else if (z <= 0.00065d0) then
        tmp = x + (z - tan(a))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double a) {
	double t_0 = Math.pow(Math.pow(x, 3.0), 0.3333333333333333);
	double tmp;
	if (z <= -1.35) {
		tmp = t_0;
	} else if (z <= 0.00065) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z, a):
	t_0 = math.pow(math.pow(x, 3.0), 0.3333333333333333)
	tmp = 0
	if z <= -1.35:
		tmp = t_0
	elif z <= 0.00065:
		tmp = x + (z - math.tan(a))
	else:
		tmp = t_0
	return tmp
function code(x, y, z, a)
	t_0 = (x ^ 3.0) ^ 0.3333333333333333
	tmp = 0.0
	if (z <= -1.35)
		tmp = t_0;
	elseif (z <= 0.00065)
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z, a)
	t_0 = (x ^ 3.0) ^ 0.3333333333333333;
	tmp = 0.0;
	if (z <= -1.35)
		tmp = t_0;
	elseif (z <= 0.00065)
		tmp = x + (z - tan(a));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Power[N[Power[x, 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]}, If[LessEqual[z, -1.35], t$95$0, If[LessEqual[z, 0.00065], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left({x}^{3}\right)}^{0.3333333333333333}\\
\mathbf{if}\;z \leq -1.35:\\
\;\;\;\;t\_0\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.3500000000000001 or 6.4999999999999997e-4 < z

    1. Initial program 58.3%

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

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(x + \left(\tan \left(y + z\right) - \tan a\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)\right) \cdot \left(x + \left(\tan \left(y + z\right) - \tan a\right)\right)}} \]
      2. pow1/350.8%

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

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

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

        \[\leadsto {\left({\color{blue}{\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}}^{3}\right)}^{0.3333333333333333} \]
    4. Applied egg-rr50.8%

      \[\leadsto \color{blue}{{\left({\left(\tan \left(y + z\right) - \left(\tan a - x\right)\right)}^{3}\right)}^{0.3333333333333333}} \]
    5. Taylor expanded in x around inf 21.4%

      \[\leadsto {\left({\color{blue}{x}}^{3}\right)}^{0.3333333333333333} \]

    if -1.3500000000000001 < z < 6.4999999999999997e-4

    1. Initial program 99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.35:\\ \;\;\;\;{\left({x}^{3}\right)}^{0.3333333333333333}\\ \mathbf{elif}\;z \leq 0.00065:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;{\left({x}^{3}\right)}^{0.3333333333333333}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 41.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.98:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00065:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (if (<= z -0.98) x (if (<= z 0.00065) (+ x (- z (tan a))) (expm1 (log1p x)))))
double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= -0.98) {
		tmp = x;
	} else if (z <= 0.00065) {
		tmp = x + (z - tan(a));
	} else {
		tmp = expm1(log1p(x));
	}
	return tmp;
}
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= -0.98) {
		tmp = x;
	} else if (z <= 0.00065) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = Math.expm1(Math.log1p(x));
	}
	return tmp;
}
def code(x, y, z, a):
	tmp = 0
	if z <= -0.98:
		tmp = x
	elif z <= 0.00065:
		tmp = x + (z - math.tan(a))
	else:
		tmp = math.expm1(math.log1p(x))
	return tmp
function code(x, y, z, a)
	tmp = 0.0
	if (z <= -0.98)
		tmp = x;
	elseif (z <= 0.00065)
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = expm1(log1p(x));
	end
	return tmp
end
code[x_, y_, z_, a_] := If[LessEqual[z, -0.98], x, If[LessEqual[z, 0.00065], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(Exp[N[Log[1 + x], $MachinePrecision]] - 1), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.98:\\
\;\;\;\;x\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\


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

    1. Initial program 61.2%

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

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

    if -0.97999999999999998 < z < 6.4999999999999997e-4

    1. Initial program 99.6%

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

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

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

    if 6.4999999999999997e-4 < z

    1. Initial program 55.4%

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

        \[\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) \]
    4. 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) \]
    5. Step-by-step derivation
      1. *-un-lft-identity99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot x} \]
    10. Step-by-step derivation
      1. neg-mul-13.3%

        \[\leadsto \color{blue}{-x} \]
    11. Simplified3.3%

      \[\leadsto \color{blue}{-x} \]
    12. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \color{blue}{\sqrt{-x} \cdot \sqrt{-x}} \]
      2. sqrt-unprod22.1%

        \[\leadsto \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
      3. sqr-neg22.1%

        \[\leadsto \sqrt{\color{blue}{x \cdot x}} \]
      4. sqrt-unprod22.1%

        \[\leadsto \color{blue}{\sqrt{x} \cdot \sqrt{x}} \]
      5. add-sqr-sqrt22.1%

        \[\leadsto \color{blue}{x} \]
      6. expm1-log1p-u22.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \]
      7. expm1-undefine22.1%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x\right)} - 1} \]
    13. Applied egg-rr22.1%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x\right)} - 1} \]
    14. Step-by-step derivation
      1. expm1-define22.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \]
    15. Simplified22.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification38.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.98:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00065:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.5% 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 76.9%

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

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

Alternative 8: 60.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
  8. Final simplification58.9%

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

Alternative 9: 60.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

Alternative 10: 41.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.80000000000000004 or 6.4999999999999997e-4 < z

    1. Initial program 58.3%

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

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

    if -1.80000000000000004 < z < 6.4999999999999997e-4

    1. Initial program 99.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00065:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 31.6% 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 76.9%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification30.7%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

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