
(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 (if (or (<= z -2e+40) (not (<= z 5e+32))) (- (/ x (/ z y)) x) (* (/ x z) (- (+ 1.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+40) || !(z <= 5e+32)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x / z) * ((1.0 + y) - 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 <= (-2d+40)) .or. (.not. (z <= 5d+32))) then
tmp = (x / (z / y)) - x
else
tmp = (x / z) * ((1.0d0 + y) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+40) || !(z <= 5e+32)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x / z) * ((1.0 + y) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+40) or not (z <= 5e+32): tmp = (x / (z / y)) - x else: tmp = (x / z) * ((1.0 + y) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+40) || !(z <= 5e+32)) tmp = Float64(Float64(x / Float64(z / y)) - x); else tmp = Float64(Float64(x / z) * Float64(Float64(1.0 + y) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+40) || ~((z <= 5e+32))) tmp = (x / (z / y)) - x; else tmp = (x / z) * ((1.0 + y) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+40], N[Not[LessEqual[z, 5e+32]], $MachinePrecision]], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(1.0 + y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+40} \lor \neg \left(z \leq 5 \cdot 10^{+32}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(1 + y\right) - z\right)\\
\end{array}
\end{array}
if z < -2.00000000000000006e40 or 4.9999999999999997e32 < z Initial program 76.0%
associate-/l*99.9%
Simplified99.9%
log1p-expm1-u99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 90.8%
neg-mul-190.8%
+-commutative90.8%
unsub-neg90.8%
*-commutative90.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -2.00000000000000006e40 < z < 4.9999999999999997e32Initial program 99.3%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in x around 0 99.3%
associate--l+99.3%
+-commutative99.3%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z 4e+82) (fma (/ x z) (+ 1.0 y) (- x)) (/ x (/ z (+ 1.0 (- y z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 4e+82) {
tmp = fma((x / z), (1.0 + y), -x);
} else {
tmp = x / (z / (1.0 + (y - z)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 4e+82) tmp = fma(Float64(x / z), Float64(1.0 + y), Float64(-x)); else tmp = Float64(x / Float64(z / Float64(1.0 + Float64(y - z)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 4e+82], N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision] + (-x)), $MachinePrecision], N[(x / N[(z / N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1 + y, -x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + \left(y - z\right)}}\\
\end{array}
\end{array}
if z < 3.9999999999999999e82Initial program 93.5%
associate-/l*96.1%
Simplified96.1%
log1p-expm1-u96.0%
Applied egg-rr96.0%
Taylor expanded in z around 0 96.7%
neg-mul-196.7%
+-commutative96.7%
unsub-neg96.7%
*-commutative96.7%
associate-/l*96.1%
Simplified96.1%
associate-/r/99.4%
fma-neg99.4%
Applied egg-rr99.4%
if 3.9999999999999999e82 < z Initial program 75.3%
associate-/l*100.0%
Simplified100.0%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) y)))
(if (<= y -2e+28)
t_0
(if (<= y -8.2e-130)
(- x)
(if (<= y 2.7e-113) (/ x z) (if (<= y 1.16e+52) (- x) t_0))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -2e+28) {
tmp = t_0;
} else if (y <= -8.2e-130) {
tmp = -x;
} else if (y <= 2.7e-113) {
tmp = x / z;
} else if (y <= 1.16e+52) {
tmp = -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 <= (-2d+28)) then
tmp = t_0
else if (y <= (-8.2d-130)) then
tmp = -x
else if (y <= 2.7d-113) then
tmp = x / z
else if (y <= 1.16d+52) then
tmp = -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 <= -2e+28) {
tmp = t_0;
} else if (y <= -8.2e-130) {
tmp = -x;
} else if (y <= 2.7e-113) {
tmp = x / z;
} else if (y <= 1.16e+52) {
tmp = -x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if y <= -2e+28: tmp = t_0 elif y <= -8.2e-130: tmp = -x elif y <= 2.7e-113: tmp = x / z elif y <= 1.16e+52: tmp = -x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) * y) tmp = 0.0 if (y <= -2e+28) tmp = t_0; elseif (y <= -8.2e-130) tmp = Float64(-x); elseif (y <= 2.7e-113) tmp = Float64(x / z); elseif (y <= 1.16e+52) tmp = Float64(-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 <= -2e+28) tmp = t_0; elseif (y <= -8.2e-130) tmp = -x; elseif (y <= 2.7e-113) tmp = x / z; elseif (y <= 1.16e+52) tmp = -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, -2e+28], t$95$0, If[LessEqual[y, -8.2e-130], (-x), If[LessEqual[y, 2.7e-113], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.16e+52], (-x), t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;y \leq -2 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-130}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-113}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.16 \cdot 10^{+52}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.99999999999999992e28 or 1.1599999999999999e52 < y Initial program 90.6%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in y around inf 73.7%
associate-/r/75.5%
Applied egg-rr75.5%
if -1.99999999999999992e28 < y < -8.19999999999999958e-130 or 2.69999999999999996e-113 < y < 1.1599999999999999e52Initial program 86.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 59.6%
neg-mul-159.6%
Simplified59.6%
if -8.19999999999999958e-130 < y < 2.69999999999999996e-113Initial program 92.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 92.5%
*-commutative92.5%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 62.3%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.0046))) (- (* (/ x z) y) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.0046)) {
tmp = ((x / z) * y) - x;
} 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 <= 0.0046d0))) then
tmp = ((x / z) * y) - x
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 <= 0.0046)) {
tmp = ((x / z) * y) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 0.0046): tmp = ((x / z) * y) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.0046)) tmp = Float64(Float64(Float64(x / z) * y) - x); 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 <= 0.0046))) tmp = ((x / z) * y) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.0046]], $MachinePrecision]], N[(N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.0046\right):\\
\;\;\;\;\frac{x}{z} \cdot y - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 0.0045999999999999999 < y Initial program 89.6%
associate-/l*93.7%
Simplified93.7%
log1p-expm1-u93.7%
Applied egg-rr93.7%
Taylor expanded in z around 0 92.5%
neg-mul-192.5%
+-commutative92.5%
unsub-neg92.5%
*-commutative92.5%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in y around inf 91.1%
associate-*r/93.2%
Simplified93.2%
if -1 < y < 0.0045999999999999999Initial program 90.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 88.7%
*-commutative88.7%
associate-/l*98.4%
Simplified98.4%
Taylor expanded in z around 0 98.4%
neg-mul-198.4%
+-commutative98.4%
unsub-neg98.4%
Simplified98.4%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.95) (not (<= z 1.0))) (- (/ x (/ z y)) x) (/ (* x (+ 1.0 y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 1.0)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * (1.0 + y)) / 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 <= (-0.95d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x / (z / y)) - x
else
tmp = (x * (1.0d0 + y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 1.0)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * (1.0 + y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.95) or not (z <= 1.0): tmp = (x / (z / y)) - x else: tmp = (x * (1.0 + y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.95) || !(z <= 1.0)) tmp = Float64(Float64(x / Float64(z / y)) - x); else tmp = Float64(Float64(x * Float64(1.0 + y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.95) || ~((z <= 1.0))) tmp = (x / (z / y)) - x; else tmp = (x * (1.0 + y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.95], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 + y\right)}{z}\\
\end{array}
\end{array}
if z < -0.94999999999999996 or 1 < z Initial program 79.5%
associate-/l*99.9%
Simplified99.9%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 92.4%
neg-mul-192.4%
+-commutative92.4%
unsub-neg92.4%
*-commutative92.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around inf 97.8%
if -0.94999999999999996 < z < 1Initial program 99.9%
associate-/l*93.9%
Simplified93.9%
Taylor expanded in z around 0 98.7%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e+31) (not (<= y 5.3e+50))) (* (/ x z) y) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+31) || !(y <= 5.3e+50)) {
tmp = (x / z) * y;
} 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.7d+31)) .or. (.not. (y <= 5.3d+50))) then
tmp = (x / z) * y
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.7e+31) || !(y <= 5.3e+50)) {
tmp = (x / z) * y;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.7e+31) or not (y <= 5.3e+50): tmp = (x / z) * y else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e+31) || !(y <= 5.3e+50)) tmp = Float64(Float64(x / z) * y); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.7e+31) || ~((y <= 5.3e+50))) tmp = (x / z) * y; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+31], N[Not[LessEqual[y, 5.3e+50]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+31} \lor \neg \left(y \leq 5.3 \cdot 10^{+50}\right):\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.6999999999999999e31 or 5.3000000000000002e50 < y Initial program 90.6%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in y around inf 73.7%
associate-/r/75.5%
Applied egg-rr75.5%
if -1.6999999999999999e31 < y < 5.3000000000000002e50Initial program 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 84.2%
*-commutative84.2%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in z around 0 94.7%
neg-mul-194.7%
+-commutative94.7%
unsub-neg94.7%
Simplified94.7%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e+27) (* (/ x z) y) (if (<= y 7.8e+49) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+27) {
tmp = (x / z) * y;
} else if (y <= 7.8e+49) {
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.9d+27)) then
tmp = (x / z) * y
else if (y <= 7.8d+49) 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.9e+27) {
tmp = (x / z) * y;
} else if (y <= 7.8e+49) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.9e+27: tmp = (x / z) * y elif y <= 7.8e+49: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.9e+27) tmp = Float64(Float64(x / z) * y); elseif (y <= 7.8e+49) 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.9e+27) tmp = (x / z) * y; elseif (y <= 7.8e+49) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.9e+27], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 7.8e+49], 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.9 \cdot 10^{+27}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+49}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -2.9000000000000001e27Initial program 91.6%
associate-/l*90.0%
Simplified90.0%
Taylor expanded in y around inf 69.0%
associate-/r/72.0%
Applied egg-rr72.0%
if -2.9000000000000001e27 < y < 7.8000000000000002e49Initial program 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 84.2%
*-commutative84.2%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in z around 0 94.7%
neg-mul-194.7%
+-commutative94.7%
unsub-neg94.7%
Simplified94.7%
if 7.8000000000000002e49 < y Initial program 89.4%
associate-/l*95.8%
Simplified95.8%
Taylor expanded in y around inf 79.0%
associate-/l*79.3%
Simplified79.3%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e+30) (/ (* x y) z) (if (<= y 2.95e+49) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+30) {
tmp = (x * y) / z;
} else if (y <= 2.95e+49) {
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 <= (-7.5d+30)) then
tmp = (x * y) / z
else if (y <= 2.95d+49) 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 <= -7.5e+30) {
tmp = (x * y) / z;
} else if (y <= 2.95e+49) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+30: tmp = (x * y) / z elif y <= 2.95e+49: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+30) tmp = Float64(Float64(x * y) / z); elseif (y <= 2.95e+49) 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 <= -7.5e+30) tmp = (x * y) / z; elseif (y <= 2.95e+49) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+30], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 2.95e+49], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+30}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 2.95 \cdot 10^{+49}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -7.49999999999999973e30Initial program 91.6%
associate-/l*90.0%
Simplified90.0%
Taylor expanded in y around inf 76.9%
if -7.49999999999999973e30 < y < 2.9500000000000001e49Initial program 89.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 84.2%
*-commutative84.2%
associate-/l*94.7%
Simplified94.7%
Taylor expanded in z around 0 94.7%
neg-mul-194.7%
+-commutative94.7%
unsub-neg94.7%
Simplified94.7%
if 2.9500000000000001e49 < y Initial program 89.4%
associate-/l*95.8%
Simplified95.8%
Taylor expanded in y around inf 79.0%
associate-/l*79.3%
Simplified79.3%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (- (/ x (/ z (+ 1.0 y))) x))
double code(double x, double y, double z) {
return (x / (z / (1.0 + y))) - 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 / (1.0d0 + y))) - x
end function
public static double code(double x, double y, double z) {
return (x / (z / (1.0 + y))) - x;
}
def code(x, y, z): return (x / (z / (1.0 + y))) - x
function code(x, y, z) return Float64(Float64(x / Float64(z / Float64(1.0 + y))) - x) end
function tmp = code(x, y, z) tmp = (x / (z / (1.0 + y))) - x; end
code[x_, y_, z_] := N[(N[(x / N[(z / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{1 + y}} - x
\end{array}
Initial program 90.0%
associate-/l*96.8%
Simplified96.8%
log1p-expm1-u96.8%
Applied egg-rr96.8%
Taylor expanded in z around 0 96.2%
neg-mul-196.2%
+-commutative96.2%
unsub-neg96.2%
*-commutative96.2%
associate-/l*96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 2700000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 2700000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 2700000.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 2700000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 2700000.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 2700000.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 2700000.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 2700000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 2700000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 2.7e6 < z Initial program 79.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 71.0%
neg-mul-171.0%
Simplified71.0%
if -1 < z < 2.7e6Initial program 99.9%
associate-/l*94.0%
Simplified94.0%
Taylor expanded in y around 0 56.3%
*-commutative56.3%
associate-/l*56.3%
Simplified56.3%
Taylor expanded in z around 0 55.1%
Final simplification62.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 90.0%
associate-/l*96.8%
Simplified96.8%
Taylor expanded in z around inf 36.0%
neg-mul-136.0%
Simplified36.0%
Final simplification36.0%
(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 2023171
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(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))