?

Average Accuracy: 88.4% → 97.6%
Time: 22.5s
Precision: binary64
Cost: 9736

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := y \cdot z - x\\ t_2 := z \cdot t - x\\ t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\ \mathbf{if}\;t_3 \leq -5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_2}{z}}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;\frac{x + \frac{t_1}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{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 (- (* y z) x))
        (t_2 (- (* z t) x))
        (t_3 (/ (+ x (/ t_1 t_2)) (+ x 1.0))))
   (if (<= t_3 -5e+22)
     (/ (+ x (/ y (/ t_2 z))) (+ x 1.0))
     (if (<= t_3 2e+284)
       (/ (+ x (/ t_1 (fma z t (- x)))) (+ x 1.0))
       (+ (/ (- (/ y (+ x 1.0)) (/ x (* z (+ x 1.0)))) t) (/ x (+ 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 = (y * z) - x;
	double t_2 = (z * t) - x;
	double t_3 = (x + (t_1 / t_2)) / (x + 1.0);
	double tmp;
	if (t_3 <= -5e+22) {
		tmp = (x + (y / (t_2 / z))) / (x + 1.0);
	} else if (t_3 <= 2e+284) {
		tmp = (x + (t_1 / fma(z, t, -x))) / (x + 1.0);
	} else {
		tmp = (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) + (x / (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(y * z) - x)
	t_2 = Float64(Float64(z * t) - x)
	t_3 = Float64(Float64(x + Float64(t_1 / t_2)) / Float64(x + 1.0))
	tmp = 0.0
	if (t_3 <= -5e+22)
		tmp = Float64(Float64(x + Float64(y / Float64(t_2 / z))) / Float64(x + 1.0));
	elseif (t_3 <= 2e+284)
		tmp = Float64(Float64(x + Float64(t_1 / fma(z, t, Float64(-x)))) / Float64(x + 1.0));
	else
		tmp = Float64(Float64(Float64(Float64(y / Float64(x + 1.0)) - Float64(x / Float64(z * Float64(x + 1.0)))) / t) + Float64(x / Float64(x + 1.0)));
	end
	return 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[(y * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -5e+22], 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+284], N[(N[(x + N[(t$95$1 / N[(z * t + (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(z * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := y \cdot z - x\\
t_2 := z \cdot t - x\\
t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{+22}:\\
\;\;\;\;\frac{x + \frac{y}{\frac{t_2}{z}}}{x + 1}\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+284}:\\
\;\;\;\;\frac{x + \frac{t_1}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{x + 1}\\


\end{array}

Error?

Target

Original88.4%
Target99.5%
Herbie97.6%
\[\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)) < -4.9999999999999996e22

    1. Initial program 69.6%

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

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

      [Start]69.6

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

      *-commutative [=>]69.6

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

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

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

      [Start]69.6

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

      associate-/l* [=>]97.9

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

    if -4.9999999999999996e22 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2.00000000000000016e284

    1. Initial program 98.9%

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

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

      [Start]98.9

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

      *-commutative [=>]98.9

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

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

      [Start]98.9

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

      fma-neg [=>]98.9

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

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

    1. Initial program 3.7%

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

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

      [Start]3.7

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

      *-commutative [=>]3.7

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{y}{1 + x} - -1 \cdot \frac{x}{\left(1 + x\right) \cdot z}}{t} + \frac{x}{1 + x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification97.6%

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

Alternatives

Alternative 1
Accuracy97.6%
Cost3784
\[\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 -5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(z \cdot t\right) \cdot \left(x + 1\right)}\\ \end{array} \]
Alternative 2
Accuracy97.6%
Cost3656
\[\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 -5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{x + 1}\\ \end{array} \]
Alternative 3
Accuracy97.5%
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 -5 \cdot 10^{+22}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 4
Accuracy85.2%
Cost1484
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{\frac{z \cdot t - x}{z}}}{x + 1}\\ \mathbf{if}\;t \leq -2.1 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{-239}:\\ \;\;\;\;\frac{\left(x - y \cdot \frac{z}{x}\right) + 1}{x + 1}\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x + 1} \cdot \left(\frac{y}{t} + \left(x - \frac{x}{z \cdot t}\right)\right)\\ \end{array} \]
Alternative 5
Accuracy85.2%
Cost1356
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{\frac{z \cdot t - x}{z}}}{x + 1}\\ \mathbf{if}\;t \leq -4.6 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-239}:\\ \;\;\;\;\frac{\left(x - y \cdot \frac{z}{x}\right) + 1}{x + 1}\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + \frac{y}{t}\right) - \frac{x}{z \cdot t}}{x + 1}\\ \end{array} \]
Alternative 6
Accuracy87.3%
Cost1225
\[\begin{array}{l} t_1 := z \cdot t - x\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{-203} \lor \neg \left(z \leq 3.1 \cdot 10^{-209}\right):\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1}\\ \end{array} \]
Alternative 7
Accuracy75.4%
Cost1105
\[\begin{array}{l} \mathbf{if}\;x \leq -9.6 \cdot 10^{-35}:\\ \;\;\;\;1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{-130} \lor \neg \left(x \leq 2.65 \cdot 10^{-76}\right) \land x \leq 22700000000000:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Accuracy68.8%
Cost1104
\[\begin{array}{l} t_1 := y \cdot \frac{z}{z \cdot t - x}\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{-69}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-75}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 9
Accuracy69.0%
Cost1104
\[\begin{array}{l} t_1 := y \cdot \frac{z}{z \cdot t - x}\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-6}:\\ \;\;\;\;1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{-76}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 10
Accuracy82.2%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq -1.08 \cdot 10^{-67} \lor \neg \left(t \leq 1.6 \cdot 10^{-107}\right):\\ \;\;\;\;\frac{x}{x + 1} + \frac{\frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y \cdot z}{x + x \cdot x}\\ \end{array} \]
Alternative 11
Accuracy83.7%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq -4.2 \cdot 10^{-67} \lor \neg \left(t \leq 1.7 \cdot 10^{-107}\right):\\ \;\;\;\;\frac{x}{x + 1} + \frac{\frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y \cdot \frac{z}{x}\right) + 1}{x + 1}\\ \end{array} \]
Alternative 12
Accuracy82.1%
Cost969
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1 \cdot 10^{-68} \lor \neg \left(t \leq 8 \cdot 10^{-109}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y \cdot z}{x + x \cdot x}\\ \end{array} \]
Alternative 13
Accuracy67.5%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-70}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-130}:\\ \;\;\;\;\frac{\frac{y}{x + 1}}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 14
Accuracy67.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -8.8 \cdot 10^{-73}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.36 \cdot 10^{-130}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 15
Accuracy57.2%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-174}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-147}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 16
Accuracy55.7%
Cost64
\[1 \]

Error

Reproduce?

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