?

Average Accuracy: 85.3% → 94.5%
Time: 18.4s
Precision: binary64
Cost: 4556

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := x + \frac{y}{t}\\ t_2 := t \cdot z - x\\ t_3 := \frac{x + \frac{y \cdot z - x}{t_2}}{x + 1}\\ \mathbf{if}\;t_3 \leq -2:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_2}{z}}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{-93}:\\ \;\;\;\;\frac{t_1 - \frac{x}{t \cdot z}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{+262}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{x + 1}\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ y t)))
        (t_2 (- (* t z) x))
        (t_3 (/ (+ x (/ (- (* y z) x) t_2)) (+ x 1.0))))
   (if (<= t_3 -2.0)
     (/ (+ x (/ y (/ t_2 z))) (+ x 1.0))
     (if (<= t_3 2e-93)
       (/ (- t_1 (/ x (* t z))) (+ x 1.0))
       (if (<= t_3 2e+262) t_3 (/ t_1 (+ x 1.0)))))))
double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
double code(double x, double y, double z, double t) {
	double t_1 = x + (y / t);
	double t_2 = (t * z) - x;
	double t_3 = (x + (((y * z) - x) / t_2)) / (x + 1.0);
	double tmp;
	if (t_3 <= -2.0) {
		tmp = (x + (y / (t_2 / z))) / (x + 1.0);
	} else if (t_3 <= 2e-93) {
		tmp = (t_1 - (x / (t * z))) / (x + 1.0);
	} else if (t_3 <= 2e+262) {
		tmp = t_3;
	} else {
		tmp = t_1 / (x + 1.0);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0d0)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = x + (y / t)
    t_2 = (t * z) - x
    t_3 = (x + (((y * z) - x) / t_2)) / (x + 1.0d0)
    if (t_3 <= (-2.0d0)) then
        tmp = (x + (y / (t_2 / z))) / (x + 1.0d0)
    else if (t_3 <= 2d-93) then
        tmp = (t_1 - (x / (t * z))) / (x + 1.0d0)
    else if (t_3 <= 2d+262) then
        tmp = t_3
    else
        tmp = t_1 / (x + 1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (y / t);
	double t_2 = (t * z) - x;
	double t_3 = (x + (((y * z) - x) / t_2)) / (x + 1.0);
	double tmp;
	if (t_3 <= -2.0) {
		tmp = (x + (y / (t_2 / z))) / (x + 1.0);
	} else if (t_3 <= 2e-93) {
		tmp = (t_1 - (x / (t * z))) / (x + 1.0);
	} else if (t_3 <= 2e+262) {
		tmp = t_3;
	} else {
		tmp = t_1 / (x + 1.0);
	}
	return tmp;
}
def code(x, y, z, t):
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
def code(x, y, z, t):
	t_1 = x + (y / t)
	t_2 = (t * z) - x
	t_3 = (x + (((y * z) - x) / t_2)) / (x + 1.0)
	tmp = 0
	if t_3 <= -2.0:
		tmp = (x + (y / (t_2 / z))) / (x + 1.0)
	elif t_3 <= 2e-93:
		tmp = (t_1 - (x / (t * z))) / (x + 1.0)
	elif t_3 <= 2e+262:
		tmp = t_3
	else:
		tmp = t_1 / (x + 1.0)
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0))
end
function code(x, y, z, t)
	t_1 = Float64(x + Float64(y / t))
	t_2 = Float64(Float64(t * z) - x)
	t_3 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_2)) / Float64(x + 1.0))
	tmp = 0.0
	if (t_3 <= -2.0)
		tmp = Float64(Float64(x + Float64(y / Float64(t_2 / z))) / Float64(x + 1.0));
	elseif (t_3 <= 2e-93)
		tmp = Float64(Float64(t_1 - Float64(x / Float64(t * z))) / Float64(x + 1.0));
	elseif (t_3 <= 2e+262)
		tmp = t_3;
	else
		tmp = Float64(t_1 / Float64(x + 1.0));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (y / t);
	t_2 = (t * z) - x;
	t_3 = (x + (((y * z) - x) / t_2)) / (x + 1.0);
	tmp = 0.0;
	if (t_3 <= -2.0)
		tmp = (x + (y / (t_2 / z))) / (x + 1.0);
	elseif (t_3 <= 2e-93)
		tmp = (t_1 - (x / (t * z))) / (x + 1.0);
	elseif (t_3 <= 2e+262)
		tmp = t_3;
	else
		tmp = t_1 / (x + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -2.0], N[(N[(x + N[(y / N[(t$95$2 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e-93], N[(N[(t$95$1 - N[(x / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+262], t$95$3, N[(t$95$1 / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := x + \frac{y}{t}\\
t_2 := t \cdot z - x\\
t_3 := \frac{x + \frac{y \cdot z - x}{t_2}}{x + 1}\\
\mathbf{if}\;t_3 \leq -2:\\
\;\;\;\;\frac{x + \frac{y}{\frac{t_2}{z}}}{x + 1}\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{-93}:\\
\;\;\;\;\frac{t_1 - \frac{x}{t \cdot z}}{x + 1}\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+262}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{x + 1}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original85.3%
Target95.7%
Herbie94.5%
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation?

  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -2

    1. Initial program 57.1%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified57.1%

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Step-by-step derivation

      [Start]57.1

      \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]

      *-commutative [=>]57.1

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Taylor expanded in y around inf 55.4%

      \[\leadsto \frac{x + \color{blue}{\frac{y \cdot z}{t \cdot z - x}}}{x + 1} \]
    4. Simplified72.9%

      \[\leadsto \frac{x + \color{blue}{\frac{y}{\frac{t \cdot z - x}{z}}}}{x + 1} \]
      Step-by-step derivation

      [Start]55.4

      \[ \frac{x + \frac{y \cdot z}{t \cdot z - x}}{x + 1} \]

      associate-/l* [=>]72.9

      \[ \frac{x + \color{blue}{\frac{y}{\frac{t \cdot z - x}{z}}}}{x + 1} \]

    if -2 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.9999999999999998e-93

    1. Initial program 88.1%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified88.1%

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Step-by-step derivation

      [Start]88.1

      \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]

      *-commutative [=>]88.1

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Applied egg-rr88.3%

      \[\leadsto \frac{x + \color{blue}{\left(\frac{y}{\frac{z \cdot t - x}{z}} - \frac{x}{z \cdot t - x}\right)}}{x + 1} \]
      Step-by-step derivation

      [Start]88.1

      \[ \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \]

      div-sub [=>]88.1

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

      associate-/l* [=>]88.3

      \[ \frac{x + \left(\color{blue}{\frac{y}{\frac{z \cdot t - x}{z}}} - \frac{x}{z \cdot t - x}\right)}{x + 1} \]
    4. Taylor expanded in z around inf 100.0%

      \[\leadsto \frac{x + \left(\frac{y}{\color{blue}{t}} - \frac{x}{z \cdot t - x}\right)}{x + 1} \]
    5. Taylor expanded in t around inf 100.0%

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

    if 1.9999999999999998e-93 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2e262

    1. Initial program 100.0%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]

    if 2e262 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 10.0%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified10.0%

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Step-by-step derivation

      [Start]10.0

      \[ \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]

      *-commutative [=>]10.0

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Taylor expanded in z around inf 80.0%

      \[\leadsto \color{blue}{\frac{\frac{y}{t} + x}{1 + x}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification94.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq -2:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t \cdot z - x}{z}}}{x + 1}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq 2 \cdot 10^{-93}:\\ \;\;\;\;\frac{\left(x + \frac{y}{t}\right) - \frac{x}{t \cdot z}}{x + 1}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq 2 \cdot 10^{+262}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy77.4%
Cost1625
\[\begin{array}{l} t_1 := 1 - \frac{y}{x + 1} \cdot \frac{z}{x}\\ t_2 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -6 \cdot 10^{+36}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -3.4 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5 \cdot 10^{-145}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.3 \cdot 10^{-83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{-27} \lor \neg \left(t \leq 2.5 \cdot 10^{+60}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \end{array} \]
Alternative 2
Accuracy93.4%
Cost1604
\[\begin{array}{l} t_1 := t \cdot z - x\\ t_2 := \frac{x}{t_1}\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+38}:\\ \;\;\;\;\frac{x + \left(\frac{y}{t} - t_2\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y}{\frac{t_1}{z}} - t_2\right)}{x + 1}\\ \end{array} \]
Alternative 3
Accuracy86.5%
Cost1353
\[\begin{array}{l} t_1 := t \cdot z - x\\ \mathbf{if}\;t \leq -2.4 \cdot 10^{-17} \lor \neg \left(t \leq 1.42 \cdot 10^{+29}\right):\\ \;\;\;\;\frac{x + \left(\frac{y}{t} - \frac{x}{t_1}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \end{array} \]
Alternative 4
Accuracy78.3%
Cost1234
\[\begin{array}{l} \mathbf{if}\;t \leq -6 \cdot 10^{+36} \lor \neg \left(t \leq -3.4 \cdot 10^{-91} \lor \neg \left(t \leq -7.4 \cdot 10^{-145}\right) \land t \leq 4.6 \cdot 10^{-83}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{x + 1} \cdot \frac{z}{x}\\ \end{array} \]
Alternative 5
Accuracy84.0%
Cost1225
\[\begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{-146} \lor \neg \left(z \leq 9 \cdot 10^{-207}\right):\\ \;\;\;\;\frac{x + \frac{y}{\frac{t \cdot z - x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y \cdot z}{x \cdot \left(x + 1\right)}\\ \end{array} \]
Alternative 6
Accuracy63.9%
Cost1104
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-162}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{+17}:\\ \;\;\;\;1 - \frac{y \cdot z}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{-1}{x}\\ \end{array} \]
Alternative 7
Accuracy76.8%
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-29}:\\ \;\;\;\;\frac{x + \frac{y - \frac{x}{z}}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{x + 1} \cdot \frac{z}{x}\\ \end{array} \]
Alternative 8
Accuracy73.8%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-31}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.42 \cdot 10^{-27}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Accuracy63.8%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-162}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 10
Accuracy64.0%
Cost460
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-162}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-28}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Accuracy55.5%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-85}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Accuracy53.3%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023157 
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (/ (+ x (- (/ y (- t (/ x z))) (/ x (- (* t z) x)))) (+ x 1.0))

  (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))