tan-example (used to crash)

Percentage Accurate: 79.8% → 99.7%
Time: 27.3s
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.8% 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 + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \left(1 + \mathsf{fma}\left(\tan y, \tan z, -1\right)\right)}, -\tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (fma
   (+ (tan y) (tan z))
   (/ 1.0 (- 1.0 (+ 1.0 (fma (tan y) (tan z) -1.0))))
   (- (tan a)))))
double code(double x, double y, double z, double a) {
	return x + fma((tan(y) + tan(z)), (1.0 / (1.0 - (1.0 + fma(tan(y), tan(z), -1.0)))), -tan(a));
}
function code(x, y, z, a)
	return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(1.0 - Float64(1.0 + fma(tan(y), tan(z), -1.0)))), Float64(-tan(a))))
end
code[x_, y_, z_, a_] := N[(x + 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] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

      \[\leadsto x + \mathsf{fma}\left(\tan y + \tan z, \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.8%

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

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

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

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

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

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

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

Alternative 2: 89.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \tan y + \tan z\\ \mathbf{if}\;\tan a \leq -4 \cdot 10^{-12} \lor \neg \left(\tan a \leq 0.04\right):\\ \;\;\;\;x + \mathsf{fma}\left(t_0, 1, -\tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t_0}{1 - \tan y \cdot \tan z}\\ \end{array} \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (let* ((t_0 (+ (tan y) (tan z))))
   (if (or (<= (tan a) -4e-12) (not (<= (tan a) 0.04)))
     (+ x (fma t_0 1.0 (- (tan a))))
     (+ x (/ t_0 (- 1.0 (* (tan y) (tan z))))))))
double code(double x, double y, double z, double a) {
	double t_0 = tan(y) + tan(z);
	double tmp;
	if ((tan(a) <= -4e-12) || !(tan(a) <= 0.04)) {
		tmp = x + fma(t_0, 1.0, -tan(a));
	} else {
		tmp = x + (t_0 / (1.0 - (tan(y) * tan(z))));
	}
	return tmp;
}
function code(x, y, z, a)
	t_0 = Float64(tan(y) + tan(z))
	tmp = 0.0
	if ((tan(a) <= -4e-12) || !(tan(a) <= 0.04))
		tmp = Float64(x + fma(t_0, 1.0, Float64(-tan(a))));
	else
		tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z)))));
	end
	return tmp
end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[Tan[a], $MachinePrecision], -4e-12], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 0.04]], $MachinePrecision]], N[(x + N[(t$95$0 * 1.0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -4 \cdot 10^{-12} \lor \neg \left(\tan a \leq 0.04\right):\\
\;\;\;\;x + \mathsf{fma}\left(t_0, 1, -\tan a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \frac{t_0}{1 - \tan y \cdot \tan z}\\


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

    1. Initial program 80.0%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. 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.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. fma-neg99.8%

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

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

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

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

        \[\leadsto x + \mathsf{fma}\left(\tan y + \tan z, \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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (tan.f64 a) < 0.0400000000000000008

    1. Initial program 78.8%

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

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

        \[\leadsto \frac{\sin \left(y + \color{blue}{1 \cdot z}\right)}{\cos \left(y + z\right)} + x \]
      2. metadata-eval78.8%

        \[\leadsto \frac{\sin \left(y + \color{blue}{\left(--1\right)} \cdot z\right)}{\cos \left(y + z\right)} + x \]
      3. cancel-sign-sub-inv78.8%

        \[\leadsto \frac{\sin \color{blue}{\left(y - -1 \cdot z\right)}}{\cos \left(y + z\right)} + x \]
      4. *-lft-identity78.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{1 \cdot z}\right)} + x \]
      5. metadata-eval78.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{\left(--1\right)} \cdot z\right)} + x \]
      6. cancel-sign-sub-inv78.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \color{blue}{\left(y - -1 \cdot z\right)}} + x \]
      7. sub-neg78.8%

        \[\leadsto \frac{\sin \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      8. mul-1-neg78.8%

        \[\leadsto \frac{\sin \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      9. remove-double-neg78.8%

        \[\leadsto \frac{\sin \left(y + \color{blue}{z}\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      10. +-commutative78.8%

        \[\leadsto \frac{\sin \color{blue}{\left(z + y\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      11. sub-neg78.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}} + x \]
      12. mul-1-neg78.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)} + x \]
      13. remove-double-neg78.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \color{blue}{z}\right)} + x \]
      14. +-commutative78.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(z + y\right)}} + x \]
    4. Simplified78.8%

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(y + z\right)\right)\right)} + x \]
      4. expm1-udef67.0%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan \left(y + z\right)\right)} - 1\right)} + x \]
    6. Applied egg-rr67.0%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\tan z + \tan y}{1 - \tan z \cdot \tan y}} + x \]
      2. +-commutative99.0%

        \[\leadsto \frac{\color{blue}{\tan y + \tan z}}{1 - \tan z \cdot \tan y} + x \]
    10. Applied egg-rr99.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\tan a \leq -4 \cdot 10^{-12} \lor \neg \left(\tan a \leq 0.04\right):\\ \;\;\;\;x + \mathsf{fma}\left(\tan y + \tan z, 1, -\tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}\\ \end{array} \]

Alternative 3: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ x + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (fma (+ (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 + fma((tan(y) + tan(z)), (1.0 / (1.0 - (tan(y) * tan(z)))), -tan(a));
}
function code(x, y, z, a)
	return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), Float64(-tan(a))))
end
code[x_, y_, z_, a_] := N[(x + 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] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

Alternative 4: 99.7% accurate, 0.4× speedup?

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

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

    \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
  2. 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) \]
  3. Applied egg-rr99.8%

    \[\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.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) \]
  5. Simplified99.8%

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

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

Alternative 5: 80.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ x + \mathsf{fma}\left(\tan y + \tan z, 1, -\tan a\right) \end{array} \]
(FPCore (x y z a)
 :precision binary64
 (+ x (fma (+ (tan y) (tan z)) 1.0 (- (tan a)))))
double code(double x, double y, double z, double a) {
	return x + fma((tan(y) + tan(z)), 1.0, -tan(a));
}
function code(x, y, z, a)
	return Float64(x + fma(Float64(tan(y) + tan(z)), 1.0, Float64(-tan(a))))
end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * 1.0 + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

      \[\leadsto x + \mathsf{fma}\left(\tan y + \tan z, \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.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x + \mathsf{fma}\left(\tan y + \tan z, 1, -\tan a\right) \]

Alternative 6: 60.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 69.0%

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

      \[\leadsto \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + x} \]
    3. Step-by-step derivation
      1. *-lft-identity51.3%

        \[\leadsto \frac{\sin \left(y + \color{blue}{1 \cdot z}\right)}{\cos \left(y + z\right)} + x \]
      2. metadata-eval51.3%

        \[\leadsto \frac{\sin \left(y + \color{blue}{\left(--1\right)} \cdot z\right)}{\cos \left(y + z\right)} + x \]
      3. cancel-sign-sub-inv51.3%

        \[\leadsto \frac{\sin \color{blue}{\left(y - -1 \cdot z\right)}}{\cos \left(y + z\right)} + x \]
      4. *-lft-identity51.3%

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

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{\left(--1\right)} \cdot z\right)} + x \]
      6. cancel-sign-sub-inv51.3%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \color{blue}{\left(y - -1 \cdot z\right)}} + x \]
      7. sub-neg51.3%

        \[\leadsto \frac{\sin \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      8. mul-1-neg51.3%

        \[\leadsto \frac{\sin \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      9. remove-double-neg51.3%

        \[\leadsto \frac{\sin \left(y + \color{blue}{z}\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      10. +-commutative51.3%

        \[\leadsto \frac{\sin \color{blue}{\left(z + y\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      11. sub-neg51.3%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}} + x \]
      12. mul-1-neg51.3%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)} + x \]
      13. remove-double-neg51.3%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \color{blue}{z}\right)} + x \]
      14. +-commutative51.3%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(z + y\right)}} + x \]
    4. Simplified51.3%

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

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

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(y + z\right)\right)\right)} + x \]
      4. expm1-udef39.3%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan \left(y + z\right)\right)} - 1\right)} + x \]
    6. Applied egg-rr39.3%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(y + z\right)\right)\right)} + x \]
      2. expm1-log1p51.3%

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

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

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

    if -500 < (+.f64 y z)

    1. Initial program 86.4%

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

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

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

        \[\leadsto x + \left(\sqrt{\color{blue}{{\tan \left(y + z\right)}^{2}}} - \tan a\right) \]
    3. Applied egg-rr73.7%

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

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

        \[\leadsto x + \left(\sqrt{{\color{blue}{\tan z}}^{2}} - \tan a\right) \]
      2. sqrt-pow169.2%

        \[\leadsto x + \left(\color{blue}{{\tan z}^{\left(\frac{2}{2}\right)}} - \tan a\right) \]
      3. metadata-eval69.2%

        \[\leadsto x + \left({\tan z}^{\color{blue}{1}} - \tan a\right) \]
      4. pow169.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y + z \leq -500:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \]

Alternative 7: 79.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 8: 59.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -7.2 \cdot 10^{-22} \lor \neg \left(a \leq 2.7 \cdot 10^{+21}\right):\\
\;\;\;\;x - \tan a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if a < -7.1999999999999996e-22 or 2.7e21 < a

    1. Initial program 77.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\left(x \cdot x - {\tan \left(y + z\right)}^{2}\right)}{-\left(x - \tan \left(y + z\right)\right)}} - \tan a \]
    6. Step-by-step derivation
      1. neg-sub076.8%

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

        \[\leadsto \frac{\color{blue}{\left(0 - x \cdot x\right) + {\tan \left(y + z\right)}^{2}}}{-\left(x - \tan \left(y + z\right)\right)} - \tan a \]
      3. neg-sub076.8%

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

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

        \[\leadsto \frac{\color{blue}{{\tan \left(y + z\right)}^{2} - x \cdot x}}{-\left(x - \tan \left(y + z\right)\right)} - \tan a \]
      6. neg-sub076.8%

        \[\leadsto \frac{{\tan \left(y + z\right)}^{2} - x \cdot x}{\color{blue}{0 - \left(x - \tan \left(y + z\right)\right)}} - \tan a \]
      7. associate--r-76.8%

        \[\leadsto \frac{{\tan \left(y + z\right)}^{2} - x \cdot x}{\color{blue}{\left(0 - x\right) + \tan \left(y + z\right)}} - \tan a \]
      8. neg-sub076.8%

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

        \[\leadsto \frac{{\tan \left(y + z\right)}^{2} - x \cdot x}{\color{blue}{\tan \left(y + z\right) + \left(-x\right)}} - \tan a \]
      10. sub-neg76.8%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-x \cdot x}}{\tan \left(z + y\right) - x} - \tan a \]
      3. distribute-rgt-neg-in44.2%

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

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

      \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-1 \cdot x}} - \tan a \]
    12. Step-by-step derivation
      1. neg-mul-141.0%

        \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-x}} - \tan a \]
    13. Simplified41.0%

      \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-x}} - \tan a \]
    14. Step-by-step derivation
      1. sub-neg41.0%

        \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} + \left(-\tan a\right)} \]
    15. Applied egg-rr41.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} + \left(-\tan a\right)} \]
    16. Step-by-step derivation
      1. sub-neg41.0%

        \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} - \tan a} \]
      2. distribute-rgt-neg-out41.0%

        \[\leadsto \frac{\color{blue}{-x \cdot x}}{-x} - \tan a \]
      3. unpow241.0%

        \[\leadsto \frac{-\color{blue}{{x}^{2}}}{-x} - \tan a \]
      4. *-rgt-identity41.0%

        \[\leadsto \frac{\color{blue}{\left(-{x}^{2}\right) \cdot 1}}{-x} - \tan a \]
      5. associate-*r/40.9%

        \[\leadsto \color{blue}{\left(-{x}^{2}\right) \cdot \frac{1}{-x}} - \tan a \]
      6. unpow240.9%

        \[\leadsto \left(-\color{blue}{x \cdot x}\right) \cdot \frac{1}{-x} - \tan a \]
      7. distribute-rgt-neg-out40.9%

        \[\leadsto \color{blue}{\left(x \cdot \left(-x\right)\right)} \cdot \frac{1}{-x} - \tan a \]
      8. associate-*l*41.0%

        \[\leadsto \color{blue}{x \cdot \left(\left(-x\right) \cdot \frac{1}{-x}\right)} - \tan a \]
      9. rgt-mult-inverse41.0%

        \[\leadsto x \cdot \color{blue}{1} - \tan a \]
      10. *-rgt-identity41.0%

        \[\leadsto \color{blue}{x} - \tan a \]
    17. Simplified41.0%

      \[\leadsto \color{blue}{x - \tan a} \]

    if -7.1999999999999996e-22 < a < 2.7e21

    1. Initial program 81.6%

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

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

        \[\leadsto \frac{\sin \left(y + \color{blue}{1 \cdot z}\right)}{\cos \left(y + z\right)} + x \]
      2. metadata-eval79.8%

        \[\leadsto \frac{\sin \left(y + \color{blue}{\left(--1\right)} \cdot z\right)}{\cos \left(y + z\right)} + x \]
      3. cancel-sign-sub-inv79.8%

        \[\leadsto \frac{\sin \color{blue}{\left(y - -1 \cdot z\right)}}{\cos \left(y + z\right)} + x \]
      4. *-lft-identity79.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{1 \cdot z}\right)} + x \]
      5. metadata-eval79.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{\left(--1\right)} \cdot z\right)} + x \]
      6. cancel-sign-sub-inv79.8%

        \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \color{blue}{\left(y - -1 \cdot z\right)}} + x \]
      7. sub-neg79.8%

        \[\leadsto \frac{\sin \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      8. mul-1-neg79.8%

        \[\leadsto \frac{\sin \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      9. remove-double-neg79.8%

        \[\leadsto \frac{\sin \left(y + \color{blue}{z}\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
      10. +-commutative79.8%

        \[\leadsto \frac{\sin \color{blue}{\left(z + y\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
      11. sub-neg79.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}} + x \]
      12. mul-1-neg79.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)} + x \]
      13. remove-double-neg79.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \color{blue}{z}\right)} + x \]
      14. +-commutative79.8%

        \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(z + y\right)}} + x \]
    4. Simplified79.8%

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

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

        \[\leadsto \tan \color{blue}{\left(y + z\right)} + x \]
      3. expm1-log1p-u67.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\tan \left(y + z\right)\right)\right)} + x \]
      4. expm1-udef67.9%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\tan \left(y + z\right)\right)} - 1\right)} + x \]
    6. Applied egg-rr67.9%

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

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

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

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

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

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

Alternative 9: 31.9% accurate, 2.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\sin \left(y + z\right)}{\cos \left(y + z\right)} + x} \]
  3. Step-by-step derivation
    1. *-lft-identity52.2%

      \[\leadsto \frac{\sin \left(y + \color{blue}{1 \cdot z}\right)}{\cos \left(y + z\right)} + x \]
    2. metadata-eval52.2%

      \[\leadsto \frac{\sin \left(y + \color{blue}{\left(--1\right)} \cdot z\right)}{\cos \left(y + z\right)} + x \]
    3. cancel-sign-sub-inv52.2%

      \[\leadsto \frac{\sin \color{blue}{\left(y - -1 \cdot z\right)}}{\cos \left(y + z\right)} + x \]
    4. *-lft-identity52.2%

      \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{1 \cdot z}\right)} + x \]
    5. metadata-eval52.2%

      \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \left(y + \color{blue}{\left(--1\right)} \cdot z\right)} + x \]
    6. cancel-sign-sub-inv52.2%

      \[\leadsto \frac{\sin \left(y - -1 \cdot z\right)}{\cos \color{blue}{\left(y - -1 \cdot z\right)}} + x \]
    7. sub-neg52.2%

      \[\leadsto \frac{\sin \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
    8. mul-1-neg52.2%

      \[\leadsto \frac{\sin \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
    9. remove-double-neg52.2%

      \[\leadsto \frac{\sin \left(y + \color{blue}{z}\right)}{\cos \left(y - -1 \cdot z\right)} + x \]
    10. +-commutative52.2%

      \[\leadsto \frac{\sin \color{blue}{\left(z + y\right)}}{\cos \left(y - -1 \cdot z\right)} + x \]
    11. sub-neg52.2%

      \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(y + \left(--1 \cdot z\right)\right)}} + x \]
    12. mul-1-neg52.2%

      \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \left(-\color{blue}{\left(-z\right)}\right)\right)} + x \]
    13. remove-double-neg52.2%

      \[\leadsto \frac{\sin \left(z + y\right)}{\cos \left(y + \color{blue}{z}\right)} + x \]
    14. +-commutative52.2%

      \[\leadsto \frac{\sin \left(z + y\right)}{\cos \color{blue}{\left(z + y\right)}} + x \]
  4. Simplified52.2%

    \[\leadsto \color{blue}{\frac{\sin \left(z + y\right)}{\cos \left(z + y\right)} + x} \]
  5. Taylor expanded in y around 0 41.0%

    \[\leadsto \frac{\sin \left(z + y\right)}{\color{blue}{\cos z}} + x \]
  6. Taylor expanded in z around 0 33.1%

    \[\leadsto \color{blue}{\sin y} + x \]
  7. Final simplification33.1%

    \[\leadsto x + \sin y \]

Alternative 10: 41.8% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{\tan \left(y + z\right)}^{2} - x \cdot x}{\color{blue}{0 - \left(x - \tan \left(y + z\right)\right)}} - \tan a \]
    7. associate--r-79.1%

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot {x}^{2}}}{\tan \left(z + y\right) - x} - \tan a \]
  9. Step-by-step derivation
    1. unpow245.0%

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

      \[\leadsto \frac{\color{blue}{-x \cdot x}}{\tan \left(z + y\right) - x} - \tan a \]
    3. distribute-rgt-neg-in45.0%

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

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

    \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-1 \cdot x}} - \tan a \]
  12. Step-by-step derivation
    1. neg-mul-142.0%

      \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-x}} - \tan a \]
  13. Simplified42.0%

    \[\leadsto \frac{x \cdot \left(-x\right)}{\color{blue}{-x}} - \tan a \]
  14. Step-by-step derivation
    1. sub-neg42.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} + \left(-\tan a\right)} \]
  15. Applied egg-rr42.0%

    \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} + \left(-\tan a\right)} \]
  16. Step-by-step derivation
    1. sub-neg42.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(-x\right)}{-x} - \tan a} \]
    2. distribute-rgt-neg-out42.0%

      \[\leadsto \frac{\color{blue}{-x \cdot x}}{-x} - \tan a \]
    3. unpow242.0%

      \[\leadsto \frac{-\color{blue}{{x}^{2}}}{-x} - \tan a \]
    4. *-rgt-identity42.0%

      \[\leadsto \frac{\color{blue}{\left(-{x}^{2}\right) \cdot 1}}{-x} - \tan a \]
    5. associate-*r/41.9%

      \[\leadsto \color{blue}{\left(-{x}^{2}\right) \cdot \frac{1}{-x}} - \tan a \]
    6. unpow241.9%

      \[\leadsto \left(-\color{blue}{x \cdot x}\right) \cdot \frac{1}{-x} - \tan a \]
    7. distribute-rgt-neg-out41.9%

      \[\leadsto \color{blue}{\left(x \cdot \left(-x\right)\right)} \cdot \frac{1}{-x} - \tan a \]
    8. associate-*l*42.0%

      \[\leadsto \color{blue}{x \cdot \left(\left(-x\right) \cdot \frac{1}{-x}\right)} - \tan a \]
    9. rgt-mult-inverse42.0%

      \[\leadsto x \cdot \color{blue}{1} - \tan a \]
    10. *-rgt-identity42.0%

      \[\leadsto \color{blue}{x} - \tan a \]
  17. Simplified42.0%

    \[\leadsto \color{blue}{x - \tan a} \]
  18. Final simplification42.0%

    \[\leadsto x - \tan a \]

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

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification33.0%

    \[\leadsto x \]

Reproduce

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