
(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 12 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.12e+17) (not (<= z 1.62e+16))) (- (* x (/ y z)) x) (* (+ (- y z) 1.0) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.12e+17) || !(z <= 1.62e+16)) {
tmp = (x * (y / z)) - x;
} else {
tmp = ((y - z) + 1.0) * (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.12d+17)) .or. (.not. (z <= 1.62d+16))) then
tmp = (x * (y / z)) - x
else
tmp = ((y - z) + 1.0d0) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.12e+17) || !(z <= 1.62e+16)) {
tmp = (x * (y / z)) - x;
} else {
tmp = ((y - z) + 1.0) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.12e+17) or not (z <= 1.62e+16): tmp = (x * (y / z)) - x else: tmp = ((y - z) + 1.0) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.12e+17) || !(z <= 1.62e+16)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(Float64(y - z) + 1.0) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.12e+17) || ~((z <= 1.62e+16))) tmp = (x * (y / z)) - x; else tmp = ((y - z) + 1.0) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.12e+17], N[Not[LessEqual[z, 1.62e+16]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.12 \cdot 10^{+17} \lor \neg \left(z \leq 1.62 \cdot 10^{+16}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - z\right) + 1\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -1.12e17 or 1.62e16 < z Initial program 79.1%
div-inv79.0%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 91.4%
neg-mul-191.4%
+-commutative91.4%
unsub-neg91.4%
associate-/l*99.9%
associate-/r/94.8%
Simplified94.8%
Taylor expanded in y around inf 91.4%
associate-*r/99.9%
Simplified99.9%
if -1.12e17 < z < 1.62e16Initial program 99.9%
associate-/l*95.7%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) -2e+47) (* t_0 (/ x z)) (* x (* t_0 (/ 1.0 z))))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (((x * t_0) / z) <= -2e+47) {
tmp = t_0 * (x / z);
} else {
tmp = x * (t_0 * (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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (((x * t_0) / z) <= (-2d+47)) then
tmp = t_0 * (x / z)
else
tmp = x * (t_0 * (1.0d0 / 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 (((x * t_0) / z) <= -2e+47) {
tmp = t_0 * (x / z);
} else {
tmp = x * (t_0 * (1.0 / z));
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if ((x * t_0) / z) <= -2e+47: tmp = t_0 * (x / z) else: tmp = x * (t_0 * (1.0 / z)) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (Float64(Float64(x * t_0) / z) <= -2e+47) tmp = Float64(t_0 * Float64(x / z)); else tmp = Float64(x * Float64(t_0 * Float64(1.0 / z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (((x * t_0) / z) <= -2e+47) tmp = t_0 * (x / z); else tmp = x * (t_0 * (1.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[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], -2e+47], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(t$95$0 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;\frac{x \cdot t_0}{z} \leq -2 \cdot 10^{+47}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(t_0 \cdot \frac{1}{z}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -2.0000000000000001e47Initial program 83.8%
associate-/l*94.9%
associate-/r/99.9%
Applied egg-rr99.9%
if -2.0000000000000001e47 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 92.5%
div-inv92.4%
associate-*l*98.7%
Applied egg-rr98.7%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -75000000.0)
(- x)
(if (<= z -7e-166)
t_0
(if (<= z 1.65e-284)
(/ x z)
(if (<= z 7.6e-185) t_0 (if (<= z 8.5e-11) (/ x z) (- x))))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -75000000.0) {
tmp = -x;
} else if (z <= -7e-166) {
tmp = t_0;
} else if (z <= 1.65e-284) {
tmp = x / z;
} else if (z <= 7.6e-185) {
tmp = t_0;
} else if (z <= 8.5e-11) {
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) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-75000000.0d0)) then
tmp = -x
else if (z <= (-7d-166)) then
tmp = t_0
else if (z <= 1.65d-284) then
tmp = x / z
else if (z <= 7.6d-185) then
tmp = t_0
else if (z <= 8.5d-11) then
tmp = x / z
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 <= -75000000.0) {
tmp = -x;
} else if (z <= -7e-166) {
tmp = t_0;
} else if (z <= 1.65e-284) {
tmp = x / z;
} else if (z <= 7.6e-185) {
tmp = t_0;
} else if (z <= 8.5e-11) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -75000000.0: tmp = -x elif z <= -7e-166: tmp = t_0 elif z <= 1.65e-284: tmp = x / z elif z <= 7.6e-185: tmp = t_0 elif z <= 8.5e-11: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -75000000.0) tmp = Float64(-x); elseif (z <= -7e-166) tmp = t_0; elseif (z <= 1.65e-284) tmp = Float64(x / z); elseif (z <= 7.6e-185) tmp = t_0; elseif (z <= 8.5e-11) tmp = Float64(x / z); 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 <= -75000000.0) tmp = -x; elseif (z <= -7e-166) tmp = t_0; elseif (z <= 1.65e-284) tmp = x / z; elseif (z <= 7.6e-185) tmp = t_0; elseif (z <= 8.5e-11) tmp = x / z; 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, -75000000.0], (-x), If[LessEqual[z, -7e-166], t$95$0, If[LessEqual[z, 1.65e-284], N[(x / z), $MachinePrecision], If[LessEqual[z, 7.6e-185], t$95$0, If[LessEqual[z, 8.5e-11], N[(x / z), $MachinePrecision], (-x)]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -75000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -7 \cdot 10^{-166}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{-284}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-185}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -7.5e7 or 8.50000000000000037e-11 < z Initial program 80.5%
Taylor expanded in z around inf 77.0%
neg-mul-177.0%
Simplified77.0%
if -7.5e7 < z < -6.9999999999999998e-166 or 1.65000000000000004e-284 < z < 7.5999999999999998e-185Initial program 99.9%
div-inv99.6%
associate-*l*98.1%
Applied egg-rr98.1%
Taylor expanded in y around inf 66.7%
associate-*r/65.1%
Simplified65.1%
if -6.9999999999999998e-166 < z < 1.65000000000000004e-284 or 7.5999999999999998e-185 < z < 8.50000000000000037e-11Initial program 99.9%
Taylor expanded in y around 0 62.6%
associate-/l*62.6%
Simplified62.6%
Taylor expanded in z around 0 62.4%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -28000000.0) (not (<= y 0.0011))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -28000000.0) || !(y <= 0.0011)) {
tmp = (x * (y / z)) - 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 <= (-28000000.0d0)) .or. (.not. (y <= 0.0011d0))) then
tmp = (x * (y / z)) - 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 <= -28000000.0) || !(y <= 0.0011)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -28000000.0) or not (y <= 0.0011): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -28000000.0) || !(y <= 0.0011)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -28000000.0) || ~((y <= 0.0011))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -28000000.0], N[Not[LessEqual[y, 0.0011]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -28000000 \lor \neg \left(y \leq 0.0011\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -2.8e7 or 0.00110000000000000007 < y Initial program 89.1%
div-inv89.0%
associate-*l*94.4%
Applied egg-rr94.4%
Taylor expanded in z around 0 91.3%
neg-mul-191.3%
+-commutative91.3%
unsub-neg91.3%
associate-/l*95.3%
associate-/r/94.8%
Simplified94.8%
Taylor expanded in y around inf 90.7%
associate-*r/93.8%
Simplified93.8%
if -2.8e7 < y < 0.00110000000000000007Initial program 90.8%
Taylor expanded in y around 0 89.6%
associate-/l*98.8%
Simplified98.8%
Taylor expanded in z around 0 98.8%
neg-mul-198.8%
+-commutative98.8%
unsub-neg98.8%
Simplified98.8%
Final simplification96.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -490.0) (not (<= z 8.5e-11))) (- (* x (/ y z)) x) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -490.0) || !(z <= 8.5e-11)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x * (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 <= (-490.0d0)) .or. (.not. (z <= 8.5d-11))) then
tmp = (x * (y / z)) - x
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -490.0) || !(z <= 8.5e-11)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -490.0) or not (z <= 8.5e-11): tmp = (x * (y / z)) - x else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -490.0) || !(z <= 8.5e-11)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -490.0) || ~((z <= 8.5e-11))) tmp = (x * (y / z)) - x; else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -490.0], N[Not[LessEqual[z, 8.5e-11]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -490 \lor \neg \left(z \leq 8.5 \cdot 10^{-11}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -490 or 8.50000000000000037e-11 < z Initial program 80.7%
div-inv80.5%
associate-*l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 92.1%
neg-mul-192.1%
+-commutative92.1%
unsub-neg92.1%
associate-/l*99.9%
associate-/r/95.2%
Simplified95.2%
Taylor expanded in y around inf 90.8%
associate-*r/98.7%
Simplified98.7%
if -490 < z < 8.50000000000000037e-11Initial program 99.9%
Taylor expanded in z around 0 99.7%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (<= z -180000000.0) (- x) (if (<= z 2.1e-185) (* y (/ x z)) (if (<= z 8.5e-11) (/ x z) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -180000000.0) {
tmp = -x;
} else if (z <= 2.1e-185) {
tmp = y * (x / z);
} else if (z <= 8.5e-11) {
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 <= (-180000000.0d0)) then
tmp = -x
else if (z <= 2.1d-185) then
tmp = y * (x / z)
else if (z <= 8.5d-11) 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 <= -180000000.0) {
tmp = -x;
} else if (z <= 2.1e-185) {
tmp = y * (x / z);
} else if (z <= 8.5e-11) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -180000000.0: tmp = -x elif z <= 2.1e-185: tmp = y * (x / z) elif z <= 8.5e-11: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -180000000.0) tmp = Float64(-x); elseif (z <= 2.1e-185) tmp = Float64(y * Float64(x / z)); elseif (z <= 8.5e-11) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -180000000.0) tmp = -x; elseif (z <= 2.1e-185) tmp = y * (x / z); elseif (z <= 8.5e-11) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -180000000.0], (-x), If[LessEqual[z, 2.1e-185], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.5e-11], N[(x / z), $MachinePrecision], (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -180000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-185}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.8e8 or 8.50000000000000037e-11 < z Initial program 80.5%
Taylor expanded in z around inf 77.0%
neg-mul-177.0%
Simplified77.0%
if -1.8e8 < z < 2.1e-185Initial program 99.9%
Taylor expanded in y around inf 60.3%
associate-/l*56.1%
associate-/r/64.7%
Simplified64.7%
if 2.1e-185 < z < 8.50000000000000037e-11Initial program 99.9%
Taylor expanded in y around 0 63.0%
associate-/l*63.0%
Simplified63.0%
Taylor expanded in z around 0 62.6%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.7e+82) (not (<= y 8.3e+14))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.7e+82) || !(y <= 8.3e+14)) {
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 <= (-3.7d+82)) .or. (.not. (y <= 8.3d+14))) 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 <= -3.7e+82) || !(y <= 8.3e+14)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.7e+82) or not (y <= 8.3e+14): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.7e+82) || !(y <= 8.3e+14)) 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 <= -3.7e+82) || ~((y <= 8.3e+14))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.7e+82], N[Not[LessEqual[y, 8.3e+14]], $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 -3.7 \cdot 10^{+82} \lor \neg \left(y \leq 8.3 \cdot 10^{+14}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -3.7000000000000002e82 or 8.3e14 < y Initial program 89.0%
Taylor expanded in y around inf 77.9%
associate-/l*75.4%
associate-/r/76.2%
Simplified76.2%
if -3.7000000000000002e82 < y < 8.3e14Initial program 90.7%
Taylor expanded in y around 0 84.4%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in z around 0 93.8%
neg-mul-193.8%
+-commutative93.8%
unsub-neg93.8%
Simplified93.8%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (<= y -3.7e+82) (/ (* x y) z) (if (<= y 46000000000000.0) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.7e+82) {
tmp = (x * y) / z;
} else if (y <= 46000000000000.0) {
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 <= (-3.7d+82)) then
tmp = (x * y) / z
else if (y <= 46000000000000.0d0) 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 <= -3.7e+82) {
tmp = (x * y) / z;
} else if (y <= 46000000000000.0) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.7e+82: tmp = (x * y) / z elif y <= 46000000000000.0: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.7e+82) tmp = Float64(Float64(x * y) / z); elseif (y <= 46000000000000.0) 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 <= -3.7e+82) tmp = (x * y) / z; elseif (y <= 46000000000000.0) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.7e+82], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 46000000000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+82}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 46000000000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.7000000000000002e82Initial program 85.1%
Taylor expanded in y around inf 80.0%
if -3.7000000000000002e82 < y < 4.6e13Initial program 90.7%
Taylor expanded in y around 0 84.4%
associate-/l*93.8%
Simplified93.8%
Taylor expanded in z around 0 93.8%
neg-mul-193.8%
+-commutative93.8%
unsub-neg93.8%
Simplified93.8%
if 4.6e13 < y Initial program 92.8%
Taylor expanded in y around inf 75.9%
associate-/l*75.6%
associate-/r/77.4%
Simplified77.4%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (- (* (/ x z) (+ y 1.0)) x))
double code(double x, double y, double z) {
return ((x / z) * (y + 1.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 = ((x / z) * (y + 1.0d0)) - x
end function
public static double code(double x, double y, double z) {
return ((x / z) * (y + 1.0)) - x;
}
def code(x, y, z): return ((x / z) * (y + 1.0)) - x
function code(x, y, z) return Float64(Float64(Float64(x / z) * Float64(y + 1.0)) - x) end
function tmp = code(x, y, z) tmp = ((x / z) * (y + 1.0)) - x; end
code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} \cdot \left(y + 1\right) - x
\end{array}
Initial program 90.0%
div-inv89.8%
associate-*l*97.2%
Applied egg-rr97.2%
Taylor expanded in z around 0 95.9%
neg-mul-195.9%
+-commutative95.9%
unsub-neg95.9%
associate-/l*97.7%
associate-/r/97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (<= z -0.245) (- x) (if (<= z 8.5e-11) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.245) {
tmp = -x;
} else if (z <= 8.5e-11) {
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 <= (-0.245d0)) then
tmp = -x
else if (z <= 8.5d-11) 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 <= -0.245) {
tmp = -x;
} else if (z <= 8.5e-11) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.245: tmp = -x elif z <= 8.5e-11: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.245) tmp = Float64(-x); elseif (z <= 8.5e-11) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.245) tmp = -x; elseif (z <= 8.5e-11) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.245], (-x), If[LessEqual[z, 8.5e-11], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.245:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -0.245 or 8.50000000000000037e-11 < z Initial program 80.9%
Taylor expanded in z around inf 75.3%
neg-mul-175.3%
Simplified75.3%
if -0.245 < z < 8.50000000000000037e-11Initial program 99.9%
Taylor expanded in y around 0 56.7%
associate-/l*56.7%
Simplified56.7%
Taylor expanded in z around 0 56.5%
Final simplification66.4%
(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%
Taylor expanded in z around inf 40.8%
neg-mul-140.8%
Simplified40.8%
Final simplification40.8%
(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 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%
Taylor expanded in z around inf 32.3%
associate-*r*32.3%
neg-mul-132.3%
Simplified32.3%
div-inv32.3%
associate-*l*40.8%
div-inv40.8%
*-inverses40.8%
*-commutative40.8%
*-un-lft-identity40.8%
neg-sub040.8%
metadata-eval40.8%
sub-neg40.8%
metadata-eval40.8%
add-sqr-sqrt18.4%
sqrt-unprod16.7%
sqr-neg16.7%
sqrt-unprod2.0%
add-sqr-sqrt3.4%
Applied egg-rr3.4%
+-lft-identity3.4%
Simplified3.4%
Final simplification3.4%
(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 2023285
(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))