Average Error: 7.0 → 2.5
Time: 18.0s
Precision: binary64
Cost: 3656
\[\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}\\ t_3 := \frac{y}{x + 1}\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+240}:\\ \;\;\;\;\frac{z}{t_1} \cdot t_3\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+187}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{t_3 - \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 (- (* z t) x))
        (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0)))
        (t_3 (/ y (+ x 1.0))))
   (if (<= t_2 -1e+240)
     (* (/ z t_1) t_3)
     (if (<= t_2 4e+187)
       t_2
       (+ (/ (- t_3 (/ 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 = (z * t) - x;
	double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
	double t_3 = y / (x + 1.0);
	double tmp;
	if (t_2 <= -1e+240) {
		tmp = (z / t_1) * t_3;
	} else if (t_2 <= 4e+187) {
		tmp = t_2;
	} else {
		tmp = ((t_3 - (x / (z * (x + 1.0)))) / t) + (x / (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) :: t_3
    real(8) :: tmp
    t_1 = (z * t) - x
    t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0d0)
    t_3 = y / (x + 1.0d0)
    if (t_2 <= (-1d+240)) then
        tmp = (z / t_1) * t_3
    else if (t_2 <= 4d+187) then
        tmp = t_2
    else
        tmp = ((t_3 - (x / (z * (x + 1.0d0)))) / t) + (x / (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 t_3 = y / (x + 1.0);
	double tmp;
	if (t_2 <= -1e+240) {
		tmp = (z / t_1) * t_3;
	} else if (t_2 <= 4e+187) {
		tmp = t_2;
	} else {
		tmp = ((t_3 - (x / (z * (x + 1.0)))) / t) + (x / (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)
	t_3 = y / (x + 1.0)
	tmp = 0
	if t_2 <= -1e+240:
		tmp = (z / t_1) * t_3
	elif t_2 <= 4e+187:
		tmp = t_2
	else:
		tmp = ((t_3 - (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(z * t) - x)
	t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0))
	t_3 = Float64(y / Float64(x + 1.0))
	tmp = 0.0
	if (t_2 <= -1e+240)
		tmp = Float64(Float64(z / t_1) * t_3);
	elseif (t_2 <= 4e+187)
		tmp = t_2;
	else
		tmp = Float64(Float64(Float64(t_3 - Float64(x / Float64(z * Float64(x + 1.0)))) / t) + Float64(x / 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);
	t_3 = y / (x + 1.0);
	tmp = 0.0;
	if (t_2 <= -1e+240)
		tmp = (z / t_1) * t_3;
	elseif (t_2 <= 4e+187)
		tmp = t_2;
	else
		tmp = ((t_3 - (x / (z * (x + 1.0)))) / t) + (x / (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]}, Block[{t$95$3 = N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -1e+240], N[(N[(z / t$95$1), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$2, 4e+187], t$95$2, N[(N[(N[(t$95$3 - 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 := z \cdot t - x\\
t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\
t_3 := \frac{y}{x + 1}\\
\mathbf{if}\;t_2 \leq -1 \cdot 10^{+240}:\\
\;\;\;\;\frac{z}{t_1} \cdot t_3\\

\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+187}:\\
\;\;\;\;t_2\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.0
Target0.3
Herbie2.5
\[\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)) < -1.00000000000000001e240

    1. Initial program 49.4

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

      \[\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 49.4

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

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

    if -1.00000000000000001e240 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 3.99999999999999963e187

    1. Initial program 0.8

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

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

    1. Initial program 50.6

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

      \[\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 t around inf 14.4

      \[\leadsto \frac{\color{blue}{\left(\frac{y}{t} + x\right) - \frac{x}{t \cdot z}}}{x + 1} \]
    4. Taylor expanded in t around -inf 14.1

      \[\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 simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -1 \cdot 10^{+240}:\\ \;\;\;\;\frac{z}{z \cdot t - x} \cdot \frac{y}{x + 1}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 4 \cdot 10^{+187}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{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
Error2.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 -1 \cdot 10^{+240}:\\ \;\;\;\;\frac{z}{t_1} \cdot \frac{y}{x + 1}\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+187}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 2
Error15.1
Cost1228
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -3.125768700774244 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.5 \cdot 10^{-239}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-249}:\\ \;\;\;\;\frac{y}{\left(x + 1\right) \cdot \frac{z \cdot t - x}{z}}\\ \mathbf{elif}\;t \leq 10^{-195}:\\ \;\;\;\;1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.5
Cost1104
\[\begin{array}{l} t_1 := 1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{if}\;x \leq -7.181771994407216 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.909165882012061 \cdot 10^{-122}:\\ \;\;\;\;y \cdot \frac{z}{z \cdot t - x}\\ \mathbf{elif}\;x \leq 6.656590266034041 \cdot 10^{-59}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 9.01321174371179 \cdot 10^{-45}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error12.8
Cost1096
\[\begin{array}{l} t_1 := 1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{if}\;x \leq -0.6844668606022151:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.01321174371179 \cdot 10^{-45}:\\ \;\;\;\;\frac{x + \frac{y - \frac{x}{z}}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error19.4
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -7.181771994407216 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.909165882012061 \cdot 10^{-122}:\\ \;\;\;\;y \cdot \frac{z}{z \cdot t - x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 6
Error14.7
Cost840
\[\begin{array}{l} t_1 := 1 - \frac{z}{x} \cdot \frac{y}{x}\\ \mathbf{if}\;x \leq -3.5713669600360386 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.01321174371179 \cdot 10^{-45}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error20.6
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -7.181771994407216 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.909165882012061 \cdot 10^{-122}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 6.656590266034041 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.01321174371179 \cdot 10^{-45}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error20.5
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -7.181771994407216 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.909165882012061 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 9
Error20.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -7.181771994407216 \cdot 10^{-9}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.909165882012061 \cdot 10^{-122}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 10
Error26.6
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3037970553935023 \cdot 10^{-92}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.01321174371179 \cdot 10^{-45}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error54.9
Cost64
\[x \]

Error

Reproduce

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