
(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 9 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 (* x (+ -1.0 (/ (+ y 1.0) z))))) (if (<= z -8e-20) t_0 (if (<= z 1.42e-99) (/ (* x (+ y 1.0)) z) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (-1.0 + ((y + 1.0) / z));
double tmp;
if (z <= -8e-20) {
tmp = t_0;
} else if (z <= 1.42e-99) {
tmp = (x * (y + 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 = x * ((-1.0d0) + ((y + 1.0d0) / z))
if (z <= (-8d-20)) then
tmp = t_0
else if (z <= 1.42d-99) then
tmp = (x * (y + 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 = x * (-1.0 + ((y + 1.0) / z));
double tmp;
if (z <= -8e-20) {
tmp = t_0;
} else if (z <= 1.42e-99) {
tmp = (x * (y + 1.0)) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (-1.0 + ((y + 1.0) / z)) tmp = 0 if z <= -8e-20: tmp = t_0 elif z <= 1.42e-99: tmp = (x * (y + 1.0)) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-1.0 + Float64(Float64(y + 1.0) / z))) tmp = 0.0 if (z <= -8e-20) tmp = t_0; elseif (z <= 1.42e-99) tmp = Float64(Float64(x * Float64(y + 1.0)) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (-1.0 + ((y + 1.0) / z)); tmp = 0.0; if (z <= -8e-20) tmp = t_0; elseif (z <= 1.42e-99) tmp = (x * (y + 1.0)) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(-1.0 + N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8e-20], t$95$0, If[LessEqual[z, 1.42e-99], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-1 + \frac{y + 1}{z}\right)\\
\mathbf{if}\;z \leq -8 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{-99}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -7.99999999999999956e-20 or 1.42e-99 < z Initial program 74.5%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
if -7.99999999999999956e-20 < z < 1.42e-99Initial program 100.0%
Taylor expanded in y around inf
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4.6e+21)
(- 0.0 x)
(if (<= z -9.5e-70)
t_0
(if (<= z -5.5e-301)
(/ x z)
(if (<= z 4.6e-124) t_0 (if (<= z 5.2) (/ x z) (- 0.0 x))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.6e+21) {
tmp = 0.0 - x;
} else if (z <= -9.5e-70) {
tmp = t_0;
} else if (z <= -5.5e-301) {
tmp = x / z;
} else if (z <= 4.6e-124) {
tmp = t_0;
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-4.6d+21)) then
tmp = 0.0d0 - x
else if (z <= (-9.5d-70)) then
tmp = t_0
else if (z <= (-5.5d-301)) then
tmp = x / z
else if (z <= 4.6d-124) then
tmp = t_0
else if (z <= 5.2d0) then
tmp = x / z
else
tmp = 0.0d0 - x
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 (z <= -4.6e+21) {
tmp = 0.0 - x;
} else if (z <= -9.5e-70) {
tmp = t_0;
} else if (z <= -5.5e-301) {
tmp = x / z;
} else if (z <= 4.6e-124) {
tmp = t_0;
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4.6e+21: tmp = 0.0 - x elif z <= -9.5e-70: tmp = t_0 elif z <= -5.5e-301: tmp = x / z elif z <= 4.6e-124: tmp = t_0 elif z <= 5.2: tmp = x / z else: tmp = 0.0 - x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -4.6e+21) tmp = Float64(0.0 - x); elseif (z <= -9.5e-70) tmp = t_0; elseif (z <= -5.5e-301) tmp = Float64(x / z); elseif (z <= 4.6e-124) tmp = t_0; elseif (z <= 5.2) tmp = Float64(x / z); else tmp = Float64(0.0 - x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -4.6e+21) tmp = 0.0 - x; elseif (z <= -9.5e-70) tmp = t_0; elseif (z <= -5.5e-301) tmp = x / z; elseif (z <= 4.6e-124) tmp = t_0; elseif (z <= 5.2) tmp = x / z; else tmp = 0.0 - x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e+21], N[(0.0 - x), $MachinePrecision], If[LessEqual[z, -9.5e-70], t$95$0, If[LessEqual[z, -5.5e-301], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.6e-124], t$95$0, If[LessEqual[z, 5.2], N[(x / z), $MachinePrecision], N[(0.0 - x), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{+21}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-70}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.2:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;0 - x\\
\end{array}
\end{array}
if z < -4.6e21 or 5.20000000000000018 < z Initial program 68.5%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.7%
Simplified76.7%
sub0-negN/A
neg-lowering-neg.f6476.7%
Applied egg-rr76.7%
if -4.6e21 < z < -9.4999999999999994e-70 or -5.50000000000000005e-301 < z < 4.60000000000000024e-124Initial program 99.9%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
/-lowering-/.f6499.8%
Applied egg-rr99.8%
Taylor expanded in y around inf
Simplified68.4%
if -9.4999999999999994e-70 < z < -5.50000000000000005e-301 or 4.60000000000000024e-124 < z < 5.20000000000000018Initial program 100.0%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval97.4%
Simplified97.4%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6468.7%
Simplified68.7%
Taylor expanded in z around 0
/-lowering-/.f6468.4%
Simplified68.4%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (<= z -3.6e+22) (- 0.0 x) (if (<= z -1.95e-70) (* x (/ y z)) (if (<= z 5.2) (/ x z) (- 0.0 x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.6e+22) {
tmp = 0.0 - x;
} else if (z <= -1.95e-70) {
tmp = x * (y / z);
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - 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 <= (-3.6d+22)) then
tmp = 0.0d0 - x
else if (z <= (-1.95d-70)) then
tmp = x * (y / z)
else if (z <= 5.2d0) then
tmp = x / z
else
tmp = 0.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.6e+22) {
tmp = 0.0 - x;
} else if (z <= -1.95e-70) {
tmp = x * (y / z);
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.6e+22: tmp = 0.0 - x elif z <= -1.95e-70: tmp = x * (y / z) elif z <= 5.2: tmp = x / z else: tmp = 0.0 - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.6e+22) tmp = Float64(0.0 - x); elseif (z <= -1.95e-70) tmp = Float64(x * Float64(y / z)); elseif (z <= 5.2) tmp = Float64(x / z); else tmp = Float64(0.0 - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.6e+22) tmp = 0.0 - x; elseif (z <= -1.95e-70) tmp = x * (y / z); elseif (z <= 5.2) tmp = x / z; else tmp = 0.0 - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.6e+22], N[(0.0 - x), $MachinePrecision], If[LessEqual[z, -1.95e-70], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.2], N[(x / z), $MachinePrecision], N[(0.0 - x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{+22}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;z \leq -1.95 \cdot 10^{-70}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 5.2:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;0 - x\\
\end{array}
\end{array}
if z < -3.6e22 or 5.20000000000000018 < z Initial program 68.5%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.7%
Simplified76.7%
sub0-negN/A
neg-lowering-neg.f6476.7%
Applied egg-rr76.7%
if -3.6e22 < z < -1.9500000000000001e-70Initial program 99.8%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval94.5%
Simplified94.5%
Taylor expanded in y around inf
/-lowering-/.f6457.1%
Simplified57.1%
if -1.9500000000000001e-70 < z < 5.20000000000000018Initial program 100.0%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval92.2%
Simplified92.2%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6461.2%
Simplified61.2%
Taylor expanded in z around 0
/-lowering-/.f6461.1%
Simplified61.1%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (<= z -6.5e+20) (- 0.0 x) (if (<= z 3400.0) (/ (* x (+ y 1.0)) z) (- (/ x z) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+20) {
tmp = 0.0 - x;
} else if (z <= 3400.0) {
tmp = (x * (y + 1.0)) / z;
} else {
tmp = (x / 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 (z <= (-6.5d+20)) then
tmp = 0.0d0 - x
else if (z <= 3400.0d0) then
tmp = (x * (y + 1.0d0)) / z
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+20) {
tmp = 0.0 - x;
} else if (z <= 3400.0) {
tmp = (x * (y + 1.0)) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.5e+20: tmp = 0.0 - x elif z <= 3400.0: tmp = (x * (y + 1.0)) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.5e+20) tmp = Float64(0.0 - x); elseif (z <= 3400.0) tmp = Float64(Float64(x * Float64(y + 1.0)) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.5e+20) tmp = 0.0 - x; elseif (z <= 3400.0) tmp = (x * (y + 1.0)) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.5e+20], N[(0.0 - x), $MachinePrecision], If[LessEqual[z, 3400.0], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+20}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;z \leq 3400:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if z < -6.5e20Initial program 63.8%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6480.1%
Simplified80.1%
sub0-negN/A
neg-lowering-neg.f6480.1%
Applied egg-rr80.1%
if -6.5e20 < z < 3400Initial program 99.9%
Taylor expanded in y around inf
Simplified98.9%
if 3400 < z Initial program 74.1%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6473.5%
Simplified73.5%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (<= y -116.0) (/ (* x y) z) (if (<= y 8.4e+17) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -116.0) {
tmp = (x * y) / z;
} else if (y <= 8.4e+17) {
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 <= (-116.0d0)) then
tmp = (x * y) / z
else if (y <= 8.4d+17) 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 <= -116.0) {
tmp = (x * y) / z;
} else if (y <= 8.4e+17) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -116.0: tmp = (x * y) / z elif y <= 8.4e+17: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -116.0) tmp = Float64(Float64(x * y) / z); elseif (y <= 8.4e+17) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -116.0) tmp = (x * y) / z; elseif (y <= 8.4e+17) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -116.0], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 8.4e+17], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -116:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 8.4 \cdot 10^{+17}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -116Initial program 87.7%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval92.3%
Simplified92.3%
Taylor expanded in y around inf
/-lowering-/.f64N/A
*-lowering-*.f6474.7%
Simplified74.7%
if -116 < y < 8.4e17Initial program 84.7%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6496.7%
Simplified96.7%
if 8.4e17 < y Initial program 87.6%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
/-lowering-/.f6492.9%
Applied egg-rr92.9%
Taylor expanded in y around inf
Simplified77.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (/ x z)))) (if (<= y -6600.0) t_0 (if (<= y 1.15e+28) (- (/ x z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (y <= -6600.0) {
tmp = t_0;
} else if (y <= 1.15e+28) {
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 <= (-6600.0d0)) then
tmp = t_0
else if (y <= 1.15d+28) 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 <= -6600.0) {
tmp = t_0;
} else if (y <= 1.15e+28) {
tmp = (x / z) - x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if y <= -6600.0: tmp = t_0 elif y <= 1.15e+28: tmp = (x / z) - x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (y <= -6600.0) tmp = t_0; elseif (y <= 1.15e+28) 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 <= -6600.0) tmp = t_0; elseif (y <= 1.15e+28) tmp = (x / z) - x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6600.0], t$95$0, If[LessEqual[y, 1.15e+28], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -6600:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -6600 or 1.14999999999999992e28 < y Initial program 87.6%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
/-lowering-/.f6490.8%
Applied egg-rr90.8%
Taylor expanded in y around inf
Simplified75.0%
if -6600 < y < 1.14999999999999992e28Initial program 84.7%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6496.7%
Simplified96.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 2e+14) (/ (* x t_0) z) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 2e+14) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / 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 - z) + 1.0d0
if (x <= 2d+14) then
tmp = (x * t_0) / z
else
tmp = x / (z / t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 2e+14) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if x <= 2e+14: tmp = (x * t_0) / z else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (x <= 2e+14) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (x <= 2e+14) tmp = (x * t_0) / z; else tmp = x / (z / t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, 2e+14], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 2 \cdot 10^{+14}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t\_0}}\\
\end{array}
\end{array}
if x < 2e14Initial program 91.1%
if 2e14 < x Initial program 71.2%
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.6e+20) (- 0.0 x) (if (<= z 5.2) (/ x z) (- 0.0 x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.6e+20) {
tmp = 0.0 - x;
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - 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.6d+20)) then
tmp = 0.0d0 - x
else if (z <= 5.2d0) then
tmp = x / z
else
tmp = 0.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.6e+20) {
tmp = 0.0 - x;
} else if (z <= 5.2) {
tmp = x / z;
} else {
tmp = 0.0 - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.6e+20: tmp = 0.0 - x elif z <= 5.2: tmp = x / z else: tmp = 0.0 - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.6e+20) tmp = Float64(0.0 - x); elseif (z <= 5.2) tmp = Float64(x / z); else tmp = Float64(0.0 - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.6e+20) tmp = 0.0 - x; elseif (z <= 5.2) tmp = x / z; else tmp = 0.0 - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.6e+20], N[(0.0 - x), $MachinePrecision], If[LessEqual[z, 5.2], N[(x / z), $MachinePrecision], N[(0.0 - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.6 \cdot 10^{+20}:\\
\;\;\;\;0 - x\\
\mathbf{elif}\;z \leq 5.2:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;0 - x\\
\end{array}
\end{array}
if z < -1.6e20 or 5.20000000000000018 < z Initial program 68.7%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.1%
Simplified76.1%
sub0-negN/A
neg-lowering-neg.f6476.1%
Applied egg-rr76.1%
if -1.6e20 < z < 5.20000000000000018Initial program 99.9%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval92.5%
Simplified92.5%
Taylor expanded in y around 0
mul-1-negN/A
distribute-lft-out--N/A
associate-*r/N/A
*-rgt-identityN/A
*-rgt-identityN/A
unsub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
/-lowering-/.f6458.2%
Simplified58.2%
Taylor expanded in z around 0
/-lowering-/.f6457.2%
Simplified57.2%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (- 0.0 x))
double code(double x, double y, double z) {
return 0.0 - x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.0d0 - x
end function
public static double code(double x, double y, double z) {
return 0.0 - x;
}
def code(x, y, z): return 0.0 - x
function code(x, y, z) return Float64(0.0 - x) end
function tmp = code(x, y, z) tmp = 0.0 - x; end
code[x_, y_, z_] := N[(0.0 - x), $MachinePrecision]
\begin{array}{l}
\\
0 - x
\end{array}
Initial program 86.0%
associate-/l*N/A
*-lowering-*.f64N/A
associate-+l-N/A
div-subN/A
sub-negN/A
+-commutativeN/A
div-subN/A
sub-negN/A
*-inversesN/A
distribute-neg-fracN/A
distribute-neg-inN/A
sub-negN/A
associate-+l-N/A
--lowering--.f64N/A
metadata-evalN/A
div-subN/A
sub-negN/A
distribute-neg-inN/A
/-lowering-/.f64N/A
distribute-neg-inN/A
sub-negN/A
--lowering--.f64N/A
metadata-eval95.8%
Simplified95.8%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6435.8%
Simplified35.8%
sub0-negN/A
neg-lowering-neg.f6435.8%
Applied egg-rr35.8%
Final simplification35.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 2024161
(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))