?

Average Error: 7.3 → 0.9
Time: 13.9s
Precision: binary64
Cost: 4813

?

\[\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 -5000:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{-16} \lor \neg \left(t_2 \leq 10^{+303}\right):\\ \;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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 -5000.0)
     (/ (+ x (/ y (/ t_1 z))) (+ x 1.0))
     (if (or (<= t_2 4e-16) (not (<= t_2 1e+303)))
       (+ (/ (- (/ y (+ x 1.0)) (/ x (* z (+ x 1.0)))) t) (/ x (+ x 1.0)))
       t_2))))
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 <= -5000.0) {
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	} else if ((t_2 <= 4e-16) || !(t_2 <= 1e+303)) {
		tmp = (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) + (x / (x + 1.0));
	} else {
		tmp = t_2;
	}
	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 <= (-5000.0d0)) then
        tmp = (x + (y / (t_1 / z))) / (x + 1.0d0)
    else if ((t_2 <= 4d-16) .or. (.not. (t_2 <= 1d+303))) then
        tmp = (((y / (x + 1.0d0)) - (x / (z * (x + 1.0d0)))) / t) + (x / (x + 1.0d0))
    else
        tmp = t_2
    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 <= -5000.0) {
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	} else if ((t_2 <= 4e-16) || !(t_2 <= 1e+303)) {
		tmp = (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) + (x / (x + 1.0));
	} else {
		tmp = t_2;
	}
	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 <= -5000.0:
		tmp = (x + (y / (t_1 / z))) / (x + 1.0)
	elif (t_2 <= 4e-16) or not (t_2 <= 1e+303):
		tmp = (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) + (x / (x + 1.0))
	else:
		tmp = t_2
	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 <= -5000.0)
		tmp = Float64(Float64(x + Float64(y / Float64(t_1 / z))) / Float64(x + 1.0));
	elseif ((t_2 <= 4e-16) || !(t_2 <= 1e+303))
		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)));
	else
		tmp = t_2;
	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 <= -5000.0)
		tmp = (x + (y / (t_1 / z))) / (x + 1.0);
	elseif ((t_2 <= 4e-16) || ~((t_2 <= 1e+303)))
		tmp = (((y / (x + 1.0)) - (x / (z * (x + 1.0)))) / t) + (x / (x + 1.0));
	else
		tmp = t_2;
	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, -5000.0], N[(N[(x + N[(y / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$2, 4e-16], N[Not[LessEqual[t$95$2, 1e+303]], $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], t$95$2]]]]
\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 -5000:\\
\;\;\;\;\frac{x + \frac{y}{\frac{t_1}{z}}}{x + 1}\\

\mathbf{elif}\;t_2 \leq 4 \cdot 10^{-16} \lor \neg \left(t_2 \leq 10^{+303}\right):\\
\;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.3
Target0.3
Herbie0.9
\[\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)) < -5e3

    1. Initial program 16.9

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

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

      [Start]16.9

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

      *-commutative [=>]16.9

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

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

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

      [Start]17.3

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

      associate-/l* [=>]1.8

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

    if -5e3 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 3.9999999999999999e-16 or 1e303 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 19.0

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

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

      [Start]19.0

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

      *-commutative [=>]19.0

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

      \[\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}} \]

    if 3.9999999999999999e-16 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1e303

    1. Initial program 0.1

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -5000:\\ \;\;\;\;\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 4 \cdot 10^{-16} \lor \neg \left(\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 10^{+303}\right):\\ \;\;\;\;\frac{\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}}{t} + \frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \end{array} \]

Alternatives

Alternative 1
Error1.2
Cost4556
\[\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 -5000:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t_2}{z}}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 4 \cdot 10^{-282}:\\ \;\;\;\;\frac{x + \frac{1}{\frac{t}{\frac{t_1}{z}}}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 10^{+303}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 2
Error8.4
Cost1356
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{\frac{z \cdot t - x}{z}}}{x + 1}\\ \mathbf{if}\;z \leq -2.4 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-213}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+142}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 3
Error13.1
Cost1164
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -1 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-166}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+39}:\\ \;\;\;\;\frac{x + \frac{y}{-\frac{x}{z}}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error13.1
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{-51} \lor \neg \left(z \leq 1.4 \cdot 10^{+35}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \end{array} \]
Alternative 5
Error14.1
Cost1033
\[\begin{array}{l} \mathbf{if}\;t \leq -6.6 \cdot 10^{-80} \lor \neg \left(t \leq 2.3 \cdot 10^{-74}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{-\frac{x}{z}}}{x + 1}\\ \end{array} \]
Alternative 6
Error14.2
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -2000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 216000:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error14.3
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -10000000000:\\ \;\;\;\;1 - \frac{y}{x \cdot \frac{x}{z}}\\ \mathbf{elif}\;x \leq 2500000:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error21.0
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.18 \cdot 10^{-17}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-50}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.42 \cdot 10^{-75}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-107}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error20.3
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{-68} \lor \neg \left(x \leq 1.95 \cdot 10^{-107}\right):\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t}\\ \end{array} \]
Alternative 10
Error27.0
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-13}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error28.6
Cost64
\[1 \]

Error

Reproduce?

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