Average Error: 7.5 → 2.4
Time: 21.2s
Precision: binary64
Cost: 3400
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+19}:\\ \;\;\;\;\frac{\frac{y}{x + 1}}{t - \frac{x}{z}}\\ \mathbf{elif}\;t_1 \leq 10^{+220}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \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 z) x) (- (* z t) x))) (+ x 1.0))))
   (if (<= t_1 -2e+19)
     (/ (/ y (+ x 1.0)) (- t (/ x z)))
     (if (<= t_1 1e+220) t_1 (+ (/ x (+ x 1.0)) (/ y (+ t (* x t))))))))
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 * z) - x) / ((z * t) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= -2e+19) {
		tmp = (y / (x + 1.0)) / (t - (x / z));
	} else if (t_1 <= 1e+220) {
		tmp = t_1;
	} else {
		tmp = (x / (x + 1.0)) + (y / (t + (x * t)));
	}
	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) :: tmp
    t_1 = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0d0)
    if (t_1 <= (-2d+19)) then
        tmp = (y / (x + 1.0d0)) / (t - (x / z))
    else if (t_1 <= 1d+220) then
        tmp = t_1
    else
        tmp = (x / (x + 1.0d0)) + (y / (t + (x * t)))
    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 * z) - x) / ((z * t) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= -2e+19) {
		tmp = (y / (x + 1.0)) / (t - (x / z));
	} else if (t_1 <= 1e+220) {
		tmp = t_1;
	} else {
		tmp = (x / (x + 1.0)) + (y / (t + (x * t)));
	}
	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 * z) - x) / ((z * t) - x))) / (x + 1.0)
	tmp = 0
	if t_1 <= -2e+19:
		tmp = (y / (x + 1.0)) / (t - (x / z))
	elif t_1 <= 1e+220:
		tmp = t_1
	else:
		tmp = (x / (x + 1.0)) + (y / (t + (x * t)))
	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(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(z * t) - x))) / Float64(x + 1.0))
	tmp = 0.0
	if (t_1 <= -2e+19)
		tmp = Float64(Float64(y / Float64(x + 1.0)) / Float64(t - Float64(x / z)));
	elseif (t_1 <= 1e+220)
		tmp = t_1;
	else
		tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(y / Float64(t + Float64(x * t))));
	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 * z) - x) / ((z * t) - x))) / (x + 1.0);
	tmp = 0.0;
	if (t_1 <= -2e+19)
		tmp = (y / (x + 1.0)) / (t - (x / z));
	elseif (t_1 <= 1e+220)
		tmp = t_1;
	else
		tmp = (x / (x + 1.0)) + (y / (t + (x * t)));
	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[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+19], N[(N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+220], t$95$1, N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(y / N[(t + N[(x * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+19}:\\
\;\;\;\;\frac{\frac{y}{x + 1}}{t - \frac{x}{z}}\\

\mathbf{elif}\;t_1 \leq 10^{+220}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.5
Target0.4
Herbie2.4
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation

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

    1. Initial program 18.8

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 18.7

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

      \[\leadsto \color{blue}{\frac{y}{x + 1} \cdot \frac{z}{t \cdot z - x}} \]
      Proof
      (*.f64 (/.f64 y (+.f64 x 1)) (/.f64 z (-.f64 (*.f64 t z) x))): 0 points increase in error, 0 points decrease in error
      (*.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (/.f64 z (-.f64 (*.f64 t z) x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 y z) (*.f64 (+.f64 1 x) (-.f64 (*.f64 t z) x)))): 52 points increase in error, 38 points decrease in error
      (/.f64 (*.f64 y z) (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x)))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr7.0

      \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z \cdot t - x}{z}}}{x + 1}} \]
    6. Taylor expanded in z around 0 7.0

      \[\leadsto \frac{\frac{y}{\color{blue}{t + -1 \cdot \frac{x}{z}}}}{x + 1} \]
    7. Simplified7.0

      \[\leadsto \frac{\frac{y}{\color{blue}{t - \frac{x}{z}}}}{x + 1} \]
      Proof
      (-.f64 t (/.f64 x z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 t (neg.f64 (/.f64 x z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 t (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 x z)))): 0 points increase in error, 0 points decrease in error
    8. Taylor expanded in y around 0 5.3

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

      \[\leadsto \color{blue}{\frac{\frac{y}{x + 1}}{t - \frac{x}{z}}} \]
      Proof
      (/.f64 (/.f64 y (+.f64 x 1)) (-.f64 t (/.f64 x z))): 0 points increase in error, 0 points decrease in error
      (/.f64 (/.f64 y (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (-.f64 t (/.f64 x z))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-/l/_binary64 (/.f64 y (*.f64 (-.f64 t (/.f64 x z)) (+.f64 1 x)))): 7 points increase in error, 24 points decrease in error

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

    1. Initial program 0.7

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error

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

    1. Initial program 54.9

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

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 54.9

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

      \[\leadsto \frac{x + \color{blue}{\frac{z \cdot y}{t \cdot z - x}}}{x + 1} \]
      Proof
      (/.f64 (*.f64 z y) (-.f64 (*.f64 t z) x)): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) (-.f64 (*.f64 t z) x)): 0 points increase in error, 0 points decrease in error
    5. Taylor expanded in t around inf 14.2

      \[\leadsto \color{blue}{\frac{x}{1 + x} + \frac{y}{\left(1 + x\right) \cdot t}} \]
    6. Simplified14.2

      \[\leadsto \color{blue}{\frac{x}{x + 1} + \frac{y}{t + x \cdot t}} \]
      Proof
      (+.f64 (/.f64 x (+.f64 x 1)) (/.f64 y (+.f64 t (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (/.f64 y (+.f64 t (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 t)) (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (Rewrite<= distribute-rgt-in_binary64 (*.f64 t (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 1 x) t)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification2.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -2 \cdot 10^{+19}:\\ \;\;\;\;\frac{\frac{y}{x + 1}}{t - \frac{x}{z}}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 10^{+220}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \end{array} \]

Alternatives

Alternative 1
Error14.6
Cost1624
\[\begin{array}{l} t_1 := x + \frac{y}{t}\\ t_2 := \frac{t_1}{x + 1}\\ t_3 := \frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;x \leq -9.495715095579199 \cdot 10^{+52}:\\ \;\;\;\;1 + z \cdot \frac{t - y}{x \cdot x}\\ \mathbf{elif}\;x \leq -2.0310848508400053 \cdot 10^{-94}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 9.407019435540319 \cdot 10^{-183}:\\ \;\;\;\;\frac{t_1 - \frac{x}{z \cdot t}}{x + 1}\\ \mathbf{elif}\;x \leq 3.371763871289422 \cdot 10^{-35}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 9.041070078141304 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \end{array} \]
Alternative 2
Error10.6
Cost1356
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ t_2 := z \cdot t - x\\ \mathbf{if}\;z \leq -1089.9018992582007:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.204351069628322 \cdot 10^{-132}:\\ \;\;\;\;\frac{x - \frac{x}{t_2}}{x + 1}\\ \mathbf{elif}\;z \leq 3.9994802825605306 \cdot 10^{+43}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t_2}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.2
Cost1096
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \mathbf{if}\;z \leq -4.255094424711837 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1294034471756676 \cdot 10^{-93}:\\ \;\;\;\;1 - y \cdot \frac{z}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error12.4
Cost1096
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \mathbf{if}\;z \leq -1089.9018992582007:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1294034471756676 \cdot 10^{-93}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.5
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.888441688905696 \cdot 10^{-150}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.3156050915439947 \cdot 10^{-101}:\\ \;\;\;\;1 - y \cdot \frac{z}{x}\\ \mathbf{elif}\;x \leq 1.973416850695024 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.371763871289422 \cdot 10^{-35}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.041070078141304 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error20.5
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.888441688905696 \cdot 10^{-150}:\\ \;\;\;\;\frac{\frac{y}{t}}{x + 1}\\ \mathbf{elif}\;x \leq 1.3156050915439947 \cdot 10^{-101}:\\ \;\;\;\;1 - y \cdot \frac{z}{x}\\ \mathbf{elif}\;x \leq 1.973416850695024 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.371763871289422 \cdot 10^{-35}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.041070078141304 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error20.6
Cost984
\[\begin{array}{l} \mathbf{if}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.888441688905696 \cdot 10^{-150}:\\ \;\;\;\;\frac{\frac{y}{t}}{x + 1}\\ \mathbf{elif}\;x \leq 1.3156050915439947 \cdot 10^{-101}:\\ \;\;\;\;1 - z \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq 1.973416850695024 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.371763871289422 \cdot 10^{-35}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.041070078141304 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error20.8
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.888441688905696 \cdot 10^{-150}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.3156050915439947 \cdot 10^{-101}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.973416850695024 \cdot 10^{-38}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error13.4
Cost840
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -4.255094424711837 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1294034471756676 \cdot 10^{-93}:\\ \;\;\;\;1 - y \cdot \frac{z}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error21.1
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -9.817290941176692 \cdot 10^{-133}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.888441688905696 \cdot 10^{-150}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 3.371763871289422 \cdot 10^{-35}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.041070078141304 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error28.2
Cost64
\[1 \]

Error

Reproduce

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