tan-example (used to crash)

Percentage Accurate: 80.0% → 99.7%
Time: 52.4s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 80.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 88.6% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.1:\\
\;\;\;\;x + \left(t\_0 - \tan a\right)\\

\mathbf{elif}\;\tan a \leq 5 \cdot 10^{-17}:\\
\;\;\;\;x + \frac{t\_0}{1 - \tan y \cdot \tan z}\\

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


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

    1. Initial program 80.9%

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

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

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

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

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

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

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

    if -0.10000000000000001 < (tan.f64 a) < 4.9999999999999999e-17

    1. Initial program 76.1%

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

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

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

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

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

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

      \[\leadsto \tan \left(y + z\right) - \color{blue}{\left(-x\right)} \]
    8. 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) \]
    9. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \left(-x\right) \]
    10. 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) \]
    11. Simplified99.8%

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

    if 4.9999999999999999e-17 < (tan.f64 a)

    1. Initial program 82.2%

      \[x + \left(\tan \left(y + z\right) - \tan a\right) \]
    2. Add Preprocessing
  3. Recombined 3 regimes into one program.
  4. Final simplification89.8%

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

Alternative 4: 99.7% accurate, 0.4× speedup?

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

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

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

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

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  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. associate-*r/99.6%

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

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

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

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

Alternative 5: 60.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;t\_0 \leq -0.001 \lor \neg \left(t\_0 \leq 10^{-8}\right):\\
\;\;\;\;x + t\_0\\

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


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

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\tan \left(y + z\right) + \left(-\left(-x\right)\right)} \]
    10. Step-by-step derivation
      1. remove-double-neg43.2%

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

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

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

    if -1e-3 < (tan.f64 (+.f64 y z)) < 1e-8

    1. Initial program 99.8%

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

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

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

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

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

      \[\leadsto x + \left(\color{blue}{\left(\sin y + z \cdot \cos y\right)} - \tan a\right) \]
    7. Taylor expanded in y around 0 99.8%

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

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

Alternative 6: 80.3% 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 79.2%

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

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

      \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  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. associate-*r/99.6%

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

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

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

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

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

Alternative 7: 61.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.011 \lor \neg \left(a \leq 0.36\right):\\
\;\;\;\;x + \left(\sin y - \tan a\right)\\

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


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

    1. Initial program 81.8%

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

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

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

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

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

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

    if -0.010999999999999999 < a < 0.35999999999999999

    1. Initial program 76.1%

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

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

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

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

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

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

Alternative 8: 80.0% 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.2%

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

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

Alternative 9: 51.8% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\tan \left(y + z\right) + \left(-\left(-x\right)\right)} \]
  10. Step-by-step derivation
    1. remove-double-neg46.2%

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

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

    \[\leadsto \color{blue}{x + \tan \left(y + z\right)} \]
  12. Final simplification46.2%

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

Alternative 10: 32.5% accurate, 207.0× speedup?

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

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

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

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

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

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