
(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 11 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)))
(if (<= z -4.2e-72)
(/ x (/ z t_0))
(if (<= z 5.5e-63) (* (/ x z) (+ y (- 1.0 z))) (* x (/ t_0 z))))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (z <= -4.2e-72) {
tmp = x / (z / t_0);
} else if (z <= 5.5e-63) {
tmp = (x / z) * (y + (1.0 - z));
} else {
tmp = x * (t_0 / 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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (z <= (-4.2d-72)) then
tmp = x / (z / t_0)
else if (z <= 5.5d-63) then
tmp = (x / z) * (y + (1.0d0 - z))
else
tmp = x * (t_0 / z)
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 (z <= -4.2e-72) {
tmp = x / (z / t_0);
} else if (z <= 5.5e-63) {
tmp = (x / z) * (y + (1.0 - z));
} else {
tmp = x * (t_0 / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if z <= -4.2e-72: tmp = x / (z / t_0) elif z <= 5.5e-63: tmp = (x / z) * (y + (1.0 - z)) else: tmp = x * (t_0 / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (z <= -4.2e-72) tmp = Float64(x / Float64(z / t_0)); elseif (z <= 5.5e-63) tmp = Float64(Float64(x / z) * Float64(y + Float64(1.0 - z))); else tmp = Float64(x * Float64(t_0 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (z <= -4.2e-72) tmp = x / (z / t_0); elseif (z <= 5.5e-63) tmp = (x / z) * (y + (1.0 - z)); else tmp = x * (t_0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[z, -4.2e-72], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.5e-63], N[(N[(x / z), $MachinePrecision] * N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{\frac{z}{t\_0}}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + \left(1 - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\end{array}
\end{array}
if z < -4.2e-72Initial program 78.3%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
if -4.2e-72 < z < 5.50000000000000043e-63Initial program 99.9%
associate-/l*90.5%
Simplified90.5%
Taylor expanded in x around 0 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*l/99.9%
associate-+l-99.9%
Simplified99.9%
if 5.50000000000000043e-63 < z Initial program 80.9%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -1.0)
(- x)
(if (<= z -9.2e-255)
(/ x z)
(if (<= z 5e-283)
t_0
(if (<= z 8.8e-158) (/ x z) (if (<= z 122000.0) t_0 (- x))))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= -9.2e-255) {
tmp = x / z;
} else if (z <= 5e-283) {
tmp = t_0;
} else if (z <= 8.8e-158) {
tmp = x / z;
} else if (z <= 122000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= (-9.2d-255)) then
tmp = x / z
else if (z <= 5d-283) then
tmp = t_0
else if (z <= 8.8d-158) then
tmp = x / z
else if (z <= 122000.0d0) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= -9.2e-255) {
tmp = x / z;
} else if (z <= 5e-283) {
tmp = t_0;
} else if (z <= 8.8e-158) {
tmp = x / z;
} else if (z <= 122000.0) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -1.0: tmp = -x elif z <= -9.2e-255: tmp = x / z elif z <= 5e-283: tmp = t_0 elif z <= 8.8e-158: tmp = x / z elif z <= 122000.0: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= -9.2e-255) tmp = Float64(x / z); elseif (z <= 5e-283) tmp = t_0; elseif (z <= 8.8e-158) tmp = Float64(x / z); elseif (z <= 122000.0) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= -9.2e-255) tmp = x / z; elseif (z <= 5e-283) tmp = t_0; elseif (z <= 8.8e-158) tmp = x / z; elseif (z <= 122000.0) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0], (-x), If[LessEqual[z, -9.2e-255], N[(x / z), $MachinePrecision], If[LessEqual[z, 5e-283], t$95$0, If[LessEqual[z, 8.8e-158], N[(x / z), $MachinePrecision], If[LessEqual[z, 122000.0], t$95$0, (-x)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -9.2 \cdot 10^{-255}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-283}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-158}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 122000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 122000 < z Initial program 74.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 79.4%
neg-mul-179.4%
Simplified79.4%
if -1 < z < -9.1999999999999995e-255 or 5.0000000000000001e-283 < z < 8.8000000000000004e-158Initial program 99.9%
associate-/l*92.1%
Simplified92.1%
Taylor expanded in y around 0 68.1%
associate-/l*67.9%
Simplified67.9%
Taylor expanded in z around 0 67.4%
if -9.1999999999999995e-255 < z < 5.0000000000000001e-283 or 8.8000000000000004e-158 < z < 122000Initial program 99.8%
associate-/l*93.4%
Simplified93.4%
Taylor expanded in y around inf 67.9%
associate-/l*61.5%
Simplified61.5%
Final simplification71.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.0)
(- x)
(if (<= z -4.3e-254)
(/ x z)
(if (<= z 6.2e-255)
t_0
(if (<= z 1.7e-222) (/ x z) (if (<= z 100000.0) t_0 (- x))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= -4.3e-254) {
tmp = x / z;
} else if (z <= 6.2e-255) {
tmp = t_0;
} else if (z <= 1.7e-222) {
tmp = x / z;
} else if (z <= 100000.0) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= (-4.3d-254)) then
tmp = x / z
else if (z <= 6.2d-255) then
tmp = t_0
else if (z <= 1.7d-222) then
tmp = x / z
else if (z <= 100000.0d0) then
tmp = t_0
else
tmp = -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 <= -1.0) {
tmp = -x;
} else if (z <= -4.3e-254) {
tmp = x / z;
} else if (z <= 6.2e-255) {
tmp = t_0;
} else if (z <= 1.7e-222) {
tmp = x / z;
} else if (z <= 100000.0) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.0: tmp = -x elif z <= -4.3e-254: tmp = x / z elif z <= 6.2e-255: tmp = t_0 elif z <= 1.7e-222: tmp = x / z elif z <= 100000.0: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= -4.3e-254) tmp = Float64(x / z); elseif (z <= 6.2e-255) tmp = t_0; elseif (z <= 1.7e-222) tmp = Float64(x / z); elseif (z <= 100000.0) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= -4.3e-254) tmp = x / z; elseif (z <= 6.2e-255) tmp = t_0; elseif (z <= 1.7e-222) tmp = x / z; elseif (z <= 100000.0) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0], (-x), If[LessEqual[z, -4.3e-254], N[(x / z), $MachinePrecision], If[LessEqual[z, 6.2e-255], t$95$0, If[LessEqual[z, 1.7e-222], N[(x / z), $MachinePrecision], If[LessEqual[z, 100000.0], t$95$0, (-x)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -4.3 \cdot 10^{-254}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-255}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-222}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 100000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1e5 < z Initial program 74.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 79.4%
neg-mul-179.4%
Simplified79.4%
if -1 < z < -4.2999999999999997e-254 or 6.19999999999999995e-255 < z < 1.7000000000000001e-222Initial program 99.9%
associate-/l*94.8%
Simplified94.8%
Taylor expanded in y around 0 74.0%
associate-/l*73.9%
Simplified73.9%
Taylor expanded in z around 0 73.1%
if -4.2999999999999997e-254 < z < 6.19999999999999995e-255 or 1.7000000000000001e-222 < z < 1e5Initial program 99.8%
associate-/l*91.0%
Simplified91.0%
Taylor expanded in y around inf 65.5%
*-commutative65.5%
associate-*r/66.7%
Simplified66.7%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -5e-14) (not (<= z 6e-63))) (* x (/ (+ (- y z) 1.0) z)) (* (/ x z) (+ y (- 1.0 z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-14) || !(z <= 6e-63)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x / z) * (y + (1.0 - 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 ((z <= (-5d-14)) .or. (.not. (z <= 6d-63))) then
tmp = x * (((y - z) + 1.0d0) / z)
else
tmp = (x / z) * (y + (1.0d0 - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-14) || !(z <= 6e-63)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x / z) * (y + (1.0 - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e-14) or not (z <= 6e-63): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x / z) * (y + (1.0 - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e-14) || !(z <= 6e-63)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); else tmp = Float64(Float64(x / z) * Float64(y + Float64(1.0 - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5e-14) || ~((z <= 6e-63))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x / z) * (y + (1.0 - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e-14], N[Not[LessEqual[z, 6e-63]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-14} \lor \neg \left(z \leq 6 \cdot 10^{-63}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + \left(1 - z\right)\right)\\
\end{array}
\end{array}
if z < -5.0000000000000002e-14 or 5.99999999999999959e-63 < z Initial program 78.4%
associate-/l*99.9%
Simplified99.9%
if -5.0000000000000002e-14 < z < 5.99999999999999959e-63Initial program 99.9%
associate-/l*91.2%
Simplified91.2%
Taylor expanded in x around 0 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*l/99.9%
associate-+l-99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.15e-11))) (* x (+ (/ y z) -1.0)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.15e-11)) {
tmp = x * ((y / z) + -1.0);
} 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 ((y <= (-1.0d0)) .or. (.not. (y <= 1.15d-11))) then
tmp = x * ((y / z) + (-1.0d0))
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.15e-11)) {
tmp = x * ((y / z) + -1.0);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.15e-11): tmp = x * ((y / z) + -1.0) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.15e-11)) tmp = Float64(x * Float64(Float64(y / z) + -1.0)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 1.15e-11))) tmp = x * ((y / z) + -1.0); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.15e-11]], $MachinePrecision]], N[(x * N[(N[(y / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1.15 \cdot 10^{-11}\right):\\
\;\;\;\;x \cdot \left(\frac{y}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1.15000000000000007e-11 < y Initial program 85.8%
associate-/l*92.6%
Simplified92.6%
associate-+l-92.6%
div-sub91.8%
sub-neg91.8%
metadata-eval91.8%
Applied egg-rr91.8%
Taylor expanded in z around inf 90.9%
if -1 < y < 1.15000000000000007e-11Initial program 89.6%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 89.4%
remove-double-neg89.4%
distribute-neg-frac289.4%
distribute-frac-neg89.4%
distribute-rgt-neg-in89.4%
neg-sub089.4%
associate--r-89.4%
metadata-eval89.4%
+-commutative89.4%
associate-*r/99.6%
distribute-neg-frac299.6%
distribute-neg-frac99.6%
distribute-neg-in99.6%
metadata-eval99.6%
+-commutative99.6%
sub-neg99.6%
div-sub99.6%
*-inverses99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
+-commutative99.6%
distribute-rgt-in99.6%
associate-*l/99.7%
*-lft-identity99.7%
neg-mul-199.7%
unsub-neg99.7%
Simplified99.7%
Final simplification95.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.05e+57) (not (<= y 1.55e+72))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.05e+57) || !(y <= 1.55e+72)) {
tmp = y * (x / 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 ((y <= (-2.05d+57)) .or. (.not. (y <= 1.55d+72))) then
tmp = y * (x / 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 ((y <= -2.05e+57) || !(y <= 1.55e+72)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.05e+57) or not (y <= 1.55e+72): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.05e+57) || !(y <= 1.55e+72)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.05e+57) || ~((y <= 1.55e+72))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.05e+57], N[Not[LessEqual[y, 1.55e+72]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{+57} \lor \neg \left(y \leq 1.55 \cdot 10^{+72}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -2.05e57 or 1.54999999999999994e72 < y Initial program 86.3%
associate-/l*89.9%
Simplified89.9%
Taylor expanded in y around inf 78.1%
*-commutative78.1%
associate-*r/82.0%
Simplified82.0%
if -2.05e57 < y < 1.54999999999999994e72Initial program 88.4%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.5%
remove-double-neg82.5%
distribute-neg-frac282.5%
distribute-frac-neg82.5%
distribute-rgt-neg-in82.5%
neg-sub082.5%
associate--r-82.5%
metadata-eval82.5%
+-commutative82.5%
associate-*r/93.9%
distribute-neg-frac293.9%
distribute-neg-frac93.9%
distribute-neg-in93.9%
metadata-eval93.9%
+-commutative93.9%
sub-neg93.9%
div-sub93.9%
*-inverses93.9%
sub-neg93.9%
metadata-eval93.9%
+-commutative93.9%
+-commutative93.9%
distribute-rgt-in93.9%
associate-*l/94.0%
*-lft-identity94.0%
neg-mul-194.0%
unsub-neg94.0%
Simplified94.0%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.05e+57) (* y (/ x z)) (if (<= y 2.5e+71) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e+57) {
tmp = y * (x / z);
} else if (y <= 2.5e+71) {
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 <= (-2.05d+57)) then
tmp = y * (x / z)
else if (y <= 2.5d+71) 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 <= -2.05e+57) {
tmp = y * (x / z);
} else if (y <= 2.5e+71) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.05e+57: tmp = y * (x / z) elif y <= 2.5e+71: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.05e+57) tmp = Float64(y * Float64(x / z)); elseif (y <= 2.5e+71) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.05e+57) tmp = y * (x / z); elseif (y <= 2.5e+71) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.05e+57], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+71], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{+57}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+71}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -2.05e57Initial program 87.4%
associate-/l*91.1%
Simplified91.1%
Taylor expanded in y around inf 85.1%
*-commutative85.1%
associate-*r/91.2%
Simplified91.2%
if -2.05e57 < y < 2.49999999999999986e71Initial program 88.4%
associate-/l*99.8%
Simplified99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.5%
remove-double-neg82.5%
distribute-neg-frac282.5%
distribute-frac-neg82.5%
distribute-rgt-neg-in82.5%
neg-sub082.5%
associate--r-82.5%
metadata-eval82.5%
+-commutative82.5%
associate-*r/93.9%
distribute-neg-frac293.9%
distribute-neg-frac93.9%
distribute-neg-in93.9%
metadata-eval93.9%
+-commutative93.9%
sub-neg93.9%
div-sub93.9%
*-inverses93.9%
sub-neg93.9%
metadata-eval93.9%
+-commutative93.9%
+-commutative93.9%
distribute-rgt-in93.9%
associate-*l/94.0%
*-lft-identity94.0%
neg-mul-194.0%
unsub-neg94.0%
Simplified94.0%
if 2.49999999999999986e71 < y Initial program 85.5%
associate-/l*88.9%
Simplified88.9%
clear-num88.9%
un-div-inv90.2%
Applied egg-rr90.2%
Taylor expanded in y around inf 69.8%
associate-/r/74.3%
Applied egg-rr74.3%
*-commutative74.3%
clear-num74.4%
un-div-inv74.5%
Applied egg-rr74.5%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 1.5e-118) (/ (* 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 <= 1.5e-118) {
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 <= 1.5d-118) 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 <= 1.5e-118) {
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 <= 1.5e-118: 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 <= 1.5e-118) 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 <= 1.5e-118) 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, 1.5e-118], 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 1.5 \cdot 10^{-118}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t\_0}}\\
\end{array}
\end{array}
if x < 1.50000000000000009e-118Initial program 87.2%
if 1.50000000000000009e-118 < x Initial program 88.4%
associate-/l*99.9%
Simplified99.9%
clear-num99.9%
un-div-inv100.0%
Applied egg-rr100.0%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 74.7%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 78.8%
neg-mul-178.8%
Simplified78.8%
if -1 < z < 1Initial program 99.9%
associate-/l*92.6%
Simplified92.6%
Taylor expanded in y around 0 54.4%
associate-/l*54.3%
Simplified54.3%
Taylor expanded in z around 0 53.9%
Final simplification65.9%
(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(x * Float64(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[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\left(y - z\right) + 1}{z}
\end{array}
Initial program 87.7%
associate-/l*96.1%
Simplified96.1%
Final simplification96.1%
(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.7%
associate-/l*96.1%
Simplified96.1%
Taylor expanded in z around inf 39.7%
neg-mul-139.7%
Simplified39.7%
Final simplification39.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 2024078
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))