| Alternative 1 | |
|---|---|
| Error | 51.2 |
| Cost | 64 |
\[x
\]
(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 (+ (+ a 1.0) (/ (* y b) t))) (t_2 (/ (+ x (/ (* y z) t)) t_1)))
(if (<= t_2 (- INFINITY))
(* z (/ y (+ t (* t (+ a (/ y (/ t b)))))))
(if (<= t_2 -2e-321)
(/ (+ x (* (* y z) (/ 1.0 t))) t_1)
(if (<= t_2 0.0)
(* (/ t y) (/ (+ x (/ z (/ t y))) b))
(if (<= t_2 2e+293) t_2 (/ 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 = (a + 1.0) + ((y * b) / t);
double t_2 = (x + ((y * z) / t)) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = z * (y / (t + (t * (a + (y / (t / b))))));
} else if (t_2 <= -2e-321) {
tmp = (x + ((y * z) * (1.0 / t))) / t_1;
} else if (t_2 <= 0.0) {
tmp = (t / y) * ((x + (z / (t / y))) / b);
} else if (t_2 <= 2e+293) {
tmp = t_2;
} else {
tmp = z / b;
}
return tmp;
}
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 = (a + 1.0) + ((y * b) / t);
double t_2 = (x + ((y * z) / t)) / t_1;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = z * (y / (t + (t * (a + (y / (t / b))))));
} else if (t_2 <= -2e-321) {
tmp = (x + ((y * z) * (1.0 / t))) / t_1;
} else if (t_2 <= 0.0) {
tmp = (t / y) * ((x + (z / (t / y))) / b);
} else if (t_2 <= 2e+293) {
tmp = t_2;
} 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 = (a + 1.0) + ((y * b) / t) t_2 = (x + ((y * z) / t)) / t_1 tmp = 0 if t_2 <= -math.inf: tmp = z * (y / (t + (t * (a + (y / (t / b)))))) elif t_2 <= -2e-321: tmp = (x + ((y * z) * (1.0 / t))) / t_1 elif t_2 <= 0.0: tmp = (t / y) * ((x + (z / (t / y))) / b) elif t_2 <= 2e+293: tmp = t_2 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(a + 1.0) + Float64(Float64(y * b) / t)) t_2 = Float64(Float64(x + Float64(Float64(y * z) / t)) / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(z * Float64(y / Float64(t + Float64(t * Float64(a + Float64(y / Float64(t / b))))))); elseif (t_2 <= -2e-321) tmp = Float64(Float64(x + Float64(Float64(y * z) * Float64(1.0 / t))) / t_1); elseif (t_2 <= 0.0) tmp = Float64(Float64(t / y) * Float64(Float64(x + Float64(z / Float64(t / y))) / b)); elseif (t_2 <= 2e+293) tmp = t_2; 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 = (a + 1.0) + ((y * b) / t); t_2 = (x + ((y * z) / t)) / t_1; tmp = 0.0; if (t_2 <= -Inf) tmp = z * (y / (t + (t * (a + (y / (t / b)))))); elseif (t_2 <= -2e-321) tmp = (x + ((y * z) * (1.0 / t))) / t_1; elseif (t_2 <= 0.0) tmp = (t / y) * ((x + (z / (t / y))) / b); elseif (t_2 <= 2e+293) tmp = t_2; 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[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(z * N[(y / N[(t + N[(t * N[(a + N[(y / N[(t / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -2e-321], N[(N[(x + N[(N[(y * z), $MachinePrecision] * N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(t / y), $MachinePrecision] * N[(N[(x + N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+293], t$95$2, 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 := \left(a + 1\right) + \frac{y \cdot b}{t}\\
t_2 := \frac{x + \frac{y \cdot z}{t}}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;z \cdot \frac{y}{t + t \cdot \left(a + \frac{y}{\frac{t}{b}}\right)}\\
\mathbf{elif}\;t_2 \leq -2 \cdot 10^{-321}:\\
\;\;\;\;\frac{x + \left(y \cdot z\right) \cdot \frac{1}{t}}{t_1}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{t}{y} \cdot \frac{x + \frac{z}{\frac{t}{y}}}{b}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+293}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
Results
| Original | 17.0 |
|---|---|
| Target | 13.6 |
| Herbie | 7.2 |
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -inf.0Initial program 64.0
Taylor expanded in x around 0 39.9
Simplified13.2
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -2.00097e-321Initial program 0.5
Applied egg-rr0.6
if -2.00097e-321 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -0.0Initial program 29.6
Taylor expanded in b around inf 31.7
Simplified26.8
if -0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < 1.9999999999999998e293Initial program 0.4
if 1.9999999999999998e293 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) Initial program 62.4
Simplified51.3
Taylor expanded in y around inf 13.2
Final simplification7.2
| Alternative 1 | |
|---|---|
| Error | 51.2 |
| Cost | 64 |

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