
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
real(8) function code(x, y, z, t, a)
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
code = (x - (y * z)) / (t - (a * z))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
def code(x, y, z, t, a): return (x - (y * z)) / (t - (a * z))
function code(x, y, z, t, a) return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) end
function tmp = code(x, y, z, t, a) tmp = (x - (y * z)) / (t - (a * z)); end
code[x_, y_, z_, t_, a_] := N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y \cdot z}{t - a \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
real(8) function code(x, y, z, t, a)
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
code = (x - (y * z)) / (t - (a * z))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
def code(x, y, z, t, a): return (x - (y * z)) / (t - (a * z))
function code(x, y, z, t, a) return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) end
function tmp = code(x, y, z, t, a) tmp = (x - (y * z)) / (t - (a * z)); end
code[x_, y_, z_, t_, a_] := N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y \cdot z}{t - a \cdot z}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma a z (- t)))
(t_2 (/ z t_1))
(t_3 (- x (* z y)))
(t_4 (- t (* a z)))
(t_5 (/ t_3 t_4)))
(if (<= t_5 -5e-116)
(fma t_2 y (/ x t_4))
(if (<= t_5 1e-64)
(/ 1.0 (fma z (/ a (- (* z y) x)) (/ t t_3)))
(if (<= t_5 INFINITY) (- (* t_2 y) (/ x t_1)) (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(a, z, -t);
double t_2 = z / t_1;
double t_3 = x - (z * y);
double t_4 = t - (a * z);
double t_5 = t_3 / t_4;
double tmp;
if (t_5 <= -5e-116) {
tmp = fma(t_2, y, (x / t_4));
} else if (t_5 <= 1e-64) {
tmp = 1.0 / fma(z, (a / ((z * y) - x)), (t / t_3));
} else if (t_5 <= ((double) INFINITY)) {
tmp = (t_2 * y) - (x / t_1);
} else {
tmp = y / a;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(a, z, Float64(-t)) t_2 = Float64(z / t_1) t_3 = Float64(x - Float64(z * y)) t_4 = Float64(t - Float64(a * z)) t_5 = Float64(t_3 / t_4) tmp = 0.0 if (t_5 <= -5e-116) tmp = fma(t_2, y, Float64(x / t_4)); elseif (t_5 <= 1e-64) tmp = Float64(1.0 / fma(z, Float64(a / Float64(Float64(z * y) - x)), Float64(t / t_3))); elseif (t_5 <= Inf) tmp = Float64(Float64(t_2 * y) - Float64(x / t_1)); else tmp = Float64(y / a); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * z + (-t)), $MachinePrecision]}, Block[{t$95$2 = N[(z / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 / t$95$4), $MachinePrecision]}, If[LessEqual[t$95$5, -5e-116], N[(t$95$2 * y + N[(x / t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 1e-64], N[(1.0 / N[(z * N[(a / N[(N[(z * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] + N[(t / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[(t$95$2 * y), $MachinePrecision] - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision], N[(y / a), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, z, -t\right)\\
t_2 := \frac{z}{t\_1}\\
t_3 := x - z \cdot y\\
t_4 := t - a \cdot z\\
t_5 := \frac{t\_3}{t\_4}\\
\mathbf{if}\;t\_5 \leq -5 \cdot 10^{-116}:\\
\;\;\;\;\mathsf{fma}\left(t\_2, y, \frac{x}{t\_4}\right)\\
\mathbf{elif}\;t\_5 \leq 10^{-64}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(z, \frac{a}{z \cdot y - x}, \frac{t}{t\_3}\right)}\\
\mathbf{elif}\;t\_5 \leq \infty:\\
\;\;\;\;t\_2 \cdot y - \frac{x}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -5.0000000000000003e-116Initial program 95.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites99.8%
if -5.0000000000000003e-116 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 9.99999999999999965e-65Initial program 87.2%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
frac-2negN/A
lower-/.f64N/A
neg-sub0N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
lower--.f64N/A
neg-sub0N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
lower--.f6486.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6486.0
Applied rewrites86.0%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f6492.8
Applied rewrites92.8%
if 9.99999999999999965e-65 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0Initial program 90.4%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
flip--N/A
distribute-neg-fracN/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites41.5%
Applied rewrites99.7%
if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 0.0%
Taylor expanded in z around inf
lower-/.f64100.0
Applied rewrites100.0%
Final simplification97.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma a z (- t))))
(if (<= z -3.2e+169)
(/ (- y (/ x z)) a)
(if (<= z 6e-82)
(+ (/ (* z y) (- (* a z) t)) (/ x (- t (* a z))))
(- (* (/ z t_1) y) (/ x t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(a, z, -t);
double tmp;
if (z <= -3.2e+169) {
tmp = (y - (x / z)) / a;
} else if (z <= 6e-82) {
tmp = ((z * y) / ((a * z) - t)) + (x / (t - (a * z)));
} else {
tmp = ((z / t_1) * y) - (x / t_1);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(a, z, Float64(-t)) tmp = 0.0 if (z <= -3.2e+169) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (z <= 6e-82) tmp = Float64(Float64(Float64(z * y) / Float64(Float64(a * z) - t)) + Float64(x / Float64(t - Float64(a * z)))); else tmp = Float64(Float64(Float64(z / t_1) * y) - Float64(x / t_1)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a * z + (-t)), $MachinePrecision]}, If[LessEqual[z, -3.2e+169], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 6e-82], N[(N[(N[(z * y), $MachinePrecision] / N[(N[(a * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z / t$95$1), $MachinePrecision] * y), $MachinePrecision] - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, z, -t\right)\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+169}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-82}:\\
\;\;\;\;\frac{z \cdot y}{a \cdot z - t} + \frac{x}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{t\_1} \cdot y - \frac{x}{t\_1}\\
\end{array}
\end{array}
if z < -3.1999999999999998e169Initial program 57.3%
Taylor expanded in t around 0
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
div-subN/A
sub-negN/A
distribute-lft-inN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
neg-mul-1N/A
remove-double-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -3.1999999999999998e169 < z < 5.9999999999999998e-82Initial program 97.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lower-+.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
neg-sub0N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
lower--.f64N/A
lower-/.f6497.2
Applied rewrites97.2%
if 5.9999999999999998e-82 < z Initial program 83.3%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
flip--N/A
distribute-neg-fracN/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites37.9%
Applied rewrites92.7%
Final simplification95.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ x (- t (* a z)))))
(if (<= z -3.2e+169)
(/ (- y (/ x z)) a)
(if (<= z 5e+36)
(+ (/ (* z y) (- (* a z) t)) t_1)
(fma (/ z (fma a z (- t))) y t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x / (t - (a * z));
double tmp;
if (z <= -3.2e+169) {
tmp = (y - (x / z)) / a;
} else if (z <= 5e+36) {
tmp = ((z * y) / ((a * z) - t)) + t_1;
} else {
tmp = fma((z / fma(a, z, -t)), y, t_1);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(x / Float64(t - Float64(a * z))) tmp = 0.0 if (z <= -3.2e+169) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (z <= 5e+36) tmp = Float64(Float64(Float64(z * y) / Float64(Float64(a * z) - t)) + t_1); else tmp = fma(Float64(z / fma(a, z, Float64(-t))), y, t_1); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.2e+169], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 5e+36], N[(N[(N[(z * y), $MachinePrecision] / N[(N[(a * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(z / N[(a * z + (-t)), $MachinePrecision]), $MachinePrecision] * y + t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{t - a \cdot z}\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+169}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+36}:\\
\;\;\;\;\frac{z \cdot y}{a \cdot z - t} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(a, z, -t\right)}, y, t\_1\right)\\
\end{array}
\end{array}
if z < -3.1999999999999998e169Initial program 57.3%
Taylor expanded in t around 0
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
div-subN/A
sub-negN/A
distribute-lft-inN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
neg-mul-1N/A
remove-double-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -3.1999999999999998e169 < z < 4.99999999999999977e36Initial program 97.6%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negN/A
+-commutativeN/A
lower-+.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
neg-sub0N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
associate--r+N/A
neg-sub0N/A
remove-double-negN/A
lower--.f64N/A
lower-/.f6497.6
Applied rewrites97.6%
if 4.99999999999999977e36 < z Initial program 75.3%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites89.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* a z))))
(if (<= z -3.2e+169)
(/ (- y (/ x z)) a)
(if (<= z 6e-82)
(/ (- x (* z y)) t_1)
(fma (/ z (fma a z (- t))) y (/ x t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double tmp;
if (z <= -3.2e+169) {
tmp = (y - (x / z)) / a;
} else if (z <= 6e-82) {
tmp = (x - (z * y)) / t_1;
} else {
tmp = fma((z / fma(a, z, -t)), y, (x / t_1));
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(t - Float64(a * z)) tmp = 0.0 if (z <= -3.2e+169) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (z <= 6e-82) tmp = Float64(Float64(x - Float64(z * y)) / t_1); else tmp = fma(Float64(z / fma(a, z, Float64(-t))), y, Float64(x / t_1)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.2e+169], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[z, 6e-82], N[(N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(z / N[(a * z + (-t)), $MachinePrecision]), $MachinePrecision] * y + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - a \cdot z\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+169}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-82}:\\
\;\;\;\;\frac{x - z \cdot y}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{\mathsf{fma}\left(a, z, -t\right)}, y, \frac{x}{t\_1}\right)\\
\end{array}
\end{array}
if z < -3.1999999999999998e169Initial program 57.3%
Taylor expanded in t around 0
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
div-subN/A
sub-negN/A
distribute-lft-inN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
neg-mul-1N/A
remove-double-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -3.1999999999999998e169 < z < 5.9999999999999998e-82Initial program 97.2%
if 5.9999999999999998e-82 < z Initial program 83.3%
Taylor expanded in x around 0
*-commutativeN/A
associate-*l/N/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites92.7%
Final simplification95.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ x (- t (* a z)))))
(if (<= a -1.45e-30)
t_1
(if (<= a 1.4e+31)
(/ (- x (* z y)) t)
(if (<= a 2.5e+175) t_1 (/ y a))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = x / (t - (a * z));
double tmp;
if (a <= -1.45e-30) {
tmp = t_1;
} else if (a <= 1.4e+31) {
tmp = (x - (z * y)) / t;
} else if (a <= 2.5e+175) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: t_1
real(8) :: tmp
t_1 = x / (t - (a * z))
if (a <= (-1.45d-30)) then
tmp = t_1
else if (a <= 1.4d+31) then
tmp = (x - (z * y)) / t
else if (a <= 2.5d+175) then
tmp = t_1
else
tmp = y / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x / (t - (a * z));
double tmp;
if (a <= -1.45e-30) {
tmp = t_1;
} else if (a <= 1.4e+31) {
tmp = (x - (z * y)) / t;
} else if (a <= 2.5e+175) {
tmp = t_1;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = x / (t - (a * z)) tmp = 0 if a <= -1.45e-30: tmp = t_1 elif a <= 1.4e+31: tmp = (x - (z * y)) / t elif a <= 2.5e+175: tmp = t_1 else: tmp = y / a return tmp
function code(x, y, z, t, a) t_1 = Float64(x / Float64(t - Float64(a * z))) tmp = 0.0 if (a <= -1.45e-30) tmp = t_1; elseif (a <= 1.4e+31) tmp = Float64(Float64(x - Float64(z * y)) / t); elseif (a <= 2.5e+175) tmp = t_1; else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = x / (t - (a * z)); tmp = 0.0; if (a <= -1.45e-30) tmp = t_1; elseif (a <= 1.4e+31) tmp = (x - (z * y)) / t; elseif (a <= 2.5e+175) tmp = t_1; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -1.45e-30], t$95$1, If[LessEqual[a, 1.4e+31], N[(N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[a, 2.5e+175], t$95$1, N[(y / a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{t - a \cdot z}\\
\mathbf{if}\;a \leq -1.45 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{+31}:\\
\;\;\;\;\frac{x - z \cdot y}{t}\\
\mathbf{elif}\;a \leq 2.5 \cdot 10^{+175}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if a < -1.44999999999999995e-30 or 1.40000000000000008e31 < a < 2.5e175Initial program 88.7%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-*.f6465.6
Applied rewrites65.6%
if -1.44999999999999995e-30 < a < 1.40000000000000008e31Initial program 95.4%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6471.7
Applied rewrites71.7%
if 2.5e175 < a Initial program 61.7%
Taylor expanded in z around inf
lower-/.f6462.4
Applied rewrites62.4%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.4e+47) (/ (- x (* z y)) t) (if (<= t 7.2e-10) (/ (- y (/ x z)) a) (/ (fma (- z) y x) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.4e+47) {
tmp = (x - (z * y)) / t;
} else if (t <= 7.2e-10) {
tmp = (y - (x / z)) / a;
} else {
tmp = fma(-z, y, x) / t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.4e+47) tmp = Float64(Float64(x - Float64(z * y)) / t); elseif (t <= 7.2e-10) tmp = Float64(Float64(y - Float64(x / z)) / a); else tmp = Float64(fma(Float64(-z), y, x) / t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.4e+47], N[(N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, 7.2e-10], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[((-z) * y + x), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.4 \cdot 10^{+47}:\\
\;\;\;\;\frac{x - z \cdot y}{t}\\
\mathbf{elif}\;t \leq 7.2 \cdot 10^{-10}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-z, y, x\right)}{t}\\
\end{array}
\end{array}
if t < -1.39999999999999994e47Initial program 89.1%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
if -1.39999999999999994e47 < t < 7.2e-10Initial program 90.2%
Taylor expanded in t around 0
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
div-subN/A
sub-negN/A
distribute-lft-inN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
neg-mul-1N/A
remove-double-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6472.6
Applied rewrites72.6%
if 7.2e-10 < t Initial program 86.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6476.0
Applied rewrites76.0%
Applied rewrites76.0%
(FPCore (x y z t a) :precision binary64 (if (<= z -8.2e+97) (/ y a) (if (<= z 3.4e-23) (/ x (- t (* a z))) (* (/ z (fma a z (- t))) y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -8.2e+97) {
tmp = y / a;
} else if (z <= 3.4e-23) {
tmp = x / (t - (a * z));
} else {
tmp = (z / fma(a, z, -t)) * y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -8.2e+97) tmp = Float64(y / a); elseif (z <= 3.4e-23) tmp = Float64(x / Float64(t - Float64(a * z))); else tmp = Float64(Float64(z / fma(a, z, Float64(-t))) * y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -8.2e+97], N[(y / a), $MachinePrecision], If[LessEqual[z, 3.4e-23], N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(a * z + (-t)), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+97}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\mathsf{fma}\left(a, z, -t\right)} \cdot y\\
\end{array}
\end{array}
if z < -8.19999999999999977e97Initial program 65.7%
Taylor expanded in z around inf
lower-/.f6476.9
Applied rewrites76.9%
if -8.19999999999999977e97 < z < 3.4000000000000001e-23Initial program 97.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-*.f6470.2
Applied rewrites70.2%
if 3.4000000000000001e-23 < z Initial program 79.4%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
associate-*r*N/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6457.8
Applied rewrites57.8%
Applied rewrites69.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -8.2e+97) (/ y a) (if (<= z 3.2e-23) (/ x (- t (* a z))) (* (/ y (fma a z (- t))) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -8.2e+97) {
tmp = y / a;
} else if (z <= 3.2e-23) {
tmp = x / (t - (a * z));
} else {
tmp = (y / fma(a, z, -t)) * z;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -8.2e+97) tmp = Float64(y / a); elseif (z <= 3.2e-23) tmp = Float64(x / Float64(t - Float64(a * z))); else tmp = Float64(Float64(y / fma(a, z, Float64(-t))) * z); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -8.2e+97], N[(y / a), $MachinePrecision], If[LessEqual[z, 3.2e-23], N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(a * z + (-t)), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+97}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(a, z, -t\right)} \cdot z\\
\end{array}
\end{array}
if z < -8.19999999999999977e97Initial program 65.7%
Taylor expanded in z around inf
lower-/.f6476.9
Applied rewrites76.9%
if -8.19999999999999977e97 < z < 3.19999999999999976e-23Initial program 97.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-*.f6470.2
Applied rewrites70.2%
if 3.19999999999999976e-23 < z Initial program 79.4%
Taylor expanded in x around 0
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
associate-*r*N/A
distribute-lft-neg-outN/A
mul-1-negN/A
remove-double-negN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6457.8
Applied rewrites57.8%
Applied rewrites65.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -3.2e+169) (/ (- y (/ x z)) a) (/ (- x (* z y)) (- t (* a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.2e+169) {
tmp = (y - (x / z)) / a;
} else {
tmp = (x - (z * y)) / (t - (a * z));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: tmp
if (z <= (-3.2d+169)) then
tmp = (y - (x / z)) / a
else
tmp = (x - (z * y)) / (t - (a * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.2e+169) {
tmp = (y - (x / z)) / a;
} else {
tmp = (x - (z * y)) / (t - (a * z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -3.2e+169: tmp = (y - (x / z)) / a else: tmp = (x - (z * y)) / (t - (a * z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.2e+169) tmp = Float64(Float64(y - Float64(x / z)) / a); else tmp = Float64(Float64(x - Float64(z * y)) / Float64(t - Float64(a * z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -3.2e+169) tmp = (y - (x / z)) / a; else tmp = (x - (z * y)) / (t - (a * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.2e+169], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+169}:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - z \cdot y}{t - a \cdot z}\\
\end{array}
\end{array}
if z < -3.1999999999999998e169Initial program 57.3%
Taylor expanded in t around 0
associate-*r/N/A
*-commutativeN/A
associate-/r*N/A
associate-*r/N/A
lower-/.f64N/A
div-subN/A
sub-negN/A
distribute-lft-inN/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
neg-mul-1N/A
remove-double-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6492.5
Applied rewrites92.5%
if -3.1999999999999998e169 < z Initial program 92.4%
Final simplification92.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -8.2e+97) (/ y a) (if (<= z 5.5e-23) (/ x (- t (* a z))) (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -8.2e+97) {
tmp = y / a;
} else if (z <= 5.5e-23) {
tmp = x / (t - (a * z));
} else {
tmp = y / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: tmp
if (z <= (-8.2d+97)) then
tmp = y / a
else if (z <= 5.5d-23) then
tmp = x / (t - (a * z))
else
tmp = y / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -8.2e+97) {
tmp = y / a;
} else if (z <= 5.5e-23) {
tmp = x / (t - (a * z));
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -8.2e+97: tmp = y / a elif z <= 5.5e-23: tmp = x / (t - (a * z)) else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -8.2e+97) tmp = Float64(y / a); elseif (z <= 5.5e-23) tmp = Float64(x / Float64(t - Float64(a * z))); else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -8.2e+97) tmp = y / a; elseif (z <= 5.5e-23) tmp = x / (t - (a * z)); else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -8.2e+97], N[(y / a), $MachinePrecision], If[LessEqual[z, 5.5e-23], N[(x / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+97}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{t - a \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -8.19999999999999977e97 or 5.5000000000000001e-23 < z Initial program 74.7%
Taylor expanded in z around inf
lower-/.f6456.9
Applied rewrites56.9%
if -8.19999999999999977e97 < z < 5.5000000000000001e-23Initial program 97.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-*.f6470.2
Applied rewrites70.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.05e+47) (/ y a) (if (<= z 1.3e-31) (/ x t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.05e+47) {
tmp = y / a;
} else if (z <= 1.3e-31) {
tmp = x / t;
} else {
tmp = y / a;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: tmp
if (z <= (-1.05d+47)) then
tmp = y / a
else if (z <= 1.3d-31) then
tmp = x / t
else
tmp = y / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.05e+47) {
tmp = y / a;
} else if (z <= 1.3e-31) {
tmp = x / t;
} else {
tmp = y / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.05e+47: tmp = y / a elif z <= 1.3e-31: tmp = x / t else: tmp = y / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.05e+47) tmp = Float64(y / a); elseif (z <= 1.3e-31) tmp = Float64(x / t); else tmp = Float64(y / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.05e+47) tmp = y / a; elseif (z <= 1.3e-31) tmp = x / t; else tmp = y / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.05e+47], N[(y / a), $MachinePrecision], If[LessEqual[z, 1.3e-31], N[(x / t), $MachinePrecision], N[(y / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+47}:\\
\;\;\;\;\frac{y}{a}\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-31}:\\
\;\;\;\;\frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a}\\
\end{array}
\end{array}
if z < -1.05e47 or 1.29999999999999998e-31 < z Initial program 76.9%
Taylor expanded in z around inf
lower-/.f6453.0
Applied rewrites53.0%
if -1.05e47 < z < 1.29999999999999998e-31Initial program 99.0%
Taylor expanded in z around 0
lower-/.f6451.3
Applied rewrites51.3%
(FPCore (x y z t a) :precision binary64 (/ x t))
double code(double x, double y, double z, double t, double a) {
return x / t;
}
real(8) function code(x, y, z, t, a)
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
code = x / t
end function
public static double code(double x, double y, double z, double t, double a) {
return x / t;
}
def code(x, y, z, t, a): return x / t
function code(x, y, z, t, a) return Float64(x / t) end
function tmp = code(x, y, z, t, a) tmp = x / t; end
code[x_, y_, z_, t_, a_] := N[(x / t), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{t}
\end{array}
Initial program 88.9%
Taylor expanded in z around 0
lower-/.f6434.2
Applied rewrites34.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* a z))) (t_2 (- (/ x t_1) (/ y (- (/ t z) a)))))
(if (< z -32113435955957344.0)
t_2
(if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 t_1)) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = (x / t_1) - (y / ((t / z) - a));
double tmp;
if (z < -32113435955957344.0) {
tmp = t_2;
} else if (z < 3.5139522372978296e-86) {
tmp = (x - (y * z)) * (1.0 / t_1);
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = t - (a * z)
t_2 = (x / t_1) - (y / ((t / z) - a))
if (z < (-32113435955957344.0d0)) then
tmp = t_2
else if (z < 3.5139522372978296d-86) then
tmp = (x - (y * z)) * (1.0d0 / t_1)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t - (a * z);
double t_2 = (x / t_1) - (y / ((t / z) - a));
double tmp;
if (z < -32113435955957344.0) {
tmp = t_2;
} else if (z < 3.5139522372978296e-86) {
tmp = (x - (y * z)) * (1.0 / t_1);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - (a * z) t_2 = (x / t_1) - (y / ((t / z) - a)) tmp = 0 if z < -32113435955957344.0: tmp = t_2 elif z < 3.5139522372978296e-86: tmp = (x - (y * z)) * (1.0 / t_1) else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(a * z)) t_2 = Float64(Float64(x / t_1) - Float64(y / Float64(Float64(t / z) - a))) tmp = 0.0 if (z < -32113435955957344.0) tmp = t_2; elseif (z < 3.5139522372978296e-86) tmp = Float64(Float64(x - Float64(y * z)) * Float64(1.0 / t_1)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - (a * z); t_2 = (x / t_1) - (y / ((t / z) - a)); tmp = 0.0; if (z < -32113435955957344.0) tmp = t_2; elseif (z < 3.5139522372978296e-86) tmp = (x - (y * z)) * (1.0 / t_1); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / t$95$1), $MachinePrecision] - N[(y / N[(N[(t / z), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -32113435955957344.0], t$95$2, If[Less[z, 3.5139522372978296e-86], N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(1.0 / t$95$1), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - a \cdot z\\
t_2 := \frac{x}{t\_1} - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z < -32113435955957344:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z < 3.5139522372978296 \cdot 10^{-86}:\\
\;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
herbie shell --seed 2024295
(FPCore (x y z t a)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< z -32113435955957344) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 4392440296622287/125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (- x (* y z)) (/ 1 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))))))
(/ (- x (* y z)) (- t (* a z))))