
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\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 x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= x -8e+122) (not (<= x 1e-40))) (- y (/ x (/ z (+ y -1.0)))) (+ (/ x z) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8e+122) || !(x <= 1e-40)) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = (x / z) + (y * (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 ((x <= (-8d+122)) .or. (.not. (x <= 1d-40))) then
tmp = y - (x / (z / (y + (-1.0d0))))
else
tmp = (x / z) + (y * (1.0d0 - (x / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8e+122) || !(x <= 1e-40)) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = (x / z) + (y * (1.0 - (x / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8e+122) or not (x <= 1e-40): tmp = y - (x / (z / (y + -1.0))) else: tmp = (x / z) + (y * (1.0 - (x / z))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8e+122) || !(x <= 1e-40)) tmp = Float64(y - Float64(x / Float64(z / Float64(y + -1.0)))); else tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8e+122) || ~((x <= 1e-40))) tmp = y - (x / (z / (y + -1.0))); else tmp = (x / z) + (y * (1.0 - (x / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8e+122], N[Not[LessEqual[x, 1e-40]], $MachinePrecision]], N[(y - N[(x / N[(z / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8 \cdot 10^{+122} \lor \neg \left(x \leq 10^{-40}\right):\\
\;\;\;\;y - \frac{x}{\frac{z}{y + -1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if x < -8.00000000000000012e122 or 9.9999999999999993e-41 < x Initial program 90.7%
Taylor expanded in y around 0 78.0%
Taylor expanded in z around -inf 94.5%
mul-1-neg94.5%
unsub-neg94.5%
distribute-rgt-out94.5%
associate-/l*99.9%
Simplified99.9%
if -8.00000000000000012e122 < x < 9.9999999999999993e-41Initial program 91.5%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e+23) (not (<= y 1e+43))) (/ y (/ z (- z x))) (- y (/ x (/ z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+23) || !(y <= 1e+43)) {
tmp = y / (z / (z - x));
} else {
tmp = y - (x / (z / (y + -1.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) :: tmp
if ((y <= (-1.2d+23)) .or. (.not. (y <= 1d+43))) then
tmp = y / (z / (z - x))
else
tmp = y - (x / (z / (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+23) || !(y <= 1e+43)) {
tmp = y / (z / (z - x));
} else {
tmp = y - (x / (z / (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e+23) or not (y <= 1e+43): tmp = y / (z / (z - x)) else: tmp = y - (x / (z / (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e+23) || !(y <= 1e+43)) tmp = Float64(y / Float64(z / Float64(z - x))); else tmp = Float64(y - Float64(x / Float64(z / Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e+23) || ~((y <= 1e+43))) tmp = y / (z / (z - x)); else tmp = y - (x / (z / (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e+23], N[Not[LessEqual[y, 1e+43]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / N[(z / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+23} \lor \neg \left(y \leq 10^{+43}\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{\frac{z}{y + -1}}\\
\end{array}
\end{array}
if y < -1.2e23 or 1.00000000000000001e43 < y Initial program 80.4%
Taylor expanded in y around inf 80.4%
associate-/l*99.9%
Simplified99.9%
if -1.2e23 < y < 1.00000000000000001e43Initial program 99.3%
Taylor expanded in y around 0 93.1%
Taylor expanded in z around -inf 99.3%
mul-1-neg99.3%
unsub-neg99.3%
distribute-rgt-out99.4%
associate-/l*100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+50) (not (<= z 2e-161))) (- y (/ x (/ z (+ y -1.0)))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+50) || !(z <= 2e-161)) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = (x + (y * (z - 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 <= (-2d+50)) .or. (.not. (z <= 2d-161))) then
tmp = y - (x / (z / (y + (-1.0d0))))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+50) || !(z <= 2e-161)) {
tmp = y - (x / (z / (y + -1.0)));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+50) or not (z <= 2e-161): tmp = y - (x / (z / (y + -1.0))) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+50) || !(z <= 2e-161)) tmp = Float64(y - Float64(x / Float64(z / Float64(y + -1.0)))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+50) || ~((z <= 2e-161))) tmp = y - (x / (z / (y + -1.0))); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+50], N[Not[LessEqual[z, 2e-161]], $MachinePrecision]], N[(y - N[(x / N[(z / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+50} \lor \neg \left(z \leq 2 \cdot 10^{-161}\right):\\
\;\;\;\;y - \frac{x}{\frac{z}{y + -1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if z < -2.0000000000000002e50 or 2.00000000000000006e-161 < z Initial program 83.3%
Taylor expanded in y around 0 99.2%
Taylor expanded in z around -inf 95.9%
mul-1-neg95.9%
unsub-neg95.9%
distribute-rgt-out95.9%
associate-/l*99.9%
Simplified99.9%
if -2.0000000000000002e50 < z < 2.00000000000000006e-161Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.75e+196) (and (not (<= y -950000.0)) (<= y 3.5e+87))) (+ y (/ x z)) (* (/ x z) (- y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.75e+196) || (!(y <= -950000.0) && (y <= 3.5e+87))) {
tmp = y + (x / z);
} 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 <= (-1.75d+196)) .or. (.not. (y <= (-950000.0d0))) .and. (y <= 3.5d+87)) then
tmp = y + (x / z)
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 <= -1.75e+196) || (!(y <= -950000.0) && (y <= 3.5e+87))) {
tmp = y + (x / z);
} else {
tmp = (x / z) * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.75e+196) or (not (y <= -950000.0) and (y <= 3.5e+87)): tmp = y + (x / z) else: tmp = (x / z) * -y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.75e+196) || (!(y <= -950000.0) && (y <= 3.5e+87))) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(x / z) * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.75e+196) || (~((y <= -950000.0)) && (y <= 3.5e+87))) tmp = y + (x / z); else tmp = (x / z) * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.75e+196], And[N[Not[LessEqual[y, -950000.0]], $MachinePrecision], LessEqual[y, 3.5e+87]]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+196} \lor \neg \left(y \leq -950000\right) \land y \leq 3.5 \cdot 10^{+87}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -1.7499999999999999e196 or -9.5e5 < y < 3.49999999999999986e87Initial program 93.7%
Taylor expanded in y around 0 94.4%
Taylor expanded in z around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
distribute-rgt-out97.9%
associate-/l*97.3%
Simplified97.3%
Taylor expanded in y around 0 90.7%
associate-*r/90.7%
neg-mul-190.7%
Simplified90.7%
Taylor expanded in y around 0 90.7%
+-commutative90.7%
Simplified90.7%
if -1.7499999999999999e196 < y < -9.5e5 or 3.49999999999999986e87 < y Initial program 85.5%
Taylor expanded in y around inf 84.8%
associate-/l*99.2%
Simplified99.2%
Taylor expanded in z around 0 66.7%
associate-*r/66.7%
neg-mul-166.7%
Simplified66.7%
Taylor expanded in y around 0 65.7%
mul-1-neg65.7%
associate-*r/66.8%
distribute-rgt-neg-in66.8%
mul-1-neg66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Final simplification83.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))))
(if (<= y -4.3e+191)
t_0
(if (<= y -950000.0)
(/ (* x (- y)) z)
(if (<= y 4.4e+86) t_0 (* (/ x z) (- y)))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -4.3e+191) {
tmp = t_0;
} else if (y <= -950000.0) {
tmp = (x * -y) / z;
} else if (y <= 4.4e+86) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y + (x / z)
if (y <= (-4.3d+191)) then
tmp = t_0
else if (y <= (-950000.0d0)) then
tmp = (x * -y) / z
else if (y <= 4.4d+86) then
tmp = t_0
else
tmp = (x / z) * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -4.3e+191) {
tmp = t_0;
} else if (y <= -950000.0) {
tmp = (x * -y) / z;
} else if (y <= 4.4e+86) {
tmp = t_0;
} else {
tmp = (x / z) * -y;
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) tmp = 0 if y <= -4.3e+191: tmp = t_0 elif y <= -950000.0: tmp = (x * -y) / z elif y <= 4.4e+86: tmp = t_0 else: tmp = (x / z) * -y return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -4.3e+191) tmp = t_0; elseif (y <= -950000.0) tmp = Float64(Float64(x * Float64(-y)) / z); elseif (y <= 4.4e+86) tmp = t_0; else tmp = Float64(Float64(x / z) * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); tmp = 0.0; if (y <= -4.3e+191) tmp = t_0; elseif (y <= -950000.0) tmp = (x * -y) / z; elseif (y <= 4.4e+86) tmp = t_0; else tmp = (x / z) * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.3e+191], t$95$0, If[LessEqual[y, -950000.0], N[(N[(x * (-y)), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 4.4e+86], t$95$0, N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -4.3 \cdot 10^{+191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -950000:\\
\;\;\;\;\frac{x \cdot \left(-y\right)}{z}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -4.2999999999999998e191 or -9.5e5 < y < 4.40000000000000006e86Initial program 93.7%
Taylor expanded in y around 0 94.4%
Taylor expanded in z around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
distribute-rgt-out97.9%
associate-/l*97.3%
Simplified97.3%
Taylor expanded in y around 0 90.7%
associate-*r/90.7%
neg-mul-190.7%
Simplified90.7%
Taylor expanded in y around 0 90.7%
+-commutative90.7%
Simplified90.7%
if -4.2999999999999998e191 < y < -9.5e5Initial program 80.8%
Taylor expanded in y around inf 79.4%
Taylor expanded in z around 0 65.3%
mul-1-neg65.3%
distribute-rgt-neg-out65.3%
Simplified65.3%
if 4.40000000000000006e86 < y Initial program 89.2%
Taylor expanded in y around inf 89.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 67.9%
associate-*r/67.9%
neg-mul-167.9%
Simplified67.9%
Taylor expanded in y around 0 66.0%
mul-1-neg66.0%
associate-*r/68.1%
distribute-rgt-neg-in68.1%
mul-1-neg68.1%
associate-*r/68.1%
neg-mul-168.1%
Simplified68.1%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4e+31) (not (<= x 2.8e+91))) (* (/ x z) (- 1.0 y)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+31) || !(x <= 2.8e+91)) {
tmp = (x / z) * (1.0 - y);
} 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 ((x <= (-1.4d+31)) .or. (.not. (x <= 2.8d+91))) then
tmp = (x / z) * (1.0d0 - y)
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+31) || !(x <= 2.8e+91)) {
tmp = (x / z) * (1.0 - y);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4e+31) or not (x <= 2.8e+91): tmp = (x / z) * (1.0 - y) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4e+31) || !(x <= 2.8e+91)) tmp = Float64(Float64(x / z) * Float64(1.0 - y)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4e+31) || ~((x <= 2.8e+91))) tmp = (x / z) * (1.0 - y); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.4e+31], N[Not[LessEqual[x, 2.8e+91]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+31} \lor \neg \left(x \leq 2.8 \cdot 10^{+91}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.40000000000000008e31 or 2.7999999999999999e91 < x Initial program 92.6%
Taylor expanded in x around inf 89.9%
*-commutative89.9%
associate-/l*93.0%
mul-1-neg93.0%
unsub-neg93.0%
Simplified93.0%
associate-/r/93.0%
Applied egg-rr93.0%
if -1.40000000000000008e31 < x < 2.7999999999999999e91Initial program 90.4%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
distribute-rgt-out99.5%
associate-/l*89.8%
Simplified89.8%
Taylor expanded in y around 0 84.5%
associate-*r/84.5%
neg-mul-184.5%
Simplified84.5%
Taylor expanded in y around 0 84.5%
+-commutative84.5%
Simplified84.5%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -118.0) (not (<= y 1.0))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -118.0) || !(y <= 1.0)) {
tmp = y / (z / (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 <= (-118.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y / (z / (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 <= -118.0) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -118.0) or not (y <= 1.0): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -118.0) || !(y <= 1.0)) tmp = Float64(y / Float64(z / Float64(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 <= -118.0) || ~((y <= 1.0))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -118.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -118 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -118 or 1 < y Initial program 82.3%
Taylor expanded in y around inf 80.9%
associate-/l*98.5%
Simplified98.5%
if -118 < y < 1Initial program 99.9%
Taylor expanded in y around 0 93.8%
Taylor expanded in z around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
distribute-rgt-out100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 98.4%
associate-*r/98.4%
neg-mul-198.4%
Simplified98.4%
Taylor expanded in y around 0 98.4%
+-commutative98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.55e+44) y (if (<= z 1.5e+29) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e+44) {
tmp = y;
} else if (z <= 1.5e+29) {
tmp = x / z;
} else {
tmp = 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 (z <= (-1.55d+44)) then
tmp = y
else if (z <= 1.5d+29) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.55e+44) {
tmp = y;
} else if (z <= 1.5e+29) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.55e+44: tmp = y elif z <= 1.5e+29: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.55e+44) tmp = y; elseif (z <= 1.5e+29) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.55e+44) tmp = y; elseif (z <= 1.5e+29) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.55e+44], y, If[LessEqual[z, 1.5e+29], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{+44}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{+29}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if z < -1.54999999999999998e44 or 1.5e29 < z Initial program 78.3%
Taylor expanded in x around 0 75.0%
if -1.54999999999999998e44 < z < 1.5e29Initial program 100.0%
Taylor expanded in y around 0 50.8%
Final simplification60.6%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = z * (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 = y + (x / z)
else
tmp = z * (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 = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 1Initial program 92.1%
Taylor expanded in y around 0 95.8%
Taylor expanded in z around -inf 99.0%
mul-1-neg99.0%
unsub-neg99.0%
distribute-rgt-out99.0%
associate-/l*95.1%
Simplified95.1%
Taylor expanded in y around 0 86.8%
associate-*r/86.8%
neg-mul-186.8%
Simplified86.8%
Taylor expanded in y around 0 86.8%
+-commutative86.8%
Simplified86.8%
if 1 < y Initial program 88.4%
Taylor expanded in y around inf 87.5%
Taylor expanded in z around inf 36.7%
associate-/l*42.5%
associate-/r/48.5%
Applied egg-rr48.5%
Final simplification77.2%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} 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 <= 1.0d0) then
tmp = y + (x / z)
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 <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 92.1%
Taylor expanded in y around 0 95.8%
Taylor expanded in z around -inf 99.0%
mul-1-neg99.0%
unsub-neg99.0%
distribute-rgt-out99.0%
associate-/l*95.1%
Simplified95.1%
Taylor expanded in y around 0 86.8%
associate-*r/86.8%
neg-mul-186.8%
Simplified86.8%
Taylor expanded in y around 0 86.8%
+-commutative86.8%
Simplified86.8%
if 1 < y Initial program 88.4%
Taylor expanded in y around 0 78.1%
Taylor expanded in z around -inf 94.2%
mul-1-neg94.2%
unsub-neg94.2%
distribute-rgt-out94.3%
associate-/l*87.9%
Simplified87.9%
Taylor expanded in y around 0 41.3%
associate-*r/41.3%
neg-mul-141.3%
Simplified41.3%
add-sqr-sqrt41.0%
add-sqr-sqrt22.3%
difference-of-squares22.3%
add-sqr-sqrt10.9%
sqrt-unprod15.8%
sqr-neg15.8%
sqrt-unprod4.7%
add-sqr-sqrt7.8%
add-sqr-sqrt3.1%
sqrt-unprod29.8%
sqr-neg29.8%
sqrt-unprod23.7%
add-sqr-sqrt37.7%
Applied egg-rr37.7%
/-rgt-identity37.7%
*-inverses37.7%
associate-/r/32.0%
*-commutative32.0%
unpow1/232.0%
metadata-eval32.0%
/-rgt-identity32.0%
*-inverses32.0%
associate-/r/24.2%
*-commutative24.2%
unpow1/224.2%
metadata-eval24.2%
difference-of-squares24.2%
sqr-pow24.3%
unpow124.3%
rem-square-sqrt53.6%
Simplified64.3%
Final simplification81.2%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 91.2%
Taylor expanded in x around 0 40.5%
Final simplification40.5%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2023279
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))