
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -2e+20) (fma (/ y z) x (- x)) (if (<= z 1.25e+16) (/ (fma (- y z) x x) z) (* (- (/ y z) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+20) {
tmp = fma((y / z), x, -x);
} else if (z <= 1.25e+16) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = ((y / z) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -2e+20) tmp = fma(Float64(y / z), x, Float64(-x)); elseif (z <= 1.25e+16) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(Float64(y / z) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -2e+20], N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision], If[LessEqual[z, 1.25e+16], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot x\\
\end{array}
\end{array}
if z < -2e20Initial program 71.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
lower-/.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-fma.f6499.9
Applied rewrites99.9%
if -2e20 < z < 1.25e16Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.8
Applied rewrites99.8%
if 1.25e16 < z Initial program 72.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
lower-/.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= x 8e-58) (/ (fma y x (fma (- x) z x)) z) (/ x (/ z (- (- y z) -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 8e-58) {
tmp = fma(y, x, fma(-x, z, x)) / z;
} else {
tmp = x / (z / ((y - z) - -1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 8e-58) tmp = Float64(fma(y, x, fma(Float64(-x), z, x)) / z); else tmp = Float64(x / Float64(z / Float64(Float64(y - z) - -1.0))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 8e-58], N[(N[(y * x + N[((-x) * z + x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / N[(N[(y - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{-58}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, \mathsf{fma}\left(-x, z, x\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) - -1}}\\
\end{array}
\end{array}
if x < 8.0000000000000002e-58Initial program 91.1%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
*-rgt-identityN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f6491.1
Applied rewrites91.1%
if 8.0000000000000002e-58 < x Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f64100.0
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= z -5.3) (fma (/ y z) x (- x)) (if (<= z 1.0) (/ (fma y x x) z) (* (- (/ y z) 1.0) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.3) {
tmp = fma((y / z), x, -x);
} else if (z <= 1.0) {
tmp = fma(y, x, x) / z;
} else {
tmp = ((y / z) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -5.3) tmp = fma(Float64(y / z), x, Float64(-x)); elseif (z <= 1.0) tmp = Float64(fma(y, x, x) / z); else tmp = Float64(Float64(Float64(y / z) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -5.3], N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot x\\
\end{array}
\end{array}
if z < -5.29999999999999982Initial program 74.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.8
Applied rewrites99.8%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
lower-/.f6497.7
Applied rewrites97.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
neg-mul-1N/A
lift-neg.f64N/A
lower-fma.f6497.7
Applied rewrites97.7%
if -5.29999999999999982 < z < 1Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6498.6
Applied rewrites98.6%
if 1 < z Initial program 73.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
lower-/.f6498.5
Applied rewrites98.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- (/ y z) 1.0) x))) (if (<= z -5.3) t_0 (if (<= z 1.0) (/ (fma y x x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y / z) - 1.0) * x;
double tmp;
if (z <= -5.3) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = fma(y, x, x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(Float64(y / z) - 1.0) * x) tmp = 0.0 if (z <= -5.3) tmp = t_0; elseif (z <= 1.0) tmp = Float64(fma(y, x, x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -5.3], t$95$0, If[LessEqual[z, 1.0], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{y}{z} - 1\right) \cdot x\\
\mathbf{if}\;z \leq -5.3:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.29999999999999982 or 1 < z Initial program 74.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
lower-/.f6498.1
Applied rewrites98.1%
if -5.29999999999999982 < z < 1Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6498.6
Applied rewrites98.6%
(FPCore (x y z) :precision binary64 (if (<= x 1.26e-45) (/ (fma y x (fma (- x) z x)) z) (* (- (/ (+ 1.0 y) z) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.26e-45) {
tmp = fma(y, x, fma(-x, z, x)) / z;
} else {
tmp = (((1.0 + y) / z) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.26e-45) tmp = Float64(fma(y, x, fma(Float64(-x), z, x)) / z); else tmp = Float64(Float64(Float64(Float64(1.0 + y) / z) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.26e-45], N[(N[(y * x + N[((-x) * z + x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.26 \cdot 10^{-45}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, \mathsf{fma}\left(-x, z, x\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1 + y}{z} - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.26e-45Initial program 91.1%
lift-*.f64N/A
lift-+.f64N/A
distribute-lft-inN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
*-rgt-identityN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-neg.f6491.1
Applied rewrites91.1%
if 1.26e-45 < x Initial program 77.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= y -9500000000000.0) (* (/ x z) y) (if (<= y 0.0098) (- (/ x z) x) (/ (fma y x x) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9500000000000.0) {
tmp = (x / z) * y;
} else if (y <= 0.0098) {
tmp = (x / z) - x;
} else {
tmp = fma(y, x, x) / z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -9500000000000.0) tmp = Float64(Float64(x / z) * y); elseif (y <= 0.0098) tmp = Float64(Float64(x / z) - x); else tmp = Float64(fma(y, x, x) / z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -9500000000000.0], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 0.0098], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9500000000000:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{elif}\;y \leq 0.0098:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\end{array}
\end{array}
if y < -9.5e12Initial program 87.1%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6477.6
Applied rewrites77.6%
if -9.5e12 < y < 0.0097999999999999997Initial program 85.8%
Taylor expanded in y around 0
associate-/l*N/A
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
associate-/l*N/A
*-rgt-identityN/A
*-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if 0.0097999999999999997 < y Initial program 91.2%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6476.2
Applied rewrites76.2%
(FPCore (x y z) :precision binary64 (if (<= y -9500000000000.0) (* (/ x z) y) (if (<= y 2.7e+103) (- (/ x z) x) (/ (* y x) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9500000000000.0) {
tmp = (x / z) * y;
} else if (y <= 2.7e+103) {
tmp = (x / z) - x;
} else {
tmp = (y * x) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-9500000000000.0d0)) then
tmp = (x / z) * y
else if (y <= 2.7d+103) then
tmp = (x / z) - x
else
tmp = (y * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9500000000000.0) {
tmp = (x / z) * y;
} else if (y <= 2.7e+103) {
tmp = (x / z) - x;
} else {
tmp = (y * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9500000000000.0: tmp = (x / z) * y elif y <= 2.7e+103: tmp = (x / z) - x else: tmp = (y * x) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9500000000000.0) tmp = Float64(Float64(x / z) * y); elseif (y <= 2.7e+103) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(y * x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9500000000000.0) tmp = (x / z) * y; elseif (y <= 2.7e+103) tmp = (x / z) - x; else tmp = (y * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9500000000000.0], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.7e+103], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9500000000000:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+103}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\end{array}
\end{array}
if y < -9.5e12Initial program 87.1%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6477.6
Applied rewrites77.6%
if -9.5e12 < y < 2.69999999999999993e103Initial program 85.9%
Taylor expanded in y around 0
associate-/l*N/A
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
associate-/l*N/A
*-rgt-identityN/A
*-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6495.6
Applied rewrites95.6%
if 2.69999999999999993e103 < y Initial program 92.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6483.9
Applied rewrites83.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ x z) y))) (if (<= y -9500000000000.0) t_0 (if (<= y 5.6e+41) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -9500000000000.0) {
tmp = t_0;
} else if (y <= 5.6e+41) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x / z) * y
if (y <= (-9500000000000.0d0)) then
tmp = t_0
else if (y <= 5.6d+41) then
tmp = (x / z) - x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -9500000000000.0) {
tmp = t_0;
} else if (y <= 5.6e+41) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if y <= -9500000000000.0: tmp = t_0 elif y <= 5.6e+41: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) * y) tmp = 0.0 if (y <= -9500000000000.0) tmp = t_0; elseif (y <= 5.6e+41) tmp = Float64(Float64(x / z) - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) * y; tmp = 0.0; if (y <= -9500000000000.0) tmp = t_0; elseif (y <= 5.6e+41) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -9500000000000.0], t$95$0, If[LessEqual[y, 5.6e+41], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;y \leq -9500000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+41}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.5e12 or 5.5999999999999999e41 < y Initial program 88.9%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6476.1
Applied rewrites76.1%
if -9.5e12 < y < 5.5999999999999999e41Initial program 86.0%
Taylor expanded in y around 0
associate-/l*N/A
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
associate-/l*N/A
*-rgt-identityN/A
*-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6499.2
Applied rewrites99.2%
(FPCore (x y z) :precision binary64 (if (<= x 1.26e-45) (/ (fma (- y z) x x) z) (* (- (/ (+ 1.0 y) z) 1.0) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.26e-45) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = (((1.0 + y) / z) - 1.0) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1.26e-45) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(Float64(Float64(1.0 + y) / z) - 1.0) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1.26e-45], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.26 \cdot 10^{-45}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1 + y}{z} - 1\right) \cdot x\\
\end{array}
\end{array}
if x < 1.26e-45Initial program 91.1%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6491.1
Applied rewrites91.1%
if 1.26e-45 < x Initial program 77.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.9
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
lift--.f64N/A
associate-+r-N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 1.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 1.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 74.5%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6474.3
Applied rewrites74.3%
if -1 < z < 1Initial program 99.8%
Taylor expanded in y around 0
associate-/l*N/A
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
associate-/l*N/A
*-rgt-identityN/A
*-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6457.3
Applied rewrites57.3%
Taylor expanded in z around 0
Applied rewrites56.2%
(FPCore (x y z) :precision binary64 (- (/ x z) x))
double code(double x, double y, double z) {
return (x / z) - x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / z) - x
end function
public static double code(double x, double y, double z) {
return (x / z) - x;
}
def code(x, y, z): return (x / z) - x
function code(x, y, z) return Float64(Float64(x / z) - x) end
function tmp = code(x, y, z) tmp = (x / z) - x; end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} - x
\end{array}
Initial program 87.3%
Taylor expanded in y around 0
associate-/l*N/A
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
associate-/l*N/A
*-rgt-identityN/A
*-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6466.6
Applied rewrites66.6%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 87.3%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6438.2
Applied rewrites38.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024242
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))