Average Error: 16.1 → 8.4
Time: 18.5s
Precision: binary64
Cost: 2244
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
\[\begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq 5 \cdot 10^{+306}:\\ \;\;\;\;\frac{x + z \cdot \frac{y}{t}}{1 + \left(a + b \cdot \frac{y}{t}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))) 5e+306)
   (/ (+ x (* z (/ y t))) (+ 1.0 (+ a (* b (/ y t)))))
   (/ z b)))
double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))) <= 5e+306) {
		tmp = (x + (z * (y / t))) / (1.0 + (a + (b * (y / t))));
	} else {
		tmp = z / b;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = (x + ((y * z) / t)) / ((a + 1.0d0) + ((y * b) / t))
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (((x + ((y * z) / t)) / ((a + 1.0d0) + ((y * b) / t))) <= 5d+306) then
        tmp = (x + (z * (y / t))) / (1.0d0 + (a + (b * (y / t))))
    else
        tmp = z / b
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))) <= 5e+306) {
		tmp = (x + (z * (y / t))) / (1.0 + (a + (b * (y / t))));
	} else {
		tmp = z / b;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))) <= 5e+306:
		tmp = (x + (z * (y / t))) / (1.0 + (a + (b * (y / t))))
	else:
		tmp = z / b
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t)))
end
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) <= 5e+306)
		tmp = Float64(Float64(x + Float64(z * Float64(y / t))) / Float64(1.0 + Float64(a + Float64(b * Float64(y / t)))));
	else
		tmp = Float64(z / b);
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (((x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))) <= 5e+306)
		tmp = (x + (z * (y / t))) / (1.0 + (a + (b * (y / t))));
	else
		tmp = z / b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+306], N[(N[(x + N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(a + N[(b * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{x + z \cdot \frac{y}{t}}{1 + \left(a + b \cdot \frac{y}{t}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.1
Target13.0
Herbie8.4
\[\begin{array}{l} \mathbf{if}\;t < -1.3659085366310088 \cdot 10^{-271}:\\ \;\;\;\;1 \cdot \left(\left(x + \frac{y}{t} \cdot z\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y}{t} \cdot b}\right)\\ \mathbf{elif}\;t < 3.036967103737246 \cdot 10^{-130}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\left(x + \frac{y}{t} \cdot z\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y}{t} \cdot b}\right)\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < 4.99999999999999993e306

    1. Initial program 8.2

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Simplified7.9

      \[\leadsto \color{blue}{\frac{x + \frac{y}{t} \cdot z}{1 + \left(a + \frac{y}{t} \cdot b\right)}} \]
      Proof
      (/.f64 (+.f64 x (*.f64 (/.f64 y t) z)) (+.f64 1 (+.f64 a (*.f64 (/.f64 y t) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y z) t))) (+.f64 1 (+.f64 a (*.f64 (/.f64 y t) b)))): 17 points increase in error, 19 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 1 (+.f64 a (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y b) t))))): 9 points increase in error, 7 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 1 a) (/.f64 (*.f64 y b) t)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 a 1)) (/.f64 (*.f64 y b) t))): 0 points increase in error, 0 points decrease in error

    if 4.99999999999999993e306 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t)))

    1. Initial program 63.8

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Simplified53.2

      \[\leadsto \color{blue}{\frac{x + \frac{y}{t} \cdot z}{1 + \left(a + \frac{y}{t} \cdot b\right)}} \]
      Proof
      (/.f64 (+.f64 x (*.f64 (/.f64 y t) z)) (+.f64 1 (+.f64 a (*.f64 (/.f64 y t) b)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y z) t))) (+.f64 1 (+.f64 a (*.f64 (/.f64 y t) b)))): 17 points increase in error, 19 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 1 (+.f64 a (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y b) t))))): 9 points increase in error, 7 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 1 a) (/.f64 (*.f64 y b) t)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 a 1)) (/.f64 (*.f64 y b) t))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 11.3

      \[\leadsto \color{blue}{\frac{z}{b}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq 5 \cdot 10^{+306}:\\ \;\;\;\;\frac{x + z \cdot \frac{y}{t}}{1 + \left(a + b \cdot \frac{y}{t}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]

Alternatives

Alternative 1
Error25.9
Cost1364
\[\begin{array}{l} t_1 := \frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ t_2 := \frac{x + z \cdot \frac{y}{t}}{a + 1}\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+135}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -27000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-15}:\\ \;\;\;\;\frac{x}{\left(a + 1\right) + \frac{y}{\frac{t}{b}}}\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+171}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error26.0
Cost1364
\[\begin{array}{l} t_1 := \frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ t_2 := \frac{x + z \cdot \frac{y}{t}}{a + 1}\\ \mathbf{if}\;z \leq -9.6 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -27000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-116}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{a + 1}\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-12}:\\ \;\;\;\;\frac{x}{\left(a + 1\right) + \frac{y}{\frac{t}{b}}}\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{+170}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error25.9
Cost1364
\[\begin{array}{l} t_1 := \frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ t_2 := \frac{x + z \cdot \frac{y}{t}}{a + 1}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -24000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-121}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{a + 1}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-14}:\\ \;\;\;\;\frac{x}{\left(a + 1\right) + \frac{y}{\frac{t}{b}}}\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+172}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error29.0
Cost1236
\[\begin{array}{l} t_1 := \frac{x}{1 + b \cdot \frac{y}{t}}\\ t_2 := \frac{x + \frac{y}{\frac{t}{z}}}{a}\\ \mathbf{if}\;a \leq -3.9:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.6 \cdot 10^{-208}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3 \cdot 10^{-236}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;a \leq 1850:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{+217}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3 \cdot 10^{+267}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 5
Error29.0
Cost1236
\[\begin{array}{l} t_1 := \frac{x}{1 + b \cdot \frac{y}{t}}\\ \mathbf{if}\;a \leq -1.2:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{a}\\ \mathbf{elif}\;a \leq -1.6 \cdot 10^{-208}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.2 \cdot 10^{-238}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;a \leq 580000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{+217}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{a}\\ \mathbf{elif}\;a \leq 3 \cdot 10^{+267}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 6
Error29.1
Cost1236
\[\begin{array}{l} t_1 := \frac{x}{1 + b \cdot \frac{y}{t}}\\ \mathbf{if}\;a \leq -3.8:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{a}\\ \mathbf{elif}\;a \leq -2.45 \cdot 10^{-206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.8 \cdot 10^{-303}:\\ \;\;\;\;\frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ \mathbf{elif}\;a \leq 6000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{+217}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{a}\\ \mathbf{elif}\;a \leq 3 \cdot 10^{+267}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 7
Error22.5
Cost968
\[\begin{array}{l} t_1 := \frac{x}{\left(a + 1\right) + y \cdot \frac{b}{t}}\\ \mathbf{if}\;t \leq -6.8 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{-123}:\\ \;\;\;\;\frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.4
Cost968
\[\begin{array}{l} t_1 := \frac{x}{\left(a + 1\right) + \frac{y}{\frac{t}{b}}}\\ \mathbf{if}\;t \leq -1.05 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-124}:\\ \;\;\;\;\frac{z}{b} + \frac{x \cdot t}{y \cdot b}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error38.9
Cost720
\[\begin{array}{l} \mathbf{if}\;a \leq -3.9:\\ \;\;\;\;\frac{x}{a}\\ \mathbf{elif}\;a \leq 3300000:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;a \leq 2.8 \cdot 10^{+115}:\\ \;\;\;\;\frac{x}{a}\\ \mathbf{elif}\;a \leq 3 \cdot 10^{+267}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 10
Error28.7
Cost584
\[\begin{array}{l} t_1 := \frac{x}{a + 1}\\ \mathbf{if}\;t \leq -3.3 \cdot 10^{-155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-124}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error47.8
Cost192
\[\frac{x}{a} \]

Error

Reproduce

herbie shell --seed 2022329 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< t -1.3659085366310088e-271) (* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b))))) (if (< t 3.036967103737246e-130) (/ z b) (* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b)))))))

  (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))