?

Average Accuracy: 88.3% → 97.0%
Time: 14.1s
Precision: binary64
Cost: 3400

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\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 -40000:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+226}:\\ \;\;\;\;t_2\\ \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)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
   (if (<= t_2 -40000.0)
     (/ (+ x (/ y (/ t_1 z))) (+ x 1.0))
     (if (<= t_2 2e+226) t_2 (/ (+ 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 t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
	double tmp;
	if (t_2 <= -40000.0) {
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	} else if (t_2 <= 2e+226) {
		tmp = t_2;
	} else {
		tmp = (x + (y / t)) / (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) :: tmp
    t_1 = (z * t) - x
    t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
    if (t_2 <= (-40000.0d0)) then
        tmp = (x + (y / (t_1 / z))) / (x + 1.0d0)
    else if (t_2 <= 2d+226) then
        tmp = t_2
    else
        tmp = (x + (y / t)) / (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 = (z * t) - x;
	double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
	double tmp;
	if (t_2 <= -40000.0) {
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	} else if (t_2 <= 2e+226) {
		tmp = t_2;
	} 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
	t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0)
	tmp = 0
	if t_2 <= -40000.0:
		tmp = (x + (y / (t_1 / z))) / (x + 1.0)
	elif t_2 <= 2e+226:
		tmp = t_2
	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)
	t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0))
	tmp = 0.0
	if (t_2 <= -40000.0)
		tmp = Float64(Float64(x + Float64(y / Float64(t_1 / z))) / Float64(x + 1.0));
	elseif (t_2 <= 2e+226)
		tmp = t_2;
	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;
	t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
	tmp = 0.0;
	if (t_2 <= -40000.0)
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	elseif (t_2 <= 2e+226)
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -40000.0], N[(N[(x + N[(y / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+226], t$95$2, 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\\
t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\
\mathbf{if}\;t_2 \leq -40000:\\
\;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+226}:\\
\;\;\;\;t_2\\

\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

Original88.3%
Target99.5%
Herbie97.0%
\[\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)) < -4e4

    1. Initial program 73.1%

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

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

      [Start]73.1

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

      *-commutative [=>]73.1

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

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

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

      [Start]72.8

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

      associate-/l* [=>]98.3

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

    if -4e4 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.99999999999999992e226

    1. Initial program 98.9%

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

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

    1. Initial program 13.9%

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

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

      [Start]13.9

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

      *-commutative [=>]13.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -40000:\\ \;\;\;\;\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^{+226}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy76.0%
Cost2020
\[\begin{array}{l} t_1 := y \cdot z + \left(1 - y \cdot \frac{z}{x}\right)\\ t_2 := z \cdot t - x\\ t_3 := \frac{x - \frac{x}{t_2}}{x + 1}\\ t_4 := \frac{x + \frac{y}{t}}{x + 1}\\ t_5 := \frac{z}{x + 1} \cdot \frac{y}{t_2}\\ \mathbf{if}\;t \leq -8.5 \cdot 10^{-44}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -1.4 \cdot 10^{-110}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.8 \cdot 10^{-131}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq -3.8 \cdot 10^{-280}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-307}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-298}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-231}:\\ \;\;\;\;\frac{x - z \cdot \frac{y}{x}}{x + 1}\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{-106}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 2
Accuracy85.5%
Cost1356
\[\begin{array}{l} t_1 := \frac{x + y \cdot \frac{z}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;t \leq -2 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{-205}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+34}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 3
Accuracy85.6%
Cost1356
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{\frac{z \cdot t - x}{z}}}{x + 1}\\ \mathbf{if}\;t \leq -3.2 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.3 \cdot 10^{-202}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 4
Accuracy81.6%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq -2.25 \cdot 10^{-73} \lor \neg \left(t \leq 6.1 \cdot 10^{-106}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \end{array} \]
Alternative 5
Accuracy81.6%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq -2.85 \cdot 10^{-73} \lor \neg \left(t \leq 2.3 \cdot 10^{-106}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + \left(x - \frac{y \cdot z}{x}\right)}{x + 1}\\ \end{array} \]
Alternative 6
Accuracy75.3%
Cost969
\[\begin{array}{l} \mathbf{if}\;t \leq -8.5 \cdot 10^{-146} \lor \neg \left(t \leq 1.3 \cdot 10^{-109}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;y \cdot z + \left(1 - y \cdot \frac{z}{x}\right)\\ \end{array} \]
Alternative 7
Accuracy67.6%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-53}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-156}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-57}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-20}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 8
Accuracy75.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -8.2 \cdot 10^{-47} \lor \neg \left(z \leq 3.1 \cdot 10^{-133}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Accuracy67.2%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -9.6 \cdot 10^{-53}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-157}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 10
Accuracy67.6%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-53}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-60}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Accuracy55.4%
Cost64
\[1 \]

Error

Reproduce?

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