
(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 11 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 (/ (+ (/ (* z y) t) x) (+ (/ (* b y) t) (+ 1.0 a)))))
(if (<= t_1 (- INFINITY))
(* (/ y (fma (fma (/ b t) y a) t t)) z)
(if (<= t_1 5e+304) 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 = (((z * y) / t) + x) / (((b * y) / t) + (1.0 + a));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (y / fma(fma((b / t), y, a), t, t)) * z;
} else if (t_1 <= 5e+304) {
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(Float64(Float64(z * y) / t) + x) / Float64(Float64(Float64(b * y) / t) + Float64(1.0 + a))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(y / fma(fma(Float64(b / t), y, a), t, t)) * z); elseif (t_1 <= 5e+304) 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[(N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision] / N[(N[(N[(b * y), $MachinePrecision] / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(y / N[(N[(N[(b / t), $MachinePrecision] * y + a), $MachinePrecision] * t + t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$1, 5e+304], t$95$1, N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{z \cdot y}{t} + x}{\frac{b \cdot y}{t} + \left(1 + a\right)}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{b}{t}, y, a\right), t, t\right)} \cdot z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;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))) < -inf.0Initial program 48.6%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
Applied rewrites99.8%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 4.9999999999999997e304Initial program 93.6%
if 4.9999999999999997e304 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 16.3%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6420.5
Applied rewrites20.5%
Taylor expanded in t around 0
Applied rewrites84.5%
Taylor expanded in b around 0
Applied rewrites88.6%
Final simplification93.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (/ (* b y) t) (+ 1.0 a))) (t_2 (/ (+ (/ (* z y) t) x) t_1)))
(if (<= t_2 (- INFINITY))
(* (/ y (fma (fma (/ b t) y a) t t)) z)
(if (<= t_2 5e+304) (/ (fma z (/ y t) x) 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 = ((b * y) / t) + (1.0 + a);
double t_2 = (((z * y) / t) + x) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (y / fma(fma((b / t), y, a), t, t)) * z;
} else if (t_2 <= 5e+304) {
tmp = fma(z, (y / t), x) / t_1;
} else {
tmp = fma(t, (x / y), z) / b;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(b * y) / t) + Float64(1.0 + a)) t_2 = Float64(Float64(Float64(Float64(z * y) / t) + x) / t_1) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(y / fma(fma(Float64(b / t), y, a), t, t)) * z); elseif (t_2 <= 5e+304) tmp = Float64(fma(z, Float64(y / t), x) / 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[(N[(b * y), $MachinePrecision] / t), $MachinePrecision] + N[(1.0 + a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(y / N[(N[(N[(b / t), $MachinePrecision] * y + a), $MachinePrecision] * t + t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[t$95$2, 5e+304], N[(N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(t * N[(x / y), $MachinePrecision] + z), $MachinePrecision] / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{b \cdot y}{t} + \left(1 + a\right)\\
t_2 := \frac{\frac{z \cdot y}{t} + x}{t\_1}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{b}{t}, y, a\right), t, t\right)} \cdot z\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, \frac{y}{t}, x\right)}{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))) < -inf.0Initial program 48.6%
Taylor expanded in z around inf
associate-*l/N/A
lower-*.f64N/A
Applied rewrites99.8%
if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) < 4.9999999999999997e304Initial program 93.6%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6490.0
Applied rewrites90.0%
if 4.9999999999999997e304 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a #s(literal 1 binary64)) (/.f64 (*.f64 y b) t))) Initial program 16.3%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6420.5
Applied rewrites20.5%
Taylor expanded in t around 0
Applied rewrites84.5%
Taylor expanded in b around 0
Applied rewrites88.6%
Final simplification90.2%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma t (/ x y) z) b)))
(if (<= y -140000000000.0)
t_1
(if (<= y 1.08e+71) (/ (fma z (/ y t) x) (+ 1.0 a)) 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 <= -140000000000.0) {
tmp = t_1;
} else if (y <= 1.08e+71) {
tmp = fma(z, (y / t), x) / (1.0 + a);
} 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 <= -140000000000.0) tmp = t_1; elseif (y <= 1.08e+71) tmp = Float64(fma(z, Float64(y / t), x) / Float64(1.0 + a)); 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, -140000000000.0], t$95$1, If[LessEqual[y, 1.08e+71], N[(N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision] / N[(1.0 + a), $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 -140000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+71}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, \frac{y}{t}, x\right)}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.4e11 or 1.08e71 < y Initial program 51.1%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.6
Applied rewrites33.6%
Taylor expanded in t around 0
Applied rewrites69.1%
Taylor expanded in b around 0
Applied rewrites73.5%
if -1.4e11 < y < 1.08e71Initial program 95.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6496.1
Applied rewrites96.1%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f6481.1
Applied rewrites81.1%
Final simplification78.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma t (/ x y) z) b)))
(if (<= y -140000000000.0)
t_1
(if (<= y 1.25e+71) (/ (fma (/ z t) y x) (+ 1.0 a)) 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 <= -140000000000.0) {
tmp = t_1;
} else if (y <= 1.25e+71) {
tmp = fma((z / t), y, x) / (1.0 + a);
} 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 <= -140000000000.0) tmp = t_1; elseif (y <= 1.25e+71) tmp = Float64(fma(Float64(z / t), y, x) / Float64(1.0 + a)); 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, -140000000000.0], t$95$1, If[LessEqual[y, 1.25e+71], N[(N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision] / N[(1.0 + a), $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 -140000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+71}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.4e11 or 1.24999999999999993e71 < y Initial program 51.1%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6433.6
Applied rewrites33.6%
Taylor expanded in t around 0
Applied rewrites69.1%
Taylor expanded in b around 0
Applied rewrites73.5%
if -1.4e11 < y < 1.24999999999999993e71Initial program 95.0%
Taylor expanded in b around 0
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6474.6
Applied rewrites74.6%
Final simplification74.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (/ (fma t (/ x y) z) b)))
(if (<= y -185000000.0)
t_1
(if (<= y 1.55e-40) (/ x (fma (/ b t) y (+ 1.0 a))) 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 <= -185000000.0) {
tmp = t_1;
} else if (y <= 1.55e-40) {
tmp = x / fma((b / t), y, (1.0 + a));
} 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 <= -185000000.0) tmp = t_1; elseif (y <= 1.55e-40) tmp = Float64(x / fma(Float64(b / t), y, Float64(1.0 + a))); 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, -185000000.0], t$95$1, If[LessEqual[y, 1.55e-40], N[(x / N[(N[(b / t), $MachinePrecision] * y + N[(1.0 + a), $MachinePrecision]), $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 -185000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-40}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(\frac{b}{t}, y, 1 + a\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.85e8 or 1.55000000000000005e-40 < y Initial program 55.2%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
Taylor expanded in t around 0
Applied rewrites66.9%
Taylor expanded in b around 0
Applied rewrites70.8%
if -1.85e8 < y < 1.55000000000000005e-40Initial program 95.9%
Taylor expanded in z around 0
lower-/.f64N/A
associate-+r+N/A
+-commutativeN/A
remove-double-negN/A
associate-/l*N/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6471.1
Applied rewrites71.1%
Final simplification71.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (/ (fma t (/ x y) z) b))) (if (<= y -116000000.0) t_1 (if (<= y 1.25e-42) (/ x (+ 1.0 a)) 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 <= -116000000.0) {
tmp = t_1;
} else if (y <= 1.25e-42) {
tmp = x / (1.0 + a);
} 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 <= -116000000.0) tmp = t_1; elseif (y <= 1.25e-42) tmp = Float64(x / Float64(1.0 + a)); 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, -116000000.0], t$95$1, If[LessEqual[y, 1.25e-42], N[(x / N[(1.0 + a), $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 -116000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-42}:\\
\;\;\;\;\frac{x}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.16e8 or 1.25000000000000001e-42 < y Initial program 55.2%
Taylor expanded in b around inf
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6435.6
Applied rewrites35.6%
Taylor expanded in t around 0
Applied rewrites66.9%
Taylor expanded in b around 0
Applied rewrites70.8%
if -1.16e8 < y < 1.25000000000000001e-42Initial program 95.9%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
Final simplification67.6%
(FPCore (x y z t a b) :precision binary64 (if (<= y -185000000.0) (/ z b) (if (<= y 1.35e-40) (/ x (+ 1.0 a)) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -185000000.0) {
tmp = z / b;
} else if (y <= 1.35e-40) {
tmp = x / (1.0 + 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 <= (-185000000.0d0)) then
tmp = z / b
else if (y <= 1.35d-40) then
tmp = x / (1.0d0 + 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 <= -185000000.0) {
tmp = z / b;
} else if (y <= 1.35e-40) {
tmp = x / (1.0 + a);
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -185000000.0: tmp = z / b elif y <= 1.35e-40: tmp = x / (1.0 + a) else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -185000000.0) tmp = Float64(z / b); elseif (y <= 1.35e-40) tmp = Float64(x / Float64(1.0 + 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 <= -185000000.0) tmp = z / b; elseif (y <= 1.35e-40) tmp = x / (1.0 + a); else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -185000000.0], N[(z / b), $MachinePrecision], If[LessEqual[y, 1.35e-40], N[(x / N[(1.0 + a), $MachinePrecision]), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -185000000:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-40}:\\
\;\;\;\;\frac{x}{1 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -1.85e8 or 1.35e-40 < y Initial program 55.2%
Taylor expanded in t around 0
lower-/.f6461.0
Applied rewrites61.0%
if -1.85e8 < y < 1.35e-40Initial program 95.9%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6464.8
Applied rewrites64.8%
Final simplification63.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -7.1e-6) (/ z b) (if (<= y 3.2e-61) (/ x a) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -7.1e-6) {
tmp = z / b;
} else if (y <= 3.2e-61) {
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 <= (-7.1d-6)) then
tmp = z / b
else if (y <= 3.2d-61) 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 <= -7.1e-6) {
tmp = z / b;
} else if (y <= 3.2e-61) {
tmp = x / a;
} else {
tmp = z / b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -7.1e-6: tmp = z / b elif y <= 3.2e-61: tmp = x / a else: tmp = z / b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -7.1e-6) tmp = Float64(z / b); elseif (y <= 3.2e-61) 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 <= -7.1e-6) tmp = z / b; elseif (y <= 3.2e-61) tmp = x / a; else tmp = z / b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -7.1e-6], N[(z / b), $MachinePrecision], If[LessEqual[y, 3.2e-61], N[(x / a), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.1 \cdot 10^{-6}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-61}:\\
\;\;\;\;\frac{x}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -7.0999999999999998e-6 or 3.2000000000000001e-61 < y Initial program 58.0%
Taylor expanded in t around 0
lower-/.f6458.7
Applied rewrites58.7%
if -7.0999999999999998e-6 < y < 3.2000000000000001e-61Initial program 96.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6496.1
Applied rewrites96.1%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6466.5
Applied rewrites66.5%
Taylor expanded in a around inf
Applied rewrites37.0%
(FPCore (x y z t a b) :precision binary64 (if (<= y -9.2e-64) (/ z b) (if (<= y 3.5e-42) (fma (- x) a x) (/ z b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -9.2e-64) {
tmp = z / b;
} else if (y <= 3.5e-42) {
tmp = fma(-x, a, x);
} else {
tmp = z / b;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -9.2e-64) tmp = Float64(z / b); elseif (y <= 3.5e-42) tmp = fma(Float64(-x), a, x); else tmp = Float64(z / b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -9.2e-64], N[(z / b), $MachinePrecision], If[LessEqual[y, 3.5e-42], N[((-x) * a + x), $MachinePrecision], N[(z / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{-64}:\\
\;\;\;\;\frac{z}{b}\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-42}:\\
\;\;\;\;\mathsf{fma}\left(-x, a, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\
\end{array}
\end{array}
if y < -9.2000000000000006e-64 or 3.5000000000000002e-42 < y Initial program 59.1%
Taylor expanded in t around 0
lower-/.f6458.2
Applied rewrites58.2%
if -9.2000000000000006e-64 < y < 3.5000000000000002e-42Initial program 96.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6495.3
Applied rewrites95.3%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6466.5
Applied rewrites66.5%
Taylor expanded in a around 0
Applied rewrites33.1%
(FPCore (x y z t a b) :precision binary64 (fma (- x) a x))
double code(double x, double y, double z, double t, double a, double b) {
return fma(-x, a, x);
}
function code(x, y, z, t, a, b) return fma(Float64(-x), a, x) end
code[x_, y_, z_, t_, a_, b_] := N[((-x) * a + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-x, a, x\right)
\end{array}
Initial program 77.1%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6477.0
Applied rewrites77.0%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6440.9
Applied rewrites40.9%
Taylor expanded in a around 0
Applied rewrites20.3%
(FPCore (x y z t a b) :precision binary64 (* (- a) x))
double code(double x, double y, double z, double t, double a, double b) {
return -a * x;
}
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 = -a * x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return -a * x;
}
def code(x, y, z, t, a, b): return -a * x
function code(x, y, z, t, a, b) return Float64(Float64(-a) * x) end
function tmp = code(x, y, z, t, a, b) tmp = -a * x; end
code[x_, y_, z_, t_, a_, b_] := N[((-a) * x), $MachinePrecision]
\begin{array}{l}
\\
\left(-a\right) \cdot x
\end{array}
Initial program 77.1%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6477.0
Applied rewrites77.0%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f6440.9
Applied rewrites40.9%
Taylor expanded in a around 0
Applied rewrites20.3%
Taylor expanded in a around inf
Applied rewrites4.4%
(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 2024257
(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))))