?

Average Error: 16.9 → 8.2
Time: 13.4s
Precision: binary64
Cost: 2756

?

\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
\[\begin{array}{l} t_1 := \frac{y \cdot b}{t}\\ \mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_1} \leq 10^{+286}:\\ \;\;\;\;\frac{y \cdot z}{y \cdot b + \left(t + t \cdot a\right)} + \frac{x}{1 + \left(t_1 + a\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
 (let* ((t_1 (/ (* y b) t)))
   (if (<= (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) t_1)) 1e+286)
     (+ (/ (* y z) (+ (* y b) (+ t (* t a)))) (/ x (+ 1.0 (+ t_1 a))))
     (/ 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 t_1 = (y * b) / t;
	double tmp;
	if (((x + ((y * z) / t)) / ((a + 1.0) + t_1)) <= 1e+286) {
		tmp = ((y * z) / ((y * b) + (t + (t * a)))) + (x / (1.0 + (t_1 + a)));
	} 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) :: t_1
    real(8) :: tmp
    t_1 = (y * b) / t
    if (((x + ((y * z) / t)) / ((a + 1.0d0) + t_1)) <= 1d+286) then
        tmp = ((y * z) / ((y * b) + (t + (t * a)))) + (x / (1.0d0 + (t_1 + a)))
    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 t_1 = (y * b) / t;
	double tmp;
	if (((x + ((y * z) / t)) / ((a + 1.0) + t_1)) <= 1e+286) {
		tmp = ((y * z) / ((y * b) + (t + (t * a)))) + (x / (1.0 + (t_1 + a)));
	} 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):
	t_1 = (y * b) / t
	tmp = 0
	if ((x + ((y * z) / t)) / ((a + 1.0) + t_1)) <= 1e+286:
		tmp = ((y * z) / ((y * b) + (t + (t * a)))) + (x / (1.0 + (t_1 + a)))
	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)
	t_1 = Float64(Float64(y * b) / t)
	tmp = 0.0
	if (Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + t_1)) <= 1e+286)
		tmp = Float64(Float64(Float64(y * z) / Float64(Float64(y * b) + Float64(t + Float64(t * a)))) + Float64(x / Float64(1.0 + Float64(t_1 + a))));
	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)
	t_1 = (y * b) / t;
	tmp = 0.0;
	if (((x + ((y * z) / t)) / ((a + 1.0) + t_1)) <= 1e+286)
		tmp = ((y * z) / ((y * b) + (t + (t * a)))) + (x / (1.0 + (t_1 + a)));
	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_] := Block[{t$95$1 = N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision], 1e+286], N[(N[(N[(y * z), $MachinePrecision] / N[(N[(y * b), $MachinePrecision] + N[(t + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(1.0 + N[(t$95$1 + a), $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}
t_1 := \frac{y \cdot b}{t}\\
\mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_1} \leq 10^{+286}:\\
\;\;\;\;\frac{y \cdot z}{y \cdot b + \left(t + t \cdot a\right)} + \frac{x}{1 + \left(t_1 + a\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.9
Target13.1
Herbie8.2
\[\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))) < 1.00000000000000003e286

    1. Initial program 9.2

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in x around 0 8.9

      \[\leadsto \color{blue}{\frac{y \cdot z}{t \cdot \left(1 + \left(\frac{y \cdot b}{t} + a\right)\right)} + \frac{x}{1 + \left(\frac{y \cdot b}{t} + a\right)}} \]
    3. Taylor expanded in t around 0 7.4

      \[\leadsto \frac{y \cdot z}{\color{blue}{y \cdot b + t \cdot \left(1 + a\right)}} + \frac{x}{1 + \left(\frac{y \cdot b}{t} + a\right)} \]
    4. Simplified7.4

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

      [Start]7.4

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

      rational_best_oopsla_all_46_json_45_simplify-37 [=>]7.4

      \[ \frac{y \cdot z}{y \cdot b + \color{blue}{\left(1 \cdot t + t \cdot a\right)}} + \frac{x}{1 + \left(\frac{y \cdot b}{t} + a\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]7.4

      \[ \frac{y \cdot z}{y \cdot b + \left(\color{blue}{t \cdot 1} + t \cdot a\right)} + \frac{x}{1 + \left(\frac{y \cdot b}{t} + a\right)} \]

      rational_best_oopsla_all_46_json_45_simplify-52 [=>]7.4

      \[ \frac{y \cdot z}{y \cdot b + \left(\color{blue}{t} + t \cdot a\right)} + \frac{x}{1 + \left(\frac{y \cdot b}{t} + a\right)} \]

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

    1. Initial program 61.2

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around inf 13.0

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

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

Alternatives

Alternative 1
Error9.8
Cost2244
\[\begin{array}{l} t_1 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{if}\;t_1 \leq 10^{+286}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
Alternative 2
Error25.1
Cost1232
\[\begin{array}{l} t_1 := \frac{x}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{if}\;y \leq -3.15 \cdot 10^{+140}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 24000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+21}:\\ \;\;\;\;\frac{y \cdot z}{y \cdot b + t}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
Alternative 3
Error25.1
Cost1232
\[\begin{array}{l} t_1 := \frac{x}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{if}\;y \leq -1.68 \cdot 10^{+140}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 0.0024:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+21}:\\ \;\;\;\;\frac{y \cdot z}{y \cdot b + t \cdot a}\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
Alternative 4
Error25.2
Cost1100
\[\begin{array}{l} \mathbf{if}\;b \leq -1.25 \cdot 10^{+148}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{+72}:\\ \;\;\;\;\frac{\frac{y \cdot z}{t} + x}{1 + a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{+155}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \end{array} \]
Alternative 5
Error29.1
Cost972
\[\begin{array}{l} t_1 := \frac{x}{a - -1}\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{+78}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+21}:\\ \;\;\;\;\frac{y \cdot z}{y \cdot b + t}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
Alternative 6
Error29.9
Cost972
\[\begin{array}{l} t_1 := \frac{y \cdot z}{t} + x\\ t_2 := \frac{t_1}{a}\\ \mathbf{if}\;a \leq -1:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 8.6 \cdot 10^{-106}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 380:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error29.0
Cost848
\[\begin{array}{l} t_1 := \frac{x}{a - -1}\\ \mathbf{if}\;y \leq -5 \cdot 10^{+78}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+22}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
Alternative 8
Error37.2
Cost720
\[\begin{array}{l} \mathbf{if}\;a \leq -4.2 \cdot 10^{+71}:\\ \;\;\;\;\frac{x}{a}\\ \mathbf{elif}\;a \leq -3.55 \cdot 10^{-147}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{elif}\;a \leq 6.5 \cdot 10^{-156}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 6.4 \cdot 10^{+46}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 9
Error37.1
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -1:\\ \;\;\;\;\frac{x}{a}\\ \mathbf{elif}\;a \leq 1400:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{a}\\ \end{array} \]
Alternative 10
Error51.1
Cost64
\[x \]

Error

Reproduce?

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