tan-example (used to crash)

Percentage Accurate: 79.7% → 99.7%
Time: 44.9s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 79.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\frac{\tan y + \tan z}{1 - \frac{\tan y}{\frac{\cos z}{\sin z}}} - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (+
  x
  (- (/ (+ (tan y) (tan z)) (- 1.0 (/ (tan y) (/ (cos z) (sin z))))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) / (cos(z) / sin(z))))) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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) / (cos(z) / sin(z))))) - tan(a))
end function
assert x < y && y < z && z < a;
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.cos(z) / Math.sin(z))))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) / (math.cos(z) / math.sin(z))))) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) / Float64(cos(z) / sin(z))))) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) / (cos(z) / sin(z))))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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[(N[Cos[z], $MachinePrecision] / N[Sin[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan y + \tan z}{1 - \frac{\tan y}{\frac{\cos z}{\sin z}}} - \tan a\right)
\end{array}
Derivation
  1. Initial program 80.7%

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

    \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  5. Step-by-step derivation
    1. associate-*r/99.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) \]
  6. Simplified99.8%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
assert(x < y && y < z && z < 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));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < a;
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));
}
[x, y, z, a] = sort([x, y, z, 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))
x, y, z, a = sort([x, y, z, 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
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Derivation
  1. Initial program 80.7%

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

    \[\leadsto x + \left(\color{blue}{\left(\tan y + \tan z\right) \cdot \frac{1}{1 - \tan y \cdot \tan z}} - \tan a\right) \]
  5. Step-by-step derivation
    1. associate-*r/99.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) \]
  6. Simplified99.8%

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

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

Alternative 3: 79.6% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\log \left(e^{\tan \left(y + z\right)}\right) - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (+ x (- (log (exp (tan (+ y z)))) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + (log(exp(tan((y + z)))) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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 + (log(exp(tan((y + z)))) - tan(a))
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x + (Math.log(Math.exp(Math.tan((y + z)))) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + (math.log(math.exp(math.tan((y + z)))) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(log(exp(tan(Float64(y + z)))) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (log(exp(tan((y + z)))) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := N[(x + N[(N[Log[N[Exp[N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\log \left(e^{\tan \left(y + z\right)}\right) - \tan a\right)
\end{array}
Derivation
  1. Initial program 80.7%

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

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

    \[\leadsto x + \left(\color{blue}{\log \left(e^{\tan \left(y + z\right)}\right)} - \tan a\right) \]
  5. Final simplification80.7%

    \[\leadsto x + \left(\log \left(e^{\tan \left(y + z\right)}\right) - \tan a\right) \]
  6. Add Preprocessing

Alternative 4: 70.0% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(\tan z - \tan a\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (if (<= (+ y z) -2e-6) (+ x (tan (+ y z))) (+ x (- (tan z) (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + tan((y + z));
	} else {
		tmp = x + (tan(z) - tan(a));
	}
	return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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) <= (-2d-6)) then
        tmp = x + tan((y + z))
    else
        tmp = x + (tan(z) - tan(a))
    end if
    code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + Math.tan((y + z));
	} else {
		tmp = x + (Math.tan(z) - Math.tan(a));
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	tmp = 0
	if (y + z) <= -2e-6:
		tmp = x + math.tan((y + z))
	else:
		tmp = x + (math.tan(z) - math.tan(a))
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	tmp = 0.0
	if (Float64(y + z) <= -2e-6)
		tmp = Float64(x + tan(Float64(y + z)));
	else
		tmp = Float64(x + Float64(tan(z) - tan(a)));
	end
	return tmp
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((y + z) <= -2e-6)
		tmp = x + tan((y + z));
	else
		tmp = x + (tan(z) - tan(a));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2e-6], 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}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\
\;\;\;\;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) < -1.99999999999999991e-6

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if -1.99999999999999991e-6 < (+.f64 y z)

    1. Initial program 81.2%

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

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

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

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

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

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

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

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

Alternative 5: 70.0% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\tan z + \left(x - \tan a\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (if (<= (+ y z) -2e-6) (+ x (tan (+ y z))) (+ (tan z) (- x (tan a)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + tan((y + z));
	} else {
		tmp = tan(z) + (x - tan(a));
	}
	return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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) <= (-2d-6)) then
        tmp = x + tan((y + z))
    else
        tmp = tan(z) + (x - tan(a))
    end if
    code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + Math.tan((y + z));
	} else {
		tmp = Math.tan(z) + (x - Math.tan(a));
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	tmp = 0
	if (y + z) <= -2e-6:
		tmp = x + math.tan((y + z))
	else:
		tmp = math.tan(z) + (x - math.tan(a))
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	tmp = 0.0
	if (Float64(y + z) <= -2e-6)
		tmp = Float64(x + tan(Float64(y + z)));
	else
		tmp = Float64(tan(z) + Float64(x - tan(a)));
	end
	return tmp
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((y + z) <= -2e-6)
		tmp = x + tan((y + z));
	else
		tmp = tan(z) + (x - tan(a));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2e-6], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Tan[z], $MachinePrecision] + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\
\;\;\;\;x + \tan \left(y + z\right)\\

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


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

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if -1.99999999999999991e-6 < (+.f64 y z)

    1. Initial program 81.2%

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

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

        \[\leadsto x + \left(\color{blue}{\tan z} - \tan a\right) \]
      2. add-sqr-sqrt33.9%

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

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

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

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

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

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

      \[\leadsto x + \left(\color{blue}{\left|\tan z\right|} - \tan a\right) \]
    8. Step-by-step derivation
      1. associate-+r-59.2%

        \[\leadsto \color{blue}{\left(x + \left|\tan z\right|\right) - \tan a} \]
      2. add-sqr-sqrt33.9%

        \[\leadsto \left(x + \left|\color{blue}{\sqrt{\tan z} \cdot \sqrt{\tan z}}\right|\right) - \tan a \]
      3. fabs-sqr33.9%

        \[\leadsto \left(x + \color{blue}{\sqrt{\tan z} \cdot \sqrt{\tan z}}\right) - \tan a \]
      4. add-sqr-sqrt66.4%

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

      \[\leadsto \color{blue}{\left(x + \tan z\right) - \tan a} \]
    10. Step-by-step derivation
      1. associate-+r-66.4%

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

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

        \[\leadsto \color{blue}{\tan z - \left(\tan a - x\right)} \]
    11. Simplified66.4%

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

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

Alternative 6: 79.7% accurate, 1.0× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \left(\tan \left(y + z\right) - \tan a\right) \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + (tan((y + z)) - tan(a));
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x + (Math.tan((y + z)) - Math.tan(a));
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + (math.tan((y + z)) - math.tan(a))
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + Float64(tan(Float64(y + z)) - tan(a)))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + (tan((y + z)) - tan(a));
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Derivation
  1. Initial program 80.7%

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

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

Alternative 7: 60.4% accurate, 1.7× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\ \;\;\;\;x + \tan \left(y + z\right)\\ \mathbf{elif}\;y + z \leq 0.2:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \tan z\\ \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (if (<= (+ y z) -2e-6)
   (+ x (tan (+ y z)))
   (if (<= (+ y z) 0.2) (+ x (- z (tan a))) (+ x (tan z)))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + tan((y + z));
	} else if ((y + z) <= 0.2) {
		tmp = x + (z - tan(a));
	} else {
		tmp = x + tan(z);
	}
	return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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) <= (-2d-6)) then
        tmp = x + tan((y + z))
    else if ((y + z) <= 0.2d0) then
        tmp = x + (z - tan(a))
    else
        tmp = x + tan(z)
    end if
    code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double tmp;
	if ((y + z) <= -2e-6) {
		tmp = x + Math.tan((y + z));
	} else if ((y + z) <= 0.2) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = x + Math.tan(z);
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	tmp = 0
	if (y + z) <= -2e-6:
		tmp = x + math.tan((y + z))
	elif (y + z) <= 0.2:
		tmp = x + (z - math.tan(a))
	else:
		tmp = x + math.tan(z)
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	tmp = 0.0
	if (Float64(y + z) <= -2e-6)
		tmp = Float64(x + tan(Float64(y + z)));
	elseif (Float64(y + z) <= 0.2)
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = Float64(x + tan(z));
	end
	return tmp
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if ((y + z) <= -2e-6)
		tmp = x + tan((y + z));
	elseif ((y + z) <= 0.2)
		tmp = x + (z - tan(a));
	else
		tmp = x + tan(z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -2e-6], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 0.2], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -2 \cdot 10^{-6}:\\
\;\;\;\;x + \tan \left(y + z\right)\\

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

\mathbf{else}:\\
\;\;\;\;x + \tan z\\


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

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if -1.99999999999999991e-6 < (+.f64 y z) < 0.20000000000000001

    1. Initial program 100.0%

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

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

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

    if 0.20000000000000001 < (+.f64 y z)

    1. Initial program 71.6%

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)} \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right) \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}} \]
      2. pow349.1%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right)}^{3}} \]
      3. tan-quot49.1%

        \[\leadsto {\left(\sqrt[3]{x + \left(\color{blue}{\tan z} - \tan a\right)}\right)}^{3} \]
    5. Applied egg-rr49.1%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\tan z - \tan a\right)}\right)}^{3}} \]
    6. Taylor expanded in a around 0 40.4%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{x + \frac{\sin z}{\cos z}}\right)}}^{3} \]
    7. Step-by-step derivation
      1. +-commutative40.4%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\sin z}{\cos z} + x}}\right)}^{3} \]
    8. Simplified40.4%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{\frac{\sin z}{\cos z} + x}\right)}}^{3} \]
    9. Step-by-step derivation
      1. rem-cube-cbrt40.9%

        \[\leadsto \color{blue}{\frac{\sin z}{\cos z} + x} \]
      2. tan-quot40.8%

        \[\leadsto \color{blue}{\tan z} + x \]
    10. Applied egg-rr40.8%

      \[\leadsto \color{blue}{\tan z + x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification58.1%

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

Alternative 8: 49.6% accurate, 1.9× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq 0.13:\\ \;\;\;\;x + \left(z - \tan a\right)\\ \mathbf{else}:\\ \;\;\;\;x + \tan z\\ \end{array} \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a)
 :precision binary64
 (if (<= z 0.13) (+ x (- z (tan a))) (+ x (tan z))))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= 0.13) {
		tmp = x + (z - tan(a));
	} else {
		tmp = x + tan(z);
	}
	return tmp;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    real(8) :: tmp
    if (z <= 0.13d0) then
        tmp = x + (z - tan(a))
    else
        tmp = x + tan(z)
    end if
    code = tmp
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	double tmp;
	if (z <= 0.13) {
		tmp = x + (z - Math.tan(a));
	} else {
		tmp = x + Math.tan(z);
	}
	return tmp;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	tmp = 0
	if z <= 0.13:
		tmp = x + (z - math.tan(a))
	else:
		tmp = x + math.tan(z)
	return tmp
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	tmp = 0.0
	if (z <= 0.13)
		tmp = Float64(x + Float64(z - tan(a)));
	else
		tmp = Float64(x + tan(z));
	end
	return tmp
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp_2 = code(x, y, z, a)
	tmp = 0.0;
	if (z <= 0.13)
		tmp = x + (z - tan(a));
	else
		tmp = x + tan(z);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := If[LessEqual[z, 0.13], N[(x + N[(z - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.13:\\
\;\;\;\;x + \left(z - \tan a\right)\\

\mathbf{else}:\\
\;\;\;\;x + \tan z\\


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

    1. Initial program 88.1%

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

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

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

    if 0.13 < z

    1. Initial program 61.8%

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)} \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right) \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}} \]
      2. pow360.9%

        \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right)}^{3}} \]
      3. tan-quot60.9%

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\tan z - \tan a\right)}\right)}^{3}} \]
    6. Taylor expanded in a around 0 48.7%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{x + \frac{\sin z}{\cos z}}\right)}}^{3} \]
    7. Step-by-step derivation
      1. +-commutative48.7%

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\sin z}{\cos z} + x}}\right)}^{3} \]
    8. Simplified48.7%

      \[\leadsto {\color{blue}{\left(\sqrt[3]{\frac{\sin z}{\cos z} + x}\right)}}^{3} \]
    9. Step-by-step derivation
      1. rem-cube-cbrt49.4%

        \[\leadsto \color{blue}{\frac{\sin z}{\cos z} + x} \]
      2. tan-quot49.3%

        \[\leadsto \color{blue}{\tan z} + x \]
    10. Applied egg-rr49.3%

      \[\leadsto \color{blue}{\tan z + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.4%

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

Alternative 9: 41.0% accurate, 2.0× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x + \tan z \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a) :precision binary64 (+ x (tan z)))
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x + tan(z);
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: a
    code = x + tan(z)
end function
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x + Math.tan(z);
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x + math.tan(z)
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return Float64(x + tan(z))
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x + tan(z);
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x + \tan z
\end{array}
Derivation
  1. Initial program 80.7%

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

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)} \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right) \cdot \sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}} \]
    2. pow361.7%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\frac{\sin z}{\cos z} - \tan a\right)}\right)}^{3}} \]
    3. tan-quot61.7%

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

    \[\leadsto \color{blue}{{\left(\sqrt[3]{x + \left(\tan z - \tan a\right)}\right)}^{3}} \]
  6. Taylor expanded in a around 0 45.0%

    \[\leadsto {\color{blue}{\left(\sqrt[3]{x + \frac{\sin z}{\cos z}}\right)}}^{3} \]
  7. Step-by-step derivation
    1. +-commutative45.0%

      \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\sin z}{\cos z} + x}}\right)}^{3} \]
  8. Simplified45.0%

    \[\leadsto {\color{blue}{\left(\sqrt[3]{\frac{\sin z}{\cos z} + x}\right)}}^{3} \]
  9. Step-by-step derivation
    1. rem-cube-cbrt45.6%

      \[\leadsto \color{blue}{\frac{\sin z}{\cos z} + x} \]
    2. tan-quot45.6%

      \[\leadsto \color{blue}{\tan z} + x \]
  10. Applied egg-rr45.6%

    \[\leadsto \color{blue}{\tan z + x} \]
  11. Final simplification45.6%

    \[\leadsto x + \tan z \]
  12. Add Preprocessing

Alternative 10: 31.7% accurate, 207.0× speedup?

\[\begin{array}{l} [x, y, z, a] = \mathsf{sort}([x, y, z, a])\\ \\ x \end{array} \]
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
(FPCore (x y z a) :precision binary64 x)
assert(x < y && y < z && z < a);
double code(double x, double y, double z, double a) {
	return x;
}
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
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
assert x < y && y < z && z < a;
public static double code(double x, double y, double z, double a) {
	return x;
}
[x, y, z, a] = sort([x, y, z, a])
def code(x, y, z, a):
	return x
x, y, z, a = sort([x, y, z, a])
function code(x, y, z, a)
	return x
end
x, y, z, a = num2cell(sort([x, y, z, a])){:}
function tmp = code(x, y, z, a)
	tmp = x;
end
NOTE: x, y, z, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, a_] := x
\begin{array}{l}
[x, y, z, a] = \mathsf{sort}([x, y, z, a])\\
\\
x
\end{array}
Derivation
  1. Initial program 80.7%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification32.1%

    \[\leadsto x \]
  5. Add Preprocessing

Reproduce

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