
(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 10 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 (<= t_0 (- INFINITY))
(+ y (* x (/ (- 1.0 y) z)))
(if (<= t_0 5e+264)
(+ y (- (/ x z) (/ (* x y) z)))
(* y (- 1.0 (/ x z)))))))
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = y + (x * ((1.0 - y) / z));
} else if (t_0 <= 5e+264) {
tmp = y + ((x / z) - ((x * y) / z));
} else {
tmp = y * (1.0 - (x / 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) {
tmp = y + (x * ((1.0 - y) / z));
} else if (t_0 <= 5e+264) {
tmp = y + ((x / z) - ((x * y) / z));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): t_0 = (x + (y * (z - x))) / z tmp = 0 if t_0 <= -math.inf: tmp = y + (x * ((1.0 - y) / z)) elif t_0 <= 5e+264: tmp = y + ((x / z) - ((x * y) / z)) else: tmp = y * (1.0 - (x / 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)) tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); elseif (t_0 <= 5e+264) tmp = Float64(y + Float64(Float64(x / z) - Float64(Float64(x * y) / z))); else tmp = Float64(y * Float64(1.0 - Float64(x / 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) tmp = y + (x * ((1.0 - y) / z)); elseif (t_0 <= 5e+264) tmp = y + ((x / z) - ((x * y) / z)); else tmp = y * (1.0 - (x / 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[LessEqual[t$95$0, (-Infinity)], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+264], N[(y + N[(N[(x / z), $MachinePrecision] - N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;y + \left(\frac{x}{z} - \frac{x \cdot y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0Initial program 74.3%
Taylor expanded in z around inf 64.7%
Taylor expanded in x around 0 100.0%
+-commutative100.0%
neg-mul-1100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 5.00000000000000033e264Initial program 99.8%
Taylor expanded in z around inf 99.9%
if 5.00000000000000033e264 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 53.0%
Taylor expanded in y around inf 48.7%
associate-/l*99.9%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -56000000000000.0) (not (<= y 9.4e+23))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -56000000000000.0) || !(y <= 9.4e+23)) {
tmp = y * (1.0 - (x / z));
} 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 ((y <= (-56000000000000.0d0)) .or. (.not. (y <= 9.4d+23))) then
tmp = y * (1.0d0 - (x / z))
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 ((y <= -56000000000000.0) || !(y <= 9.4e+23)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -56000000000000.0) or not (y <= 9.4e+23): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -56000000000000.0) || !(y <= 9.4e+23)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); 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 ((y <= -56000000000000.0) || ~((y <= 9.4e+23))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -56000000000000.0], N[Not[LessEqual[y, 9.4e+23]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -56000000000000 \lor \neg \left(y \leq 9.4 \cdot 10^{+23}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -5.6e13 or 9.3999999999999994e23 < y Initial program 74.5%
Taylor expanded in y around inf 74.5%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -5.6e13 < y < 9.3999999999999994e23Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.8e-21) (not (<= x 9.8e-6))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.8e-21) || !(x <= 9.8e-6)) {
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 <= (-5.8d-21)) .or. (.not. (x <= 9.8d-6))) 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 <= -5.8e-21) || !(x <= 9.8e-6)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.8e-21) or not (x <= 9.8e-6): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.8e-21) || !(x <= 9.8e-6)) 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 <= -5.8e-21) || ~((x <= 9.8e-6))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.8e-21], N[Not[LessEqual[x, 9.8e-6]], $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 -5.8 \cdot 10^{-21} \lor \neg \left(x \leq 9.8 \cdot 10^{-6}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -5.8e-21 or 9.79999999999999934e-6 < x Initial program 89.3%
Taylor expanded in x around inf 83.5%
associate-/l*87.8%
mul-1-neg87.8%
unsub-neg87.8%
Simplified87.8%
if -5.8e-21 < x < 9.79999999999999934e-6Initial program 84.7%
Taylor expanded in z around inf 99.9%
Taylor expanded in y around 0 84.1%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 2.45e-14))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 2.45e-14)) {
tmp = y * (1.0 - (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)) .or. (.not. (y <= 2.45d-14))) then
tmp = y * (1.0d0 - (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) || !(y <= 2.45e-14)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 2.45e-14): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 2.45e-14)) tmp = Float64(y * Float64(1.0 - 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) || ~((y <= 2.45e-14))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 2.45e-14]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.45 \cdot 10^{-14}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 2.44999999999999997e-14 < y Initial program 76.6%
Taylor expanded in y around inf 76.1%
associate-/l*99.4%
div-sub99.4%
*-inverses99.4%
Simplified99.4%
if -1 < y < 2.44999999999999997e-14Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in y around 0 100.0%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= z 1e-27) (+ y (/ 1.0 (/ z (* x (- 1.0 y))))) (+ y (* x (/ (- 1.0 y) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e-27) {
tmp = y + (1.0 / (z / (x * (1.0 - y))));
} else {
tmp = y + (x * ((1.0 - y) / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1d-27) then
tmp = y + (1.0d0 / (z / (x * (1.0d0 - y))))
else
tmp = y + (x * ((1.0d0 - y) / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e-27) {
tmp = y + (1.0 / (z / (x * (1.0 - y))));
} else {
tmp = y + (x * ((1.0 - y) / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e-27: tmp = y + (1.0 / (z / (x * (1.0 - y)))) else: tmp = y + (x * ((1.0 - y) / z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e-27) tmp = Float64(y + Float64(1.0 / Float64(z / Float64(x * Float64(1.0 - y))))); else tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e-27) tmp = y + (1.0 / (z / (x * (1.0 - y)))); else tmp = y + (x * ((1.0 - y) / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e-27], N[(y + N[(1.0 / N[(z / N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-27}:\\
\;\;\;\;y + \frac{1}{\frac{z}{x \cdot \left(1 - y\right)}}\\
\mathbf{else}:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\end{array}
\end{array}
if z < 1e-27Initial program 90.6%
Taylor expanded in z around inf 89.3%
Taylor expanded in x around 0 93.5%
+-commutative93.5%
neg-mul-193.5%
sub-neg93.5%
div-sub93.5%
Simplified93.5%
associate-*r/98.0%
clear-num97.9%
sub-neg97.9%
distribute-rgt-in97.9%
*-un-lft-identity97.9%
distribute-lft-neg-in97.9%
distribute-rgt-neg-out97.9%
+-commutative97.9%
*-commutative97.9%
fma-define97.9%
add-sqr-sqrt54.6%
sqrt-unprod69.2%
sqr-neg69.2%
sqrt-unprod27.9%
add-sqr-sqrt63.2%
Applied egg-rr63.2%
/-rgt-identity63.2%
clear-num63.2%
associate-/r/63.1%
fma-undefine63.1%
distribute-lft-in61.1%
add-sqr-sqrt39.6%
sqrt-unprod66.7%
sqr-neg66.7%
mul-1-neg66.7%
mul-1-neg66.7%
sqrt-unprod51.9%
add-sqr-sqrt89.0%
*-commutative89.0%
div-inv89.2%
+-commutative89.2%
*-un-lft-identity89.2%
*-commutative89.2%
mul-1-neg89.2%
associate-*r*90.5%
Applied egg-rr98.0%
associate-/l/97.9%
associate-*r/97.9%
*-rgt-identity97.9%
Simplified97.9%
if 1e-27 < z Initial program 76.0%
Taylor expanded in z around inf 89.4%
Taylor expanded in x around 0 99.8%
+-commutative99.8%
neg-mul-199.8%
sub-neg99.8%
div-sub99.8%
Simplified99.8%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= y -2e+65) (* y (- 1.0 (/ x z))) (+ y (* x (/ (- 1.0 y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+65) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x * ((1.0 - y) / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2d+65)) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x * ((1.0d0 - y) / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e+65) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x * ((1.0 - y) / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+65: tmp = y * (1.0 - (x / z)) else: tmp = y + (x * ((1.0 - y) / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+65) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+65) tmp = y * (1.0 - (x / z)); else tmp = y + (x * ((1.0 - y) / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+65], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+65}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\end{array}
\end{array}
if y < -2e65Initial program 77.4%
Taylor expanded in y around inf 77.4%
associate-/l*99.9%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
if -2e65 < y Initial program 89.7%
Taylor expanded in z around inf 88.8%
Taylor expanded in x around 0 97.9%
+-commutative97.9%
neg-mul-197.9%
sub-neg97.9%
div-sub97.9%
Simplified97.9%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.1e-27) (not (<= x 1.5e-8))) (/ x z) y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.1e-27) || !(x <= 1.5e-8)) {
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 ((x <= (-6.1d-27)) .or. (.not. (x <= 1.5d-8))) 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 ((x <= -6.1e-27) || !(x <= 1.5e-8)) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6.1e-27) or not (x <= 1.5e-8): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6.1e-27) || !(x <= 1.5e-8)) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6.1e-27) || ~((x <= 1.5e-8))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6.1e-27], N[Not[LessEqual[x, 1.5e-8]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{-27} \lor \neg \left(x \leq 1.5 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -6.0999999999999999e-27 or 1.49999999999999987e-8 < x Initial program 89.0%
Taylor expanded in y around 0 55.8%
if -6.0999999999999999e-27 < x < 1.49999999999999987e-8Initial program 84.8%
Taylor expanded in x around 0 64.3%
Final simplification59.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.45e-14) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.45e-14) {
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 <= 2.45d-14) 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 <= 2.45e-14) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.45e-14: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.45e-14) 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 <= 2.45e-14) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.45e-14], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{-14}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 2.44999999999999997e-14Initial program 93.0%
Taylor expanded in z around inf 96.7%
Taylor expanded in y around 0 85.2%
if 2.44999999999999997e-14 < y Initial program 73.8%
Taylor expanded in z around inf 72.6%
Taylor expanded in y around 0 50.7%
add-sqr-sqrt23.4%
sqrt-unprod62.5%
sqr-neg62.5%
sqrt-unprod37.2%
add-sqr-sqrt72.3%
distribute-neg-frac272.3%
sub-neg72.3%
Applied egg-rr72.3%
Final simplification81.2%
(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 87.1%
Taylor expanded in z around inf 89.3%
Taylor expanded in y around 0 74.5%
Final simplification74.5%
(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 87.1%
Taylor expanded in x around 0 37.3%
Final simplification37.3%
(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 2024077
(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))