
(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 13 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 -4e+101) (* (- (/ y z) 1.0) x) (if (<= z 2e+16) (/ (fma (- y z) x x) z) (- (* (/ y z) x) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4e+101) {
tmp = ((y / z) - 1.0) * x;
} else if (z <= 2e+16) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = ((y / z) * x) - x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -4e+101) tmp = Float64(Float64(Float64(y / z) - 1.0) * x); elseif (z <= 2e+16) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(Float64(y / z) * x) - x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -4e+101], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 2e+16], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+101}:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot x\\
\mathbf{elif}\;z \leq 2 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x - x\\
\end{array}
\end{array}
if z < -3.9999999999999999e101Initial program 58.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/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%
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-+.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
lower-/.f64100.0
Applied rewrites100.0%
if -3.9999999999999999e101 < z < 2e16Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
if 2e16 < z Initial program 78.5%
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%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
neg-mul-1N/A
unsub-negN/A
lower--.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (* (- (/ y z) 1.0) x) (if (<= z 3.6e-7) (/ (fma y x x) z) (- (* (/ y z) x) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = ((y / z) - 1.0) * x;
} else if (z <= 3.6e-7) {
tmp = fma(y, x, x) / z;
} else {
tmp = ((y / z) * x) - x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(Float64(Float64(y / z) - 1.0) * x); elseif (z <= 3.6e-7) tmp = Float64(fma(y, x, x) / z); else tmp = Float64(Float64(Float64(y / z) * x) - x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.0], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 3.6e-7], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot x\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x - x\\
\end{array}
\end{array}
if z < -1Initial program 75.1%
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-/.f6497.3
Applied rewrites97.3%
if -1 < z < 3.59999999999999994e-7Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.3
Applied rewrites99.3%
if 3.59999999999999994e-7 < z Initial program 80.5%
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-/.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
unsub-negN/A
lower--.f64N/A
lower-*.f6497.8
Applied rewrites97.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- (/ y z) 1.0) x))) (if (<= z -1.0) t_0 (if (<= z 3.6e-7) (/ (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 <= -1.0) {
tmp = t_0;
} else if (z <= 3.6e-7) {
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 <= -1.0) tmp = t_0; elseif (z <= 3.6e-7) 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, -1.0], t$95$0, If[LessEqual[z, 3.6e-7], 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 -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 3.59999999999999994e-7 < z Initial program 77.8%
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-/.f6497.5
Applied rewrites97.5%
if -1 < z < 3.59999999999999994e-7Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.3
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (if (<= z -3600.0) (- (/ x z) x) (if (<= z 3.7e+33) (/ (fma y x x) z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3600.0) {
tmp = (x / z) - x;
} else if (z <= 3.7e+33) {
tmp = fma(y, x, x) / z;
} else {
tmp = -x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3600.0) tmp = Float64(Float64(x / z) - x); elseif (z <= 3.7e+33) tmp = Float64(fma(y, x, x) / z); else tmp = Float64(-x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3600.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 3.7e+33], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3600:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+33}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -3600Initial program 75.1%
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-/.f6478.5
Applied rewrites78.5%
if -3600 < z < 3.6999999999999999e33Initial program 99.8%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6494.4
Applied rewrites94.4%
if 3.6999999999999999e33 < z Initial program 76.4%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6482.2
Applied rewrites82.2%
(FPCore (x y z) :precision binary64 (if (<= y -300000000000.0) (/ (* y x) z) (if (<= y 2.25e+66) (- (/ x z) x) (* (/ y z) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -300000000000.0) {
tmp = (y * x) / z;
} else if (y <= 2.25e+66) {
tmp = (x / z) - x;
} else {
tmp = (y / z) * 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 (y <= (-300000000000.0d0)) then
tmp = (y * x) / z
else if (y <= 2.25d+66) then
tmp = (x / z) - x
else
tmp = (y / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -300000000000.0) {
tmp = (y * x) / z;
} else if (y <= 2.25e+66) {
tmp = (x / z) - x;
} else {
tmp = (y / z) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -300000000000.0: tmp = (y * x) / z elif y <= 2.25e+66: tmp = (x / z) - x else: tmp = (y / z) * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -300000000000.0) tmp = Float64(Float64(y * x) / z); elseif (y <= 2.25e+66) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(y / z) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -300000000000.0) tmp = (y * x) / z; elseif (y <= 2.25e+66) tmp = (x / z) - x; else tmp = (y / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -300000000000.0], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 2.25e+66], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -300000000000:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+66}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if y < -3e11Initial program 85.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6469.3
Applied rewrites69.3%
if -3e11 < y < 2.2499999999999999e66Initial program 88.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-/.f6496.8
Applied rewrites96.8%
if 2.2499999999999999e66 < y Initial program 85.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.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--.f6497.8
Applied rewrites97.8%
Taylor expanded in y around inf
lower-/.f6475.1
Applied rewrites75.1%
(FPCore (x y z) :precision binary64 (if (<= y -300000000000.0) (* (/ x z) y) (if (<= y 2.25e+66) (- (/ x z) x) (* (/ y z) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -300000000000.0) {
tmp = (x / z) * y;
} else if (y <= 2.25e+66) {
tmp = (x / z) - x;
} else {
tmp = (y / z) * 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 (y <= (-300000000000.0d0)) then
tmp = (x / z) * y
else if (y <= 2.25d+66) then
tmp = (x / z) - x
else
tmp = (y / z) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -300000000000.0) {
tmp = (x / z) * y;
} else if (y <= 2.25e+66) {
tmp = (x / z) - x;
} else {
tmp = (y / z) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -300000000000.0: tmp = (x / z) * y elif y <= 2.25e+66: tmp = (x / z) - x else: tmp = (y / z) * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -300000000000.0) tmp = Float64(Float64(x / z) * y); elseif (y <= 2.25e+66) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(y / z) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -300000000000.0) tmp = (x / z) * y; elseif (y <= 2.25e+66) tmp = (x / z) - x; else tmp = (y / z) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -300000000000.0], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 2.25e+66], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -300000000000:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+66}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if y < -3e11Initial program 85.8%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6464.9
Applied rewrites64.9%
if -3e11 < y < 2.2499999999999999e66Initial program 88.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-/.f6496.8
Applied rewrites96.8%
if 2.2499999999999999e66 < y Initial program 85.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6497.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--.f6497.8
Applied rewrites97.8%
Taylor expanded in y around inf
lower-/.f6475.1
Applied rewrites75.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ x z) y))) (if (<= y -300000000000.0) t_0 (if (<= y 5.4e+65) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -300000000000.0) {
tmp = t_0;
} else if (y <= 5.4e+65) {
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 <= (-300000000000.0d0)) then
tmp = t_0
else if (y <= 5.4d+65) 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 <= -300000000000.0) {
tmp = t_0;
} else if (y <= 5.4e+65) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if y <= -300000000000.0: tmp = t_0 elif y <= 5.4e+65: 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 <= -300000000000.0) tmp = t_0; elseif (y <= 5.4e+65) 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 <= -300000000000.0) tmp = t_0; elseif (y <= 5.4e+65) 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, -300000000000.0], t$95$0, If[LessEqual[y, 5.4e+65], 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 -300000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3e11 or 5.40000000000000038e65 < y Initial program 85.7%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6467.5
Applied rewrites67.5%
if -3e11 < y < 5.40000000000000038e65Initial program 88.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-/.f6496.8
Applied rewrites96.8%
(FPCore (x y z) :precision binary64 (if (<= x 1e-121) (/ (fma (- y z) x x) z) (fma (/ (- y -1.0) z) x (- x))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1e-121) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = fma(((y - -1.0) / z), x, -x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 1e-121) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = fma(Float64(Float64(y - -1.0) / z), x, Float64(-x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 1e-121], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y - -1.0), $MachinePrecision] / z), $MachinePrecision] * x + (-x)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-121}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - -1}{z}, x, -x\right)\\
\end{array}
\end{array}
if x < 9.9999999999999998e-122Initial program 89.0%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6489.0
Applied rewrites89.0%
if 9.9999999999999998e-122 < x Initial program 82.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%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
neg-mul-1N/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lift--.f64N/A
lower-neg.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= x 82000000.0) (/ (fma (- y z) x x) z) (* (/ (- (- y z) -1.0) z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 82000000.0) {
tmp = fma((y - z), x, x) / z;
} else {
tmp = (((y - z) - -1.0) / z) * x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 82000000.0) tmp = Float64(fma(Float64(y - z), x, x) / z); else tmp = Float64(Float64(Float64(Float64(y - z) - -1.0) / z) * x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 82000000.0], N[(N[(N[(y - z), $MachinePrecision] * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(N[(y - z), $MachinePrecision] - -1.0), $MachinePrecision] / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 82000000:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y - z\right) - -1}{z} \cdot x\\
\end{array}
\end{array}
if x < 8.2e7Initial program 90.3%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6490.3
Applied rewrites90.3%
if 8.2e7 < x Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/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 (<= x 82000000.0) (/ (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 <= 82000000.0) {
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 <= 82000000.0) 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, 82000000.0], 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 82000000:\\
\;\;\;\;\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 < 8.2e7Initial program 90.3%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6490.3
Applied rewrites90.3%
if 8.2e7 < x Initial program 76.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/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%
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-+.f64100.0
Applied rewrites100.0%
(FPCore (x y z) :precision binary64 (if (<= z -4.2e-37) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e-37) {
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 <= (-4.2d-37)) 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 <= -4.2e-37) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e-37: tmp = -x elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e-37) 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 <= -4.2e-37) tmp = -x; elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e-37], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-37}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.2000000000000002e-37 or 1 < z Initial program 78.1%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6473.7
Applied rewrites73.7%
if -4.2000000000000002e-37 < z < 1Initial program 99.8%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
mul-1-negN/A
unsub-negN/A
*-rgt-identityN/A
distribute-lft-out--N/A
associate-/l*N/A
div-subN/A
*-inversesN/A
distribute-lft-out--N/A
associate-/l*N/A
*-rgt-identityN/A
*-rgt-identityN/A
lower--.f64N/A
lower-/.f6458.0
Applied rewrites58.0%
Taylor expanded in z around 0
Applied rewrites57.4%
(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.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-/.f6468.7
Applied rewrites68.7%
(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.0%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6444.8
Applied rewrites44.8%
(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 2024240
(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))