
(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 10 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 (let* ((t_0 (* (- (/ y z) 1.0) x))) (if (<= z -2e+28) t_0 (if (<= z 1.05e+17) (/ (fma (- y z) 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 <= -2e+28) {
tmp = t_0;
} else if (z <= 1.05e+17) {
tmp = fma((y - z), 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 <= -2e+28) tmp = t_0; elseif (z <= 1.05e+17) tmp = Float64(fma(Float64(y - z), 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, -2e+28], t$95$0, If[LessEqual[z, 1.05e+17], N[(N[(N[(y - z), $MachinePrecision] * 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 -2 \cdot 10^{+28}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+17}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y - z, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.99999999999999992e28 or 1.05e17 < z Initial program 75.3%
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%
if -1.99999999999999992e28 < z < 1.05e17Initial program 99.9%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= z -1700.0) (* (- (/ y z) 1.0) x) (if (<= z 1.0) (/ (fma y x x) z) (fma (/ y z) x (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1700.0) {
tmp = ((y / z) - 1.0) * x;
} else if (z <= 1.0) {
tmp = fma(y, x, x) / z;
} else {
tmp = fma((y / z), x, -x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1700.0) tmp = Float64(Float64(Float64(y / z) - 1.0) * x); elseif (z <= 1.0) tmp = Float64(fma(y, x, x) / z); else tmp = fma(Float64(y / z), x, Float64(-x)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1700.0], N[(N[(N[(y / z), $MachinePrecision] - 1.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 1.0], N[(N[(y * x + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x + (-x)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1700:\\
\;\;\;\;\left(\frac{y}{z} - 1\right) \cdot x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, -x\right)\\
\end{array}
\end{array}
if z < -1700Initial program 77.0%
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-/.f6498.2
Applied rewrites98.2%
if -1700 < z < 1Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.1
Applied rewrites99.1%
if 1 < z Initial program 77.2%
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-/.f6499.7
Applied rewrites99.7%
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
lower-neg.f6499.7
Applied rewrites99.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- (/ y z) 1.0) x))) (if (<= z -1700.0) 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 <= -1700.0) {
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 <= -1700.0) 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, -1700.0], 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 -1700:\\
\;\;\;\;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 < -1700 or 1 < z Initial program 77.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-/.f6499.0
Applied rewrites99.0%
if -1700 < z < 1Initial program 99.9%
Taylor expanded in z around 0
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6499.1
Applied rewrites99.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (* y x) z))) (if (<= y -8.6e+17) t_0 (if (<= y 3.8e+56) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (y * x) / z;
double tmp;
if (y <= -8.6e+17) {
tmp = t_0;
} else if (y <= 3.8e+56) {
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 = (y * x) / z
if (y <= (-8.6d+17)) then
tmp = t_0
else if (y <= 3.8d+56) 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 = (y * x) / z;
double tmp;
if (y <= -8.6e+17) {
tmp = t_0;
} else if (y <= 3.8e+56) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * x) / z tmp = 0 if y <= -8.6e+17: tmp = t_0 elif y <= 3.8e+56: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * x) / z) tmp = 0.0 if (y <= -8.6e+17) tmp = t_0; elseif (y <= 3.8e+56) tmp = Float64(Float64(x / z) - x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * x) / z; tmp = 0.0; if (y <= -8.6e+17) tmp = t_0; elseif (y <= 3.8e+56) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -8.6e+17], t$95$0, If[LessEqual[y, 3.8e+56], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot x}{z}\\
\mathbf{if}\;y \leq -8.6 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.6e17 or 3.79999999999999996e56 < y Initial program 89.1%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6477.0
Applied rewrites77.0%
if -8.6e17 < y < 3.79999999999999996e56Initial program 88.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-/.f6496.7
Applied rewrites96.7%
(FPCore (x y z) :precision binary64 (if (<= y -8.6e+17) (* (/ y z) x) (if (<= y 3.8e+56) (- (/ x z) x) (* (/ x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.6e+17) {
tmp = (y / z) * x;
} else if (y <= 3.8e+56) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * y;
}
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 <= (-8.6d+17)) then
tmp = (y / z) * x
else if (y <= 3.8d+56) then
tmp = (x / z) - x
else
tmp = (x / z) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.6e+17) {
tmp = (y / z) * x;
} else if (y <= 3.8e+56) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.6e+17: tmp = (y / z) * x elif y <= 3.8e+56: tmp = (x / z) - x else: tmp = (x / z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.6e+17) tmp = Float64(Float64(y / z) * x); elseif (y <= 3.8e+56) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x / z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.6e+17) tmp = (y / z) * x; elseif (y <= 3.8e+56) tmp = (x / z) - x; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.6e+17], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 3.8e+56], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+17}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -8.6e17Initial program 89.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6495.3
lift-+.f64N/A
lift--.f64N/A
associate-+l-N/A
sub-negN/A
metadata-evalN/A
associate--r+N/A
lift--.f64N/A
lower--.f6495.3
Applied rewrites95.3%
Taylor expanded in y around inf
lower-/.f6473.3
Applied rewrites73.3%
if -8.6e17 < y < 3.79999999999999996e56Initial program 88.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-/.f6496.7
Applied rewrites96.7%
if 3.79999999999999996e56 < y Initial program 89.0%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6478.0
Applied rewrites78.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (/ x z) y))) (if (<= y -8.6e+17) t_0 (if (<= y 3.8e+56) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -8.6e+17) {
tmp = t_0;
} else if (y <= 3.8e+56) {
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 <= (-8.6d+17)) then
tmp = t_0
else if (y <= 3.8d+56) 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 <= -8.6e+17) {
tmp = t_0;
} else if (y <= 3.8e+56) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if y <= -8.6e+17: tmp = t_0 elif y <= 3.8e+56: 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 <= -8.6e+17) tmp = t_0; elseif (y <= 3.8e+56) 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 <= -8.6e+17) tmp = t_0; elseif (y <= 3.8e+56) 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, -8.6e+17], t$95$0, If[LessEqual[y, 3.8e+56], 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 -8.6 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.6e17 or 3.79999999999999996e56 < y Initial program 89.1%
Taylor expanded in y around inf
associate-*l/N/A
lower-*.f64N/A
lower-/.f6475.5
Applied rewrites75.5%
if -8.6e17 < y < 3.79999999999999996e56Initial program 88.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-/.f6496.7
Applied rewrites96.7%
(FPCore (x y z) :precision binary64 (if (<= x 4e-93) (/ (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 <= 4e-93) {
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 <= 4e-93) 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, 4e-93], 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 4 \cdot 10^{-93}:\\
\;\;\;\;\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 < 3.9999999999999996e-93Initial program 90.7%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f6490.7
Applied rewrites90.7%
if 3.9999999999999996e-93 < x Initial program 85.3%
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 -4.2) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2) {
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.2d0)) 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.2) {
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.2: 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.2) 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.2) 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.2], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.20000000000000018 or 1 < z Initial program 77.3%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6470.5
Applied rewrites70.5%
if -4.20000000000000018 < z < 1Initial program 99.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-/.f6454.5
Applied rewrites54.5%
Taylor expanded in z around 0
Applied rewrites53.6%
(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 88.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-/.f6462.7
Applied rewrites62.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 88.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6435.7
Applied rewrites35.7%
(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 2024276
(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))