
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -1.35e+19) (not (<= z 1.0))) (- (* x (/ y z)) x) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e+19) || !(z <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x + (x * 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 <= (-1.35d+19)) .or. (.not. (z <= 1.0d0))) then
tmp = (x * (y / z)) - x
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e+19) || !(z <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e+19) or not (z <= 1.0): tmp = (x * (y / z)) - x else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e+19) || !(z <= 1.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.35e+19) || ~((z <= 1.0))) tmp = (x * (y / z)) - x; else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e+19], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+19} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -1.35e19 or 1 < z Initial program 78.2%
Taylor expanded in z around 0 95.3%
neg-mul-195.3%
+-commutative95.3%
unsub-neg95.3%
associate-/l*99.9%
associate-/r/94.2%
Simplified94.2%
Taylor expanded in y around inf 95.1%
associate-*r/99.6%
Simplified99.6%
if -1.35e19 < z < 1Initial program 99.9%
Taylor expanded in z around 0 98.6%
distribute-lft-in98.6%
*-rgt-identity98.6%
Simplified98.6%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) y)))
(if (<= y -5.5e+39)
t_0
(if (<= y -1.85e-42)
(- x)
(if (<= y -1.5e-76)
(/ x z)
(if (<= y -3.6e-143)
(- x)
(if (<= y 7.6e-10) (/ x z) (if (<= y 1.8e+75) (- x) t_0))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * y;
double tmp;
if (y <= -5.5e+39) {
tmp = t_0;
} else if (y <= -1.85e-42) {
tmp = -x;
} else if (y <= -1.5e-76) {
tmp = x / z;
} else if (y <= -3.6e-143) {
tmp = -x;
} else if (y <= 7.6e-10) {
tmp = x / z;
} else if (y <= 1.8e+75) {
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 <= (-5.5d+39)) then
tmp = t_0
else if (y <= (-1.85d-42)) then
tmp = -x
else if (y <= (-1.5d-76)) then
tmp = x / z
else if (y <= (-3.6d-143)) then
tmp = -x
else if (y <= 7.6d-10) then
tmp = x / z
else if (y <= 1.8d+75) 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 <= -5.5e+39) {
tmp = t_0;
} else if (y <= -1.85e-42) {
tmp = -x;
} else if (y <= -1.5e-76) {
tmp = x / z;
} else if (y <= -3.6e-143) {
tmp = -x;
} else if (y <= 7.6e-10) {
tmp = x / z;
} else if (y <= 1.8e+75) {
tmp = -x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * y tmp = 0 if y <= -5.5e+39: tmp = t_0 elif y <= -1.85e-42: tmp = -x elif y <= -1.5e-76: tmp = x / z elif y <= -3.6e-143: tmp = -x elif y <= 7.6e-10: tmp = x / z elif y <= 1.8e+75: 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 <= -5.5e+39) tmp = t_0; elseif (y <= -1.85e-42) tmp = Float64(-x); elseif (y <= -1.5e-76) tmp = Float64(x / z); elseif (y <= -3.6e-143) tmp = Float64(-x); elseif (y <= 7.6e-10) tmp = Float64(x / z); elseif (y <= 1.8e+75) 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 <= -5.5e+39) tmp = t_0; elseif (y <= -1.85e-42) tmp = -x; elseif (y <= -1.5e-76) tmp = x / z; elseif (y <= -3.6e-143) tmp = -x; elseif (y <= 7.6e-10) tmp = x / z; elseif (y <= 1.8e+75) 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, -5.5e+39], t$95$0, If[LessEqual[y, -1.85e-42], (-x), If[LessEqual[y, -1.5e-76], N[(x / z), $MachinePrecision], If[LessEqual[y, -3.6e-143], (-x), If[LessEqual[y, 7.6e-10], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.8e+75], (-x), t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot y\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-42}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{-76}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-143}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-10}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+75}:\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -5.4999999999999997e39 or 1.8e75 < y Initial program 94.2%
Taylor expanded in y around inf 85.2%
associate-/l*76.3%
associate-/r/81.1%
Simplified81.1%
if -5.4999999999999997e39 < y < -1.8500000000000001e-42 or -1.50000000000000012e-76 < y < -3.5999999999999998e-143 or 7.5999999999999996e-10 < y < 1.8e75Initial program 82.5%
Taylor expanded in z around inf 70.9%
neg-mul-170.9%
Simplified70.9%
if -1.8500000000000001e-42 < y < -1.50000000000000012e-76 or -3.5999999999999998e-143 < y < 7.5999999999999996e-10Initial program 89.0%
Taylor expanded in z around 0 63.8%
distribute-lft-in63.8%
*-rgt-identity63.8%
Simplified63.8%
Taylor expanded in y around 0 63.5%
Final simplification71.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x (/ y z)) x)))
(if (<= y -1.0)
t_0
(if (<= y 1.0) (- (/ x z) x) (if (<= y 2.5e+137) t_0 (/ (* x y) z))))))
double code(double x, double y, double z) {
double t_0 = (x * (y / z)) - x;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.5e+137) {
tmp = t_0;
} else {
tmp = (x * 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) :: t_0
real(8) :: tmp
t_0 = (x * (y / z)) - x
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= 1.0d0) then
tmp = (x / z) - x
else if (y <= 2.5d+137) then
tmp = t_0
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * (y / z)) - x;
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.5e+137) {
tmp = t_0;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (x * (y / z)) - x tmp = 0 if y <= -1.0: tmp = t_0 elif y <= 1.0: tmp = (x / z) - x elif y <= 2.5e+137: tmp = t_0 else: tmp = (x * y) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y / z)) - x) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(Float64(x / z) - x); elseif (y <= 2.5e+137) tmp = t_0; else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * (y / z)) - x; tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= 1.0) tmp = (x / z) - x; elseif (y <= 2.5e+137) tmp = t_0; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, 1.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 2.5e+137], t$95$0, N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z} - x\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+137}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y < 2.5000000000000001e137Initial program 90.9%
Taylor expanded in z around 0 96.7%
neg-mul-196.7%
+-commutative96.7%
unsub-neg96.7%
associate-/l*98.8%
associate-/r/97.2%
Simplified97.2%
Taylor expanded in y around inf 95.9%
associate-*r/97.9%
Simplified97.9%
if -1 < y < 1Initial program 87.8%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
if 2.5000000000000001e137 < y Initial program 92.9%
Taylor expanded in y around inf 91.6%
Final simplification97.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.0)
(- (* x (/ y z)) x)
(if (<= y 1.0)
(- (/ x z) x)
(if (<= y 2.5e+137) (- (/ x (/ z y)) x) (/ (* x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x * (y / z)) - x;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.5e+137) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * 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 (y <= (-1.0d0)) then
tmp = (x * (y / z)) - x
else if (y <= 1.0d0) then
tmp = (x / z) - x
else if (y <= 2.5d+137) then
tmp = (x / (z / y)) - x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x * (y / z)) - x;
} else if (y <= 1.0) {
tmp = (x / z) - x;
} else if (y <= 2.5e+137) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = (x * (y / z)) - x elif y <= 1.0: tmp = (x / z) - x elif y <= 2.5e+137: tmp = (x / (z / y)) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (y <= 1.0) tmp = Float64(Float64(x / z) - x); elseif (y <= 2.5e+137) tmp = Float64(Float64(x / Float64(z / y)) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = (x * (y / z)) - x; elseif (y <= 1.0) tmp = (x / z) - x; elseif (y <= 2.5e+137) tmp = (x / (z / y)) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 2.5e+137], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+137}:\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1Initial program 93.3%
Taylor expanded in z around 0 96.8%
neg-mul-196.8%
+-commutative96.8%
unsub-neg96.8%
associate-/l*98.2%
associate-/r/95.9%
Simplified95.9%
Taylor expanded in y around inf 96.8%
associate-*r/98.2%
Simplified98.2%
if -1 < y < 1Initial program 87.8%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
if 1 < y < 2.5000000000000001e137Initial program 85.9%
Taylor expanded in z around 0 96.4%
neg-mul-196.4%
+-commutative96.4%
unsub-neg96.4%
associate-/l*99.9%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in y around inf 93.9%
associate-*r/97.3%
Simplified97.3%
clear-num97.4%
un-div-inv97.4%
Applied egg-rr97.4%
if 2.5000000000000001e137 < y Initial program 92.9%
Taylor expanded in y around inf 91.6%
Final simplification97.5%
(FPCore (x y z)
:precision binary64
(if (<= y -1.0)
(- (* x (/ y z)) x)
(if (<= y 1.0)
(/ x (/ z (- 1.0 z)))
(if (<= y 2.45e+137) (- (/ x (/ z y)) x) (/ (* x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x * (y / z)) - x;
} else if (y <= 1.0) {
tmp = x / (z / (1.0 - z));
} else if (y <= 2.45e+137) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * 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 (y <= (-1.0d0)) then
tmp = (x * (y / z)) - x
else if (y <= 1.0d0) then
tmp = x / (z / (1.0d0 - z))
else if (y <= 2.45d+137) then
tmp = (x / (z / y)) - x
else
tmp = (x * y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x * (y / z)) - x;
} else if (y <= 1.0) {
tmp = x / (z / (1.0 - z));
} else if (y <= 2.45e+137) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = (x * (y / z)) - x elif y <= 1.0: tmp = x / (z / (1.0 - z)) elif y <= 2.45e+137: tmp = (x / (z / y)) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (y <= 1.0) tmp = Float64(x / Float64(z / Float64(1.0 - z))); elseif (y <= 2.45e+137) tmp = Float64(Float64(x / Float64(z / y)) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = (x * (y / z)) - x; elseif (y <= 1.0) tmp = x / (z / (1.0 - z)); elseif (y <= 2.45e+137) tmp = (x / (z / y)) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 1.0], N[(x / N[(z / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e+137], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{\frac{z}{1 - z}}\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+137}:\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -1Initial program 93.3%
Taylor expanded in z around 0 96.8%
neg-mul-196.8%
+-commutative96.8%
unsub-neg96.8%
associate-/l*98.2%
associate-/r/95.9%
Simplified95.9%
Taylor expanded in y around inf 96.8%
associate-*r/98.2%
Simplified98.2%
if -1 < y < 1Initial program 87.8%
Taylor expanded in y around 0 87.0%
associate-/l*99.2%
Simplified99.2%
if 1 < y < 2.45000000000000016e137Initial program 85.9%
Taylor expanded in z around 0 96.4%
neg-mul-196.4%
+-commutative96.4%
unsub-neg96.4%
associate-/l*99.9%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in y around inf 93.9%
associate-*r/97.3%
Simplified97.3%
clear-num97.4%
un-div-inv97.4%
Applied egg-rr97.4%
if 2.45000000000000016e137 < y Initial program 92.9%
Taylor expanded in y around inf 91.6%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (<= z 5e-129) (- (* (/ x z) (+ 1.0 y)) x) (* x (/ (+ 1.0 (- y z)) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5e-129) {
tmp = ((x / z) * (1.0 + y)) - x;
} else {
tmp = x * ((1.0 + (y - z)) / 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-129) then
tmp = ((x / z) * (1.0d0 + y)) - x
else
tmp = x * ((1.0d0 + (y - z)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 5e-129) {
tmp = ((x / z) * (1.0 + y)) - x;
} else {
tmp = x * ((1.0 + (y - z)) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 5e-129: tmp = ((x / z) * (1.0 + y)) - x else: tmp = x * ((1.0 + (y - z)) / z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 5e-129) tmp = Float64(Float64(Float64(x / z) * Float64(1.0 + y)) - x); else tmp = Float64(x * Float64(Float64(1.0 + Float64(y - z)) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 5e-129) tmp = ((x / z) * (1.0 + y)) - x; else tmp = x * ((1.0 + (y - z)) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 5e-129], N[(N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{-129}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + y\right) - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 + \left(y - z\right)}{z}\\
\end{array}
\end{array}
if z < 5.00000000000000027e-129Initial program 92.0%
Taylor expanded in z around 0 98.2%
neg-mul-198.2%
+-commutative98.2%
unsub-neg98.2%
associate-/l*93.4%
associate-/r/98.2%
Simplified98.2%
if 5.00000000000000027e-129 < z Initial program 85.4%
*-un-lft-identity85.4%
times-frac99.9%
Applied egg-rr99.9%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= z 54000000000.0) (- (* (/ x z) (+ 1.0 y)) x) (- (* x (/ y z)) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= 54000000000.0) {
tmp = ((x / z) * (1.0 + y)) - x;
} else {
tmp = (x * (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 (z <= 54000000000.0d0) then
tmp = ((x / z) * (1.0d0 + y)) - x
else
tmp = (x * (y / z)) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 54000000000.0) {
tmp = ((x / z) * (1.0 + y)) - x;
} else {
tmp = (x * (y / z)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 54000000000.0: tmp = ((x / z) * (1.0 + y)) - x else: tmp = (x * (y / z)) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= 54000000000.0) tmp = Float64(Float64(Float64(x / z) * Float64(1.0 + y)) - x); else tmp = Float64(Float64(x * Float64(y / z)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 54000000000.0) tmp = ((x / z) * (1.0 + y)) - x; else tmp = (x * (y / z)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 54000000000.0], N[(N[(N[(x / z), $MachinePrecision] * N[(1.0 + y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 54000000000:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + y\right) - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\end{array}
\end{array}
if z < 5.4e10Initial program 93.1%
Taylor expanded in z around 0 98.4%
neg-mul-198.4%
+-commutative98.4%
unsub-neg98.4%
associate-/l*94.3%
associate-/r/98.4%
Simplified98.4%
if 5.4e10 < z Initial program 78.9%
Taylor expanded in z around 0 95.5%
neg-mul-195.5%
+-commutative95.5%
unsub-neg95.5%
associate-/l*99.9%
associate-/r/93.3%
Simplified93.3%
Taylor expanded in y around inf 95.5%
associate-*r/99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.7e+40) (not (<= y 1.55e+75))) (* (/ x z) y) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.7e+40) || !(y <= 1.55e+75)) {
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 <= (-3.7d+40)) .or. (.not. (y <= 1.55d+75))) 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 <= -3.7e+40) || !(y <= 1.55e+75)) {
tmp = (x / z) * y;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.7e+40) or not (y <= 1.55e+75): tmp = (x / z) * y else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.7e+40) || !(y <= 1.55e+75)) 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 <= -3.7e+40) || ~((y <= 1.55e+75))) tmp = (x / z) * y; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.7e+40], N[Not[LessEqual[y, 1.55e+75]], $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 -3.7 \cdot 10^{+40} \lor \neg \left(y \leq 1.55 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{x}{z} \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -3.7e40 or 1.5500000000000001e75 < y Initial program 94.2%
Taylor expanded in y around inf 85.2%
associate-/l*76.3%
associate-/r/81.1%
Simplified81.1%
if -3.7e40 < y < 1.5500000000000001e75Initial program 86.8%
Taylor expanded in z around 0 99.4%
neg-mul-199.4%
+-commutative99.4%
unsub-neg99.4%
associate-/l*100.0%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 94.9%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.16e+41) (not (<= y 1.05e+75))) (/ (* x y) z) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.16e+41) || !(y <= 1.05e+75)) {
tmp = (x * y) / 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 <= (-1.16d+41)) .or. (.not. (y <= 1.05d+75))) then
tmp = (x * y) / 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 <= -1.16e+41) || !(y <= 1.05e+75)) {
tmp = (x * y) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.16e+41) or not (y <= 1.05e+75): tmp = (x * y) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.16e+41) || !(y <= 1.05e+75)) tmp = Float64(Float64(x * y) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.16e+41) || ~((y <= 1.05e+75))) tmp = (x * y) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.16e+41], N[Not[LessEqual[y, 1.05e+75]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.16 \cdot 10^{+41} \lor \neg \left(y \leq 1.05 \cdot 10^{+75}\right):\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.16000000000000007e41 or 1.04999999999999999e75 < y Initial program 94.2%
Taylor expanded in y around inf 85.2%
if -1.16000000000000007e41 < y < 1.04999999999999999e75Initial program 86.8%
Taylor expanded in z around 0 99.4%
neg-mul-199.4%
+-commutative99.4%
unsub-neg99.4%
associate-/l*100.0%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 94.9%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (<= y -3.7e+40) (/ x (/ z y)) (if (<= y 8.6e+74) (- (/ x z) x) (* (/ x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.7e+40) {
tmp = x / (z / y);
} else if (y <= 8.6e+74) {
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 <= (-3.7d+40)) then
tmp = x / (z / y)
else if (y <= 8.6d+74) 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 <= -3.7e+40) {
tmp = x / (z / y);
} else if (y <= 8.6e+74) {
tmp = (x / z) - x;
} else {
tmp = (x / z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.7e+40: tmp = x / (z / y) elif y <= 8.6e+74: tmp = (x / z) - x else: tmp = (x / z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.7e+40) tmp = Float64(x / Float64(z / y)); elseif (y <= 8.6e+74) 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 <= -3.7e+40) tmp = x / (z / y); elseif (y <= 8.6e+74) tmp = (x / z) - x; else tmp = (x / z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.7e+40], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+74], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+74}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot y\\
\end{array}
\end{array}
if y < -3.7e40Initial program 94.1%
Taylor expanded in y around inf 84.3%
associate-/l*84.1%
Simplified84.1%
if -3.7e40 < y < 8.60000000000000001e74Initial program 86.8%
Taylor expanded in z around 0 99.4%
neg-mul-199.4%
+-commutative99.4%
unsub-neg99.4%
associate-/l*100.0%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 94.9%
if 8.60000000000000001e74 < y Initial program 94.2%
Taylor expanded in y around inf 85.9%
associate-/l*69.1%
associate-/r/80.2%
Simplified80.2%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.8e+39) (/ x (/ z y)) (if (<= y 1.05e+75) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+39) {
tmp = x / (z / y);
} else if (y <= 1.05e+75) {
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 <= (-5.8d+39)) then
tmp = x / (z / y)
else if (y <= 1.05d+75) 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 <= -5.8e+39) {
tmp = x / (z / y);
} else if (y <= 1.05e+75) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+39: tmp = x / (z / y) elif y <= 1.05e+75: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+39) tmp = Float64(x / Float64(z / y)); elseif (y <= 1.05e+75) 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 <= -5.8e+39) tmp = x / (z / y); elseif (y <= 1.05e+75) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+39], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e+75], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+39}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+75}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -5.80000000000000059e39Initial program 94.1%
Taylor expanded in y around inf 84.3%
associate-/l*84.1%
Simplified84.1%
if -5.80000000000000059e39 < y < 1.04999999999999999e75Initial program 86.8%
Taylor expanded in z around 0 99.4%
neg-mul-199.4%
+-commutative99.4%
unsub-neg99.4%
associate-/l*100.0%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 94.9%
if 1.04999999999999999e75 < y Initial program 94.2%
Taylor expanded in y around inf 85.9%
associate-/l*69.1%
associate-/r/80.2%
Simplified80.2%
associate-*l/85.9%
*-commutative85.9%
associate-/l*80.3%
Applied egg-rr80.3%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 4100000.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 4100000.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 <= 4100000.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 <= 4100000.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 4100000.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 <= 4100000.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 <= 4100000.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, 4100000.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 4100000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 4.1e6 < z Initial program 78.2%
Taylor expanded in z around inf 72.5%
neg-mul-172.5%
Simplified72.5%
if -1 < z < 4.1e6Initial program 99.9%
Taylor expanded in z around 0 98.5%
distribute-lft-in98.5%
*-rgt-identity98.5%
Simplified98.5%
Taylor expanded in y around 0 58.9%
Final simplification65.3%
(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 89.7%
Taylor expanded in z around inf 35.7%
neg-mul-135.7%
Simplified35.7%
Final simplification35.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 2023277
(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))