
(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
(let* ((t_0 (/ (+ x (* y (- z x))) z)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+306)))
(+ y (* x (- (/ 1.0 z) (/ y z))))
(/ (+ x (- (* y z) (* x y))) z))))
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+306)) {
tmp = y + (x * ((1.0 / z) - (y / z)));
} else {
tmp = (x + ((y * z) - (x * y))) / z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e+306)) {
tmp = y + (x * ((1.0 / z) - (y / z)));
} else {
tmp = (x + ((y * z) - (x * y))) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (x + (y * (z - x))) / z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e+306): tmp = y + (x * ((1.0 / z) - (y / z))) else: tmp = (x + ((y * z) - (x * y))) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+306)) tmp = Float64(y + Float64(x * Float64(Float64(1.0 / z) - Float64(y / z)))); else tmp = Float64(Float64(x + Float64(Float64(y * z) - Float64(x * y))) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + (y * (z - x))) / z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e+306))) tmp = y + (x * ((1.0 / z) - (y / z))); else tmp = (x + ((y * z) - (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+306]], $MachinePrecision]], N[(y + N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(y * z), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 10^{+306}\right):\\
\;\;\;\;y + x \cdot \left(\frac{1}{z} - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + \left(y \cdot z - x \cdot y\right)}{z}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0 or 1.00000000000000002e306 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 62.9%
Taylor expanded in x around 0 100.0%
if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 1.00000000000000002e306Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y -2000.0) (- y (* y (/ x z))) (if (<= y 6e+27) (/ (+ x (* y (- z x))) z) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2000.0) {
tmp = y - (y * (x / z));
} else if (y <= 6e+27) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = 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 (y <= (-2000.0d0)) then
tmp = y - (y * (x / z))
else if (y <= 6d+27) then
tmp = (x + (y * (z - x))) / z
else
tmp = y * ((z - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2000.0) {
tmp = y - (y * (x / z));
} else if (y <= 6e+27) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2000.0: tmp = y - (y * (x / z)) elif y <= 6e+27: tmp = (x + (y * (z - x))) / z else: tmp = y * ((z - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2000.0) tmp = Float64(y - Float64(y * Float64(x / z))); elseif (y <= 6e+27) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2000.0) tmp = y - (y * (x / z)); elseif (y <= 6e+27) tmp = (x + (y * (z - x))) / z; else tmp = y * ((z - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2000.0], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+27], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2000:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+27}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -2e3Initial program 77.3%
Taylor expanded in x around 0 92.7%
Taylor expanded in y around inf 92.8%
mul-1-neg92.8%
distribute-neg-frac292.8%
associate-*r/92.6%
Simplified92.6%
*-commutative92.6%
add-sqr-sqrt41.8%
sqrt-unprod61.3%
sqr-neg61.3%
sqrt-unprod23.6%
add-sqr-sqrt48.1%
cancel-sign-sub48.1%
distribute-frac-neg248.1%
distribute-frac-neg248.1%
distribute-frac-neg48.1%
div-inv48.1%
associate-*l*52.2%
add-sqr-sqrt52.2%
sqrt-unprod26.1%
sqr-neg26.1%
sqrt-unprod0.0%
add-sqr-sqrt99.7%
associate-*l/99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if -2e3 < y < 5.99999999999999953e27Initial program 100.0%
if 5.99999999999999953e27 < y Initial program 70.7%
Taylor expanded in y around inf 70.7%
associate-/l*100.0%
Simplified100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -2020.0) (not (<= y 1.0))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2020.0) || !(y <= 1.0)) {
tmp = y * ((z - 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 <= (-2020.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y * ((z - 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 <= -2020.0) || !(y <= 1.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2020.0) or not (y <= 1.0): tmp = y * ((z - x) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2020.0) || !(y <= 1.0)) tmp = Float64(y * Float64(Float64(z - 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 <= -2020.0) || ~((y <= 1.0))) tmp = y * ((z - x) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2020.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2020 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2020 or 1 < y Initial program 75.4%
Taylor expanded in y around inf 75.3%
associate-/l*99.8%
Simplified99.8%
if -2020 < y < 1Initial program 99.2%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 98.1%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.5e+117) (not (<= x 1.52e+71))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e+117) || !(x <= 1.52e+71)) {
tmp = x * ((1.0 - y) / 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 ((x <= (-1.5d+117)) .or. (.not. (x <= 1.52d+71))) then
tmp = x * ((1.0d0 - y) / 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 ((x <= -1.5e+117) || !(x <= 1.52e+71)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.5e+117) or not (x <= 1.52e+71): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.5e+117) || !(x <= 1.52e+71)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.5e+117) || ~((x <= 1.52e+71))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.5e+117], N[Not[LessEqual[x, 1.52e+71]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+117} \lor \neg \left(x \leq 1.52 \cdot 10^{+71}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.5e117 or 1.5199999999999999e71 < x Initial program 92.2%
Taylor expanded in x around inf 87.7%
associate-/l*91.6%
mul-1-neg91.6%
unsub-neg91.6%
Simplified91.6%
if -1.5e117 < x < 1.5199999999999999e71Initial program 83.5%
Taylor expanded in x around 0 93.2%
Taylor expanded in y around 0 85.4%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (<= y -2020.0) (- y (* y (/ x z))) (if (<= y 1.0) (+ y (/ x z)) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2020.0) {
tmp = y - (y * (x / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = 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 (y <= (-2020.0d0)) then
tmp = y - (y * (x / z))
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y * ((z - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2020.0) {
tmp = y - (y * (x / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2020.0: tmp = y - (y * (x / z)) elif y <= 1.0: tmp = y + (x / z) else: tmp = y * ((z - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2020.0) tmp = Float64(y - Float64(y * Float64(x / z))); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2020.0) tmp = y - (y * (x / z)); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y * ((z - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2020.0], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2020:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -2020Initial program 78.5%
Taylor expanded in x around 0 92.6%
Taylor expanded in y around inf 92.7%
mul-1-neg92.7%
distribute-neg-frac292.7%
associate-*r/92.5%
Simplified92.5%
*-commutative92.5%
add-sqr-sqrt42.5%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-unprod22.4%
add-sqr-sqrt47.4%
cancel-sign-sub47.4%
distribute-frac-neg247.4%
distribute-frac-neg247.4%
distribute-frac-neg47.4%
div-inv47.4%
associate-*l*51.5%
add-sqr-sqrt51.5%
sqrt-unprod24.9%
sqr-neg24.9%
sqrt-unprod0.0%
add-sqr-sqrt99.7%
associate-*l/99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if -2020 < y < 1Initial program 99.2%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 98.1%
if 1 < y Initial program 72.4%
Taylor expanded in y around inf 72.4%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z 4.5e-287) (not (<= z 7.2e-198))) (+ y (/ x z)) (* (/ x z) (- y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 4.5e-287) || !(z <= 7.2e-198)) {
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 ((z <= 4.5d-287) .or. (.not. (z <= 7.2d-198))) 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 ((z <= 4.5e-287) || !(z <= 7.2e-198)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 4.5e-287) or not (z <= 7.2e-198): tmp = y + (x / z) else: tmp = (x / z) * -y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 4.5e-287) || !(z <= 7.2e-198)) 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 ((z <= 4.5e-287) || ~((z <= 7.2e-198))) tmp = y + (x / z); else tmp = (x / z) * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 4.5e-287], N[Not[LessEqual[z, 7.2e-198]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.5 \cdot 10^{-287} \lor \neg \left(z \leq 7.2 \cdot 10^{-198}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 4.50000000000000017e-287 or 7.19999999999999996e-198 < z Initial program 85.7%
Taylor expanded in x around 0 96.6%
Taylor expanded in y around 0 80.4%
if 4.50000000000000017e-287 < z < 7.19999999999999996e-198Initial program 99.8%
Taylor expanded in z around 0 92.2%
mul-1-neg92.2%
distribute-lft-neg-out92.2%
*-commutative92.2%
Simplified92.2%
*-un-lft-identity92.2%
distribute-rgt-neg-out92.2%
distribute-lft-neg-in92.2%
distribute-rgt-in92.1%
sub-neg92.1%
*-commutative92.1%
associate-*l/84.2%
div-inv84.3%
associate-*l*92.2%
associate-*l/92.2%
*-un-lft-identity92.2%
Applied egg-rr92.2%
Taylor expanded in y around inf 77.7%
neg-mul-177.7%
Simplified77.7%
Final simplification80.2%
(FPCore (x y z) :precision binary64 (if (<= y -6.2e-41) y (if (<= y 1.2e-11) (/ x z) (* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e-41) {
tmp = y;
} else if (y <= 1.2e-11) {
tmp = 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 <= (-6.2d-41)) then
tmp = y
else if (y <= 1.2d-11) then
tmp = 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 <= -6.2e-41) {
tmp = y;
} else if (y <= 1.2e-11) {
tmp = x / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.2e-41: tmp = y elif y <= 1.2e-11: tmp = x / z else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.2e-41) tmp = y; elseif (y <= 1.2e-11) tmp = 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 <= -6.2e-41) tmp = y; elseif (y <= 1.2e-11) tmp = x / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.2e-41], y, If[LessEqual[y, 1.2e-11], N[(x / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-41}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -6.20000000000000001e-41Initial program 79.5%
Taylor expanded in x around 0 52.6%
if -6.20000000000000001e-41 < y < 1.2000000000000001e-11Initial program 100.0%
Taylor expanded in y around 0 80.3%
if 1.2000000000000001e-11 < y Initial program 72.4%
Taylor expanded in y around inf 72.4%
Taylor expanded in z around inf 31.5%
*-commutative31.5%
associate-/l*54.8%
Applied egg-rr54.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.45e-39) y (if (<= y 8e-12) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.45e-39) {
tmp = y;
} else if (y <= 8e-12) {
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 (y <= (-1.45d-39)) then
tmp = y
else if (y <= 8d-12) 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 (y <= -1.45e-39) {
tmp = y;
} else if (y <= 8e-12) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.45e-39: tmp = y elif y <= 8e-12: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.45e-39) tmp = y; elseif (y <= 8e-12) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.45e-39) tmp = y; elseif (y <= 8e-12) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.45e-39], y, If[LessEqual[y, 8e-12], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-39}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-12}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -1.44999999999999994e-39 or 7.99999999999999984e-12 < y Initial program 76.1%
Taylor expanded in x around 0 53.1%
if -1.44999999999999994e-39 < y < 7.99999999999999984e-12Initial program 100.0%
Taylor expanded in y around 0 80.3%
(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 91.9%
Taylor expanded in x around 0 97.2%
Taylor expanded in y around 0 85.7%
if 1 < y Initial program 72.4%
Taylor expanded in x around 0 91.5%
Taylor expanded in y around 0 53.1%
add-sqr-sqrt25.8%
sqrt-unprod59.1%
sqr-neg59.1%
sqrt-unprod33.7%
add-sqr-sqrt63.1%
distribute-frac-neg63.1%
sub-neg63.1%
Applied egg-rr63.1%
(FPCore (x y z) :precision binary64 (+ y (/ x z)))
double code(double x, double y, double z) {
return y + (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 = y + (x / z)
end function
public static double code(double x, double y, double z) {
return y + (x / z);
}
def code(x, y, z): return y + (x / z)
function code(x, y, z) return Float64(y + Float64(x / z)) end
function tmp = code(x, y, z) tmp = y + (x / z); end
code[x_, y_, z_] := N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z}
\end{array}
Initial program 86.7%
Taylor expanded in x around 0 95.7%
Taylor expanded in y around 0 77.1%
(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 86.7%
Taylor expanded in x around 0 39.4%
(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 2024110
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))