
(FPCore (x y z t a b) :precision binary64 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
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));
}
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
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));
}
def code(x, y, z, t, a, b): return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
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 tmp = code(x, y, z, t, a, b) tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t)); 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]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
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));
}
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
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));
}
def code(x, y, z, t, a, b): return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t))
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 tmp = code(x, y, z, t, a, b) tmp = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t)); 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]
\begin{array}{l}
\\
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\end{array}
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
(t_2 (fma y (/ b t) a))
(t_3 (* z (+ (/ x (fma z t_2 z)) (/ y (fma t t_2 t))))))
(if (<= t_1 (- INFINITY))
t_3
(if (<= t_1 2e+259)
t_1
(if (<= t_1 INFINITY) t_3 (/ (fma t (/ x y) z) b))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
double t_2 = fma(y, (b / t), a);
double t_3 = z * ((x / fma(z, t_2, z)) + (y / fma(t, t_2, t)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_1 <= 2e+259) {
tmp = t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = fma(t, (x / y), z) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) t_2 = fma(y, Float64(b / t), a) t_3 = Float64(z * Float64(Float64(x / fma(z, t_2, z)) + Float64(y / fma(t, t_2, t)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_3; elseif (t_1 <= 2e+259) tmp = t_1; elseif (t_1 <= Inf) tmp = t_3; else tmp = Float64(fma(t, Float64(x / y), z) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[(y * N[(b / t), $MachinePrecision] + a), $MachinePrecision]}, Block[{t$95$3 = N[(z * N[(N[(x / N[(z * t$95$2 + z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(t * t$95$2 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$3, If[LessEqual[t$95$1, 2e+259], t$95$1, If[LessEqual[t$95$1, Infinity], t$95$3, N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\
t_2 := \mathsf{fma}\left(y, \frac{b}{t}, a\right)\\
t_3 := z \cdot \left(\frac{x}{\mathsf{fma}\left(z, t\_2, z\right)} + \frac{y}{\mathsf{fma}\left(t, t\_2, t\right)}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+259}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < -inf.0 or 2e259 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 43.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
+-commutativeN/A
Applied rewrites87.6%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2e259Initial program 93.3%
if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 0.0%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites76.4%
Taylor expanded in b around inf
Applied rewrites100.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))) (if (<= t_1 2e+277) t_1 (/ (fma t (/ x y) z) b))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
double tmp;
if (t_1 <= 2e+277) {
tmp = t_1;
} else {
tmp = fma(t, (x / y), z) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))) tmp = 0.0 if (t_1 <= 2e+277) tmp = t_1; else tmp = Float64(fma(t, Float64(x / y), z) / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, 2e+277], t$95$1, N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\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 2 \cdot 10^{+277}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 2.00000000000000001e277Initial program 90.0%
if 2.00000000000000001e277 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 11.5%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.4%
Taylor expanded in b around inf
Applied rewrites81.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))) INFINITY) (/ (fma y (/ z t) x) (fma y (/ b t) (+ a 1.0))) (/ (fma t (/ x y) z) b)))
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))) <= ((double) INFINITY)) {
tmp = fma(y, (z / t), x) / fma(y, (b / t), (a + 1.0));
} else {
tmp = fma(t, (x / y), z) / b;
}
return tmp;
}
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))) <= Inf) tmp = Float64(fma(y, Float64(z / t), x) / fma(y, Float64(b / t), Float64(a + 1.0))); else tmp = Float64(fma(t, Float64(x / y), z) / b); end return tmp end
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], Infinity], N[(N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision] / N[(y * N[(b / t), $MachinePrecision] + N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{\mathsf{fma}\left(y, \frac{b}{t}, a + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < +inf.0Initial program 86.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.6
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.3
Applied rewrites80.3%
if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 0.0%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites76.4%
Taylor expanded in b around inf
Applied rewrites100.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma t (/ x y) z) b)))
(if (<= y -3e+46)
t_1
(if (<= y 1.08e+102) (/ (fma z (/ y t) x) (+ a 1.0)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, (x / y), z) / b;
double tmp;
if (y <= -3e+46) {
tmp = t_1;
} else if (y <= 1.08e+102) {
tmp = fma(z, (y / t), x) / (a + 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(t, Float64(x / y), z) / b) tmp = 0.0 if (y <= -3e+46) tmp = t_1; elseif (y <= 1.08e+102) tmp = Float64(fma(z, Float64(y / t), x) / Float64(a + 1.0)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -3e+46], t$95$1, If[LessEqual[y, 1.08e+102], N[(N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(a + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\mathbf{if}\;y \leq -3 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+102}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, \frac{y}{t}, x\right)}{a + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.00000000000000023e46 or 1.08000000000000002e102 < y Initial program 49.6%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.3%
Taylor expanded in b around inf
Applied rewrites74.3%
if -3.00000000000000023e46 < y < 1.08000000000000002e102Initial program 95.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*r/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f6479.9
Applied rewrites79.9%
Final simplification77.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ x (+ 1.0 (fma y (/ b t) a))))) (if (<= t -3e-39) t_1 (if (<= t 1.35e+38) (/ (+ z (/ (* x t) y)) b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = x / (1.0 + fma(y, (b / t), a));
double tmp;
if (t <= -3e-39) {
tmp = t_1;
} else if (t <= 1.35e+38) {
tmp = (z + ((x * t) / y)) / b;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(x / Float64(1.0 + fma(y, Float64(b / t), a))) tmp = 0.0 if (t <= -3e-39) tmp = t_1; elseif (t <= 1.35e+38) tmp = Float64(Float64(z + Float64(Float64(x * t) / y)) / b); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x / N[(1.0 + N[(y * N[(b / t), $MachinePrecision] + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3e-39], t$95$1, If[LessEqual[t, 1.35e+38], N[(N[(z + N[(N[(x * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{1 + \mathsf{fma}\left(y, \frac{b}{t}, a\right)}\\
\mathbf{if}\;t \leq -3 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{+38}:\\
\;\;\;\;\frac{z + \frac{x \cdot t}{y}}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.00000000000000028e-39 or 1.34999999999999998e38 < t Initial program 88.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower-+.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6473.4
Applied rewrites73.4%
if -3.00000000000000028e-39 < t < 1.34999999999999998e38Initial program 68.3%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites49.8%
Taylor expanded in b around inf
Applied rewrites58.5%
Applied rewrites60.3%
Final simplification66.5%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ (fma t (/ x y) z) b))) (if (<= y -7.6e-29) t_1 (if (<= y 4.2e+56) (/ x (+ a 1.0)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = fma(t, (x / y), z) / b;
double tmp;
if (y <= -7.6e-29) {
tmp = t_1;
} else if (y <= 4.2e+56) {
tmp = x / (a + 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(fma(t, Float64(x / y), z) / b) tmp = 0.0 if (y <= -7.6e-29) tmp = t_1; elseif (y <= 4.2e+56) tmp = Float64(x / Float64(a + 1.0)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]}, If[LessEqual[y, -7.6e-29], t$95$1, If[LessEqual[y, 4.2e+56], N[(x / N[(a + 1.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\mathsf{fma}\left(t, \frac{x}{y}, z\right)}{b}\\
\mathbf{if}\;y \leq -7.6 \cdot 10^{-29}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{a + 1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.59999999999999951e-29 or 4.20000000000000034e56 < y Initial program 55.9%
Taylor expanded in y around inf
sub-negN/A
associate-+l+N/A
sub-negN/A
associate-/l*N/A
associate-/l*N/A
distribute-lft-out--N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites55.4%
Taylor expanded in b around inf
Applied rewrites69.3%
if -7.59999999999999951e-29 < y < 4.20000000000000034e56Initial program 95.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6461.3
Applied rewrites61.3%
Final simplification64.8%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.45e-38) (/ z b) (if (<= y -2.5e-133) (/ x 1.0) (if (<= y 1.8e-55) (/ x a) (/ z b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= -2.5e-133) {
tmp = x / 1.0;
} else if (y <= 1.8e-55) {
tmp = x / 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
real(8) :: tmp
if (y <= (-1.45d-38)) then
tmp = z / b
else if (y <= (-2.5d-133)) then
tmp = x / 1.0d0
else if (y <= 1.8d-55) then
tmp = x / 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) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= -2.5e-133) {
tmp = x / 1.0;
} else if (y <= 1.8e-55) {
tmp = x / a;
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.45e-38: tmp = z / b elif y <= -2.5e-133: tmp = x / 1.0 elif y <= 1.8e-55: tmp = x / a else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.45e-38) tmp = Float64(z / b); elseif (y <= -2.5e-133) tmp = Float64(x / 1.0); elseif (y <= 1.8e-55) tmp = Float64(x / a); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.45e-38) tmp = z / b; elseif (y <= -2.5e-133) tmp = x / 1.0; elseif (y <= 1.8e-55) tmp = x / a; else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.45e-38], N[(z / b), $MachinePrecision], If[LessEqual[y, -2.5e-133], N[(x / 1.0), $MachinePrecision], If[LessEqual[y, 1.8e-55], N[(x / a), $MachinePrecision], N[(z / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-38}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-133}:\\
\;\;\;\;\frac{x}{1}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-55}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -1.44999999999999997e-38 or 1.8e-55 < y Initial program 63.4%
Taylor expanded in y around inf
lower-/.f6456.3
Applied rewrites56.3%
if -1.44999999999999997e-38 < y < -2.5e-133Initial program 96.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6495.9
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.5
Applied rewrites84.5%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6454.7
Applied rewrites54.7%
Taylor expanded in a around 0
Applied rewrites39.1%
if -2.5e-133 < y < 1.8e-55Initial program 96.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6484.8
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6469.4
Applied rewrites69.4%
Taylor expanded in a around inf
Applied rewrites42.9%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.45e-38) (/ z b) (if (<= y -3.1e-152) (- x (* x a)) (if (<= y 1.8e-55) (/ x a) (/ z b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= -3.1e-152) {
tmp = x - (x * a);
} else if (y <= 1.8e-55) {
tmp = x / 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
real(8) :: tmp
if (y <= (-1.45d-38)) then
tmp = z / b
else if (y <= (-3.1d-152)) then
tmp = x - (x * a)
else if (y <= 1.8d-55) then
tmp = x / 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) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= -3.1e-152) {
tmp = x - (x * a);
} else if (y <= 1.8e-55) {
tmp = x / a;
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.45e-38: tmp = z / b elif y <= -3.1e-152: tmp = x - (x * a) elif y <= 1.8e-55: tmp = x / a else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.45e-38) tmp = Float64(z / b); elseif (y <= -3.1e-152) tmp = Float64(x - Float64(x * a)); elseif (y <= 1.8e-55) tmp = Float64(x / a); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.45e-38) tmp = z / b; elseif (y <= -3.1e-152) tmp = x - (x * a); elseif (y <= 1.8e-55) tmp = x / a; else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.45e-38], N[(z / b), $MachinePrecision], If[LessEqual[y, -3.1e-152], N[(x - N[(x * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e-55], N[(x / a), $MachinePrecision], N[(z / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-38}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{-152}:\\
\;\;\;\;x - x \cdot a\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-55}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -1.44999999999999997e-38 or 1.8e-55 < y Initial program 63.4%
Taylor expanded in y around inf
lower-/.f6456.3
Applied rewrites56.3%
if -1.44999999999999997e-38 < y < -3.0999999999999998e-152Initial program 93.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6493.5
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6483.8
Applied rewrites83.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6459.1
Applied rewrites59.1%
Taylor expanded in a around 0
Applied rewrites39.0%
Applied rewrites39.0%
if -3.0999999999999998e-152 < y < 1.8e-55Initial program 97.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6485.1
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6479.7
Applied rewrites79.7%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6468.7
Applied rewrites68.7%
Taylor expanded in a around inf
Applied rewrites43.0%
(FPCore (x y z t a b) :precision binary64 (if (<= y -8e-29) (/ z b) (if (<= y 9.2e+56) (/ x (+ a 1.0)) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -8e-29) {
tmp = z / b;
} else if (y <= 9.2e+56) {
tmp = x / (a + 1.0);
} 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
real(8) :: tmp
if (y <= (-8d-29)) then
tmp = z / b
else if (y <= 9.2d+56) then
tmp = x / (a + 1.0d0)
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) {
double tmp;
if (y <= -8e-29) {
tmp = z / b;
} else if (y <= 9.2e+56) {
tmp = x / (a + 1.0);
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -8e-29: tmp = z / b elif y <= 9.2e+56: tmp = x / (a + 1.0) else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -8e-29) tmp = Float64(z / b); elseif (y <= 9.2e+56) tmp = Float64(x / Float64(a + 1.0)); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -8e-29) tmp = z / b; elseif (y <= 9.2e+56) tmp = x / (a + 1.0); else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -8e-29], N[(z / b), $MachinePrecision], If[LessEqual[y, 9.2e+56], N[(x / N[(a + 1.0), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{-29}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{a + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -7.99999999999999955e-29 or 9.20000000000000058e56 < y Initial program 55.9%
Taylor expanded in y around inf
lower-/.f6464.2
Applied rewrites64.2%
if -7.99999999999999955e-29 < y < 9.20000000000000058e56Initial program 95.2%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6461.3
Applied rewrites61.3%
Final simplification62.6%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.45e-38) (/ z b) (if (<= y 5.2e-79) (- x (* x a)) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= 5.2e-79) {
tmp = x - (x * 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
real(8) :: tmp
if (y <= (-1.45d-38)) then
tmp = z / b
else if (y <= 5.2d-79) then
tmp = x - (x * 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) {
double tmp;
if (y <= -1.45e-38) {
tmp = z / b;
} else if (y <= 5.2e-79) {
tmp = x - (x * a);
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.45e-38: tmp = z / b elif y <= 5.2e-79: tmp = x - (x * a) else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.45e-38) tmp = Float64(z / b); elseif (y <= 5.2e-79) tmp = Float64(x - Float64(x * a)); else tmp = Float64(z / b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.45e-38) tmp = z / b; elseif (y <= 5.2e-79) tmp = x - (x * a); else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.45e-38], N[(z / b), $MachinePrecision], If[LessEqual[y, 5.2e-79], N[(x - N[(x * a), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-38}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-79}:\\
\;\;\;\;x - x \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -1.44999999999999997e-38 or 5.19999999999999987e-79 < y Initial program 64.6%
Taylor expanded in y around inf
lower-/.f6455.2
Applied rewrites55.2%
if -1.44999999999999997e-38 < y < 5.19999999999999987e-79Initial program 96.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6487.6
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6480.8
Applied rewrites80.8%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6467.3
Applied rewrites67.3%
Taylor expanded in a around 0
Applied rewrites31.6%
Applied rewrites31.6%
(FPCore (x y z t a b) :precision binary64 (- x (* x a)))
double code(double x, double y, double z, double t, double a, double b) {
return x - (x * a);
}
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 - (x * a)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x - (x * a);
}
def code(x, y, z, t, a, b): return x - (x * a)
function code(x, y, z, t, a, b) return Float64(x - Float64(x * a)) end
function tmp = code(x, y, z, t, a, b) tmp = x - (x * a); end
code[x_, y_, z_, t_, a_, b_] := N[(x - N[(x * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - x \cdot a
\end{array}
Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.6
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6473.6
Applied rewrites73.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6441.5
Applied rewrites41.5%
Taylor expanded in a around 0
Applied rewrites18.2%
Applied rewrites18.2%
(FPCore (x y z t a b) :precision binary64 (* x (- a)))
double code(double x, double y, double z, double t, double a, double b) {
return x * -a;
}
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 * -a
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * -a;
}
def code(x, y, z, t, a, b): return x * -a
function code(x, y, z, t, a, b) return Float64(x * Float64(-a)) end
function tmp = code(x, y, z, t, a, b) tmp = x * -a; end
code[x_, y_, z_, t_, a_, b_] := N[(x * (-a)), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(-a\right)
\end{array}
Initial program 78.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.6
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6473.6
Applied rewrites73.6%
Taylor expanded in y around 0
lower-/.f64N/A
lower-+.f6441.5
Applied rewrites41.5%
Taylor expanded in a around 0
Applied rewrites18.2%
Taylor expanded in a around inf
Applied rewrites3.6%
Final simplification3.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1
(* 1.0 (* (+ x (* (/ y t) z)) (/ 1.0 (+ (+ a 1.0) (* (/ y t) b)))))))
(if (< t -1.3659085366310088e-271)
t_1
(if (< t 3.036967103737246e-130) (/ z b) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b))));
double tmp;
if (t < -1.3659085366310088e-271) {
tmp = t_1;
} else if (t < 3.036967103737246e-130) {
tmp = z / b;
} else {
tmp = t_1;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = 1.0d0 * ((x + ((y / t) * z)) * (1.0d0 / ((a + 1.0d0) + ((y / t) * b))))
if (t < (-1.3659085366310088d-271)) then
tmp = t_1
else if (t < 3.036967103737246d-130) then
tmp = z / b
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b))));
double tmp;
if (t < -1.3659085366310088e-271) {
tmp = t_1;
} else if (t < 3.036967103737246e-130) {
tmp = z / b;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b)))) tmp = 0 if t < -1.3659085366310088e-271: tmp = t_1 elif t < 3.036967103737246e-130: tmp = z / b else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(1.0 * Float64(Float64(x + Float64(Float64(y / t) * z)) * Float64(1.0 / Float64(Float64(a + 1.0) + Float64(Float64(y / t) * b))))) tmp = 0.0 if (t < -1.3659085366310088e-271) tmp = t_1; elseif (t < 3.036967103737246e-130) tmp = Float64(z / b); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = 1.0 * ((x + ((y / t) * z)) * (1.0 / ((a + 1.0) + ((y / t) * b)))); tmp = 0.0; if (t < -1.3659085366310088e-271) tmp = t_1; elseif (t < 3.036967103737246e-130) tmp = z / b; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(1.0 * N[(N[(x + N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y / t), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t, -1.3659085366310088e-271], t$95$1, If[Less[t, 3.036967103737246e-130], N[(z / b), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 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{if}\;t < -1.3659085366310088 \cdot 10^{-271}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t < 3.036967103737246 \cdot 10^{-130}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024223
(FPCore (x y z t a b)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (if (< t -1707385670788761/12500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))) (if (< t 1518483551868623/5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ z b) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))))))
(/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))