Average Error: 7.7 → 0.5
Time: 19.6s
Precision: binary64
Cost: 2884
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := z \cdot t - x\\ \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t_1}}{x + 1} \leq \infty:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1} + \frac{y}{t_1 \cdot \frac{x + 1}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{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 (- (* z t) x)))
   (if (<= (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0)) INFINITY)
     (+ (/ (- x (/ x t_1)) (+ x 1.0)) (/ y (* t_1 (/ (+ x 1.0) z))))
     (/ (+ x (/ y t)) (+ 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 = (z * t) - x;
	double tmp;
	if (((x + (((y * z) - x) / t_1)) / (x + 1.0)) <= ((double) INFINITY)) {
		tmp = ((x - (x / t_1)) / (x + 1.0)) + (y / (t_1 * ((x + 1.0) / z)));
	} else {
		tmp = (x + (y / t)) / (x + 1.0);
	}
	return tmp;
}
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 = (z * t) - x;
	double tmp;
	if (((x + (((y * z) - x) / t_1)) / (x + 1.0)) <= Double.POSITIVE_INFINITY) {
		tmp = ((x - (x / t_1)) / (x + 1.0)) + (y / (t_1 * ((x + 1.0) / z)));
	} else {
		tmp = (x + (y / t)) / (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 = (z * t) - x
	tmp = 0
	if ((x + (((y * z) - x) / t_1)) / (x + 1.0)) <= math.inf:
		tmp = ((x - (x / t_1)) / (x + 1.0)) + (y / (t_1 * ((x + 1.0) / z)))
	else:
		tmp = (x + (y / t)) / (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(Float64(z * t) - x)
	tmp = 0.0
	if (Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0)) <= Inf)
		tmp = Float64(Float64(Float64(x - Float64(x / t_1)) / Float64(x + 1.0)) + Float64(y / Float64(t_1 * Float64(Float64(x + 1.0) / z))));
	else
		tmp = Float64(Float64(x + Float64(y / t)) / 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 = (z * t) - x;
	tmp = 0.0;
	if (((x + (((y * z) - x) / t_1)) / (x + 1.0)) <= Inf)
		tmp = ((x - (x / t_1)) / (x + 1.0)) + (y / (t_1 * ((x + 1.0) / z)));
	else
		tmp = (x + (y / t)) / (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[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[(x - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(y / N[(t$95$1 * N[(N[(x + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := z \cdot t - x\\
\mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t_1}}{x + 1} \leq \infty:\\
\;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1} + \frac{y}{t_1 \cdot \frac{x + 1}{z}}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

    1. Initial program 4.8

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified4.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 0 4.8

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, \frac{z}{x + 1}, \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\right)} \]
      Proof
      (fma.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (+.f64 x 1)) (/.f64 (-.f64 x (/.f64 x (-.f64 (*.f64 t z) x))) (+.f64 x 1))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (/.f64 (-.f64 x (/.f64 x (-.f64 (*.f64 t z) x))) (+.f64 x 1))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (+.f64 1 x)) (/.f64 (-.f64 x (/.f64 x (-.f64 (*.f64 t z) x))) (Rewrite<= +-commutative_binary64 (+.f64 1 x)))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (+.f64 1 x)) (Rewrite=> div-sub_binary64 (-.f64 (/.f64 x (+.f64 1 x)) (/.f64 (/.f64 x (-.f64 (*.f64 t z) x)) (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (fma.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (+.f64 1 x)) (-.f64 (/.f64 x (+.f64 1 x)) (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x)))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (/.f64 y (-.f64 (*.f64 t z) x)) (/.f64 z (+.f64 1 x))) (-.f64 (/.f64 x (+.f64 1 x)) (/.f64 x (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 y z) (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x)))) (-.f64 (/.f64 x (+.f64 1 x)) (/.f64 x (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x))))): 39 points increase in error, 13 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 y z) (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x))) (/.f64 x (+.f64 1 x))) (/.f64 x (*.f64 (-.f64 (*.f64 t z) x) (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr0.6

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

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

    1. Initial program 64.0

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

      \[\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 z around inf 0.0

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

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

Alternatives

Alternative 1
Error1.6
Cost3400
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{x + \frac{z}{\frac{t_1}{y}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+271}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 2
Error1.7
Cost3400
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{t_1 \cdot \left(x + 1\right)}{z}} + \frac{x + 1}{x + 1}\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+271}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 3
Error1.2
Cost2884
\[\begin{array}{l} t_1 := z \cdot t - x\\ \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t_1}}{x + 1} \leq \infty:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1} + \frac{y}{\frac{t_1 \cdot \left(x + 1\right)}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 4
Error20.9
Cost1504
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ t_2 := 1 - y \cdot \frac{z}{x}\\ \mathbf{if}\;x \leq -1.7171851863651042 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.9555022153688294 \cdot 10^{-111}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -7.64087482223622 \cdot 10^{-131}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq -2.421148494295588 \cdot 10^{-190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.318579551571572 \cdot 10^{-190}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.2394840880444366 \cdot 10^{-133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.98262462559044 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 5.024671632950742 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.9
Cost1504
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ t_2 := 1 - y \cdot \frac{z}{x}\\ \mathbf{if}\;x \leq -1.7171851863651042 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.9555022153688294 \cdot 10^{-111}:\\ \;\;\;\;1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{elif}\;x \leq -7.64087482223622 \cdot 10^{-131}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq -2.421148494295588 \cdot 10^{-190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.318579551571572 \cdot 10^{-190}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.2394840880444366 \cdot 10^{-133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.98262462559044 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 5.024671632950742 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error9.9
Cost1356
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{z}{\frac{t_1}{y}}}{x + 1}\\ \mathbf{if}\;y \leq -3.4749110597033234 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.655518015288191 \cdot 10^{-151}:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1}\\ \mathbf{elif}\;y \leq 10^{+275}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\ \end{array} \]
Alternative 7
Error11.6
Cost1096
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -4.6632887868441304 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.552229358017878 \cdot 10^{-29}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error11.7
Cost968
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.5703737718789661 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.552229358017878 \cdot 10^{-29}:\\ \;\;\;\;1 - \frac{\frac{y \cdot z}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error13.7
Cost840
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.5703737718789661 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.786923852011499 \cdot 10^{-37}:\\ \;\;\;\;1 - y \cdot \frac{z}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error20.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1237479809210617 \cdot 10^{-55}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.98262462559044 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error20.6
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3112863316572175 \cdot 10^{-84}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.98262462559044 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Error28.2
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.552057566786246 \cdot 10^{-156}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.1108203084702848 \cdot 10^{-300}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 13
Error55.1
Cost64
\[x \]

Error

Reproduce

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