?

Average Error: 7.3 → 1.9
Time: 1.9min
Precision: binary64
Cost: 4556

?

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

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\left(-\frac{\left(-y\right) + \frac{x}{z}}{t}\right) + x}{x + 1}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+300}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.3
Target0.4
Herbie1.9
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation?

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

    1. Initial program 17.6

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Taylor expanded in y around inf 17.6

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

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

    if -1e27 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2e-8

    1. Initial program 2.8

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Applied egg-rr2.7

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

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

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

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

    if 2e-8 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2.0000000000000001e300

    1. Initial program 0.1

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

    if 2.0000000000000001e300 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 63.4

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Taylor expanded in z around inf 10.1

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

Alternatives

Alternative 1
Error2.6
Cost10056
\[\begin{array}{l} t_1 := t \cdot z - x\\ t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+27}:\\ \;\;\;\;\frac{z}{z \cdot t - x} \cdot \frac{y}{x + 1}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\left(-\frac{\left(-y\right) + \frac{x}{z}}{t}\right) + x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t_1}, x + \frac{x}{x - t \cdot z}\right)}{x + 1}\\ \end{array} \]
Alternative 2
Error15.8
Cost1492
\[\begin{array}{l} t_1 := 1 + z \cdot \frac{t - y}{x}\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ t_3 := \frac{z}{z \cdot t - x} \cdot \frac{y}{x + 1}\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{-74}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.4 \cdot 10^{-307}:\\ \;\;\;\;1 + \frac{\left(t - y\right) \cdot z}{x}\\ \mathbf{elif}\;t \leq 2.15 \cdot 10^{-265}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{-177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-145}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 13.5:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error15.8
Cost1492
\[\begin{array}{l} t_1 := 1 + z \cdot \frac{t - y}{x}\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ t_3 := z \cdot t - x\\ \mathbf{if}\;t \leq -2 \cdot 10^{-74}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{-306}:\\ \;\;\;\;1 + \frac{\left(t - y\right) \cdot z}{x}\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-265}:\\ \;\;\;\;\frac{z}{t_3} \cdot \frac{y}{x + 1}\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{-177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-145}:\\ \;\;\;\;\frac{\frac{y}{t_3}}{x + 1} \cdot z\\ \mathbf{elif}\;t \leq 13.5:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error12.7
Cost1360
\[\begin{array}{l} t_1 := \frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;z \leq -6:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-148}:\\ \;\;\;\;1 + \frac{\left(t - y\right) \cdot z}{x}\\ \mathbf{elif}\;z \leq 4.45 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error14.5
Cost1232
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;z \leq -1.5 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-119}:\\ \;\;\;\;1 + \frac{\left(t - y\right) \cdot z}{x}\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-34}:\\ \;\;\;\;\frac{t \cdot z}{\left(1 + x\right) \cdot x} + 1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error14.5
Cost1104
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-120}:\\ \;\;\;\;1 + \frac{\left(t - y\right) \cdot z}{x}\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-34}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error13.8
Cost1096
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;z \leq -3.9 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\left(x - \frac{y \cdot z}{x}\right) - -1}{x - -1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error18.5
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-34}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-67}:\\ \;\;\;\;\frac{z}{z \cdot t - x} \cdot y\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error21.0
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-37}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-189}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error27.1
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-184}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-115}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error28.2
Cost64
\[1 \]

Error

Reproduce?

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