
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
return x + ((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 = x + ((y - x) / z)
end function
public static double code(double x, double y, double z) {
return x + ((y - x) / z);
}
def code(x, y, z): return x + ((y - x) / z)
function code(x, y, z) return Float64(x + Float64(Float64(y - x) / z)) end
function tmp = code(x, y, z) tmp = x + ((y - x) / z); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
return x + ((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 = x + ((y - x) / z)
end function
public static double code(double x, double y, double z) {
return x + ((y - x) / z);
}
def code(x, y, z): return x + ((y - x) / z)
function code(x, y, z) return Float64(x + Float64(Float64(y - x) / z)) end
function tmp = code(x, y, z) tmp = x + ((y - x) / z); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{z}
\end{array}
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
return x + ((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 = x + ((y - x) / z)
end function
public static double code(double x, double y, double z) {
return x + ((y - x) / z);
}
def code(x, y, z): return x + ((y - x) / z)
function code(x, y, z) return Float64(x + Float64(Float64(y - x) / z)) end
function tmp = code(x, y, z) tmp = x + ((y - x) / z); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{z}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x) z)))
(if (<= z -2.2e+26)
x
(if (<= z -2.8e-74)
(/ y z)
(if (<= z -1.05e-285)
t_0
(if (<= z 9.2e-268)
(/ y z)
(if (<= z 2e-133)
t_0
(if (<= z 2.6e-78) (/ y z) (if (<= z 1.0) t_0 x)))))))))
double code(double x, double y, double z) {
double t_0 = -x / z;
double tmp;
if (z <= -2.2e+26) {
tmp = x;
} else if (z <= -2.8e-74) {
tmp = y / z;
} else if (z <= -1.05e-285) {
tmp = t_0;
} else if (z <= 9.2e-268) {
tmp = y / z;
} else if (z <= 2e-133) {
tmp = t_0;
} else if (z <= 2.6e-78) {
tmp = y / z;
} else if (z <= 1.0) {
tmp = t_0;
} 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 / z
if (z <= (-2.2d+26)) then
tmp = x
else if (z <= (-2.8d-74)) then
tmp = y / z
else if (z <= (-1.05d-285)) then
tmp = t_0
else if (z <= 9.2d-268) then
tmp = y / z
else if (z <= 2d-133) then
tmp = t_0
else if (z <= 2.6d-78) then
tmp = y / z
else if (z <= 1.0d0) then
tmp = t_0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -x / z;
double tmp;
if (z <= -2.2e+26) {
tmp = x;
} else if (z <= -2.8e-74) {
tmp = y / z;
} else if (z <= -1.05e-285) {
tmp = t_0;
} else if (z <= 9.2e-268) {
tmp = y / z;
} else if (z <= 2e-133) {
tmp = t_0;
} else if (z <= 2.6e-78) {
tmp = y / z;
} else if (z <= 1.0) {
tmp = t_0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = -x / z tmp = 0 if z <= -2.2e+26: tmp = x elif z <= -2.8e-74: tmp = y / z elif z <= -1.05e-285: tmp = t_0 elif z <= 9.2e-268: tmp = y / z elif z <= 2e-133: tmp = t_0 elif z <= 2.6e-78: tmp = y / z elif z <= 1.0: tmp = t_0 else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(Float64(-x) / z) tmp = 0.0 if (z <= -2.2e+26) tmp = x; elseif (z <= -2.8e-74) tmp = Float64(y / z); elseif (z <= -1.05e-285) tmp = t_0; elseif (z <= 9.2e-268) tmp = Float64(y / z); elseif (z <= 2e-133) tmp = t_0; elseif (z <= 2.6e-78) tmp = Float64(y / z); elseif (z <= 1.0) tmp = t_0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -x / z; tmp = 0.0; if (z <= -2.2e+26) tmp = x; elseif (z <= -2.8e-74) tmp = y / z; elseif (z <= -1.05e-285) tmp = t_0; elseif (z <= 9.2e-268) tmp = y / z; elseif (z <= 2e-133) tmp = t_0; elseif (z <= 2.6e-78) tmp = y / z; elseif (z <= 1.0) tmp = t_0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) / z), $MachinePrecision]}, If[LessEqual[z, -2.2e+26], x, If[LessEqual[z, -2.8e-74], N[(y / z), $MachinePrecision], If[LessEqual[z, -1.05e-285], t$95$0, If[LessEqual[z, 9.2e-268], N[(y / z), $MachinePrecision], If[LessEqual[z, 2e-133], t$95$0, If[LessEqual[z, 2.6e-78], N[(y / z), $MachinePrecision], If[LessEqual[z, 1.0], t$95$0, x]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{z}\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{+26}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-74}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-285}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-268}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 2 \cdot 10^{-133}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-78}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.20000000000000007e26 or 1 < z Initial program 100.0%
div-sub100.0%
associate-+r-100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
unsub-neg100.0%
associate--r+100.0%
+-commutative100.0%
distribute-frac-neg100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around inf 75.4%
if -2.20000000000000007e26 < z < -2.79999999999999988e-74 or -1.04999999999999992e-285 < z < 9.20000000000000042e-268 or 2.0000000000000001e-133 < z < 2.6000000000000001e-78Initial program 100.0%
div-sub95.3%
associate-+r-95.3%
remove-double-neg95.3%
distribute-frac-neg95.3%
unsub-neg95.3%
associate--r+95.3%
+-commutative95.3%
distribute-frac-neg95.3%
sub-neg95.3%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 70.6%
if -2.79999999999999988e-74 < z < -1.04999999999999992e-285 or 9.20000000000000042e-268 < z < 2.0000000000000001e-133 or 2.6000000000000001e-78 < z < 1Initial program 100.0%
div-sub97.8%
associate-+r-97.8%
remove-double-neg97.8%
distribute-frac-neg97.8%
unsub-neg97.8%
associate--r+97.8%
+-commutative97.8%
distribute-frac-neg97.8%
sub-neg97.8%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 68.7%
distribute-lft-out--68.7%
*-rgt-identity68.7%
associate-*r/68.8%
*-rgt-identity68.8%
Simplified68.8%
Taylor expanded in z around 0 67.2%
mul-1-neg67.2%
Simplified67.2%
Final simplification71.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ y z))) (t_1 (/ (- x) z)))
(if (<= z -4.5e-75)
t_0
(if (<= z -2.9e-286)
t_1
(if (<= z 1.15e-267)
(/ y z)
(if (<= z 3e-132)
t_1
(if (<= z 2.45e-73) (/ y z) (if (<= z 0.06) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = x + (y / z);
double t_1 = -x / z;
double tmp;
if (z <= -4.5e-75) {
tmp = t_0;
} else if (z <= -2.9e-286) {
tmp = t_1;
} else if (z <= 1.15e-267) {
tmp = y / z;
} else if (z <= 3e-132) {
tmp = t_1;
} else if (z <= 2.45e-73) {
tmp = y / z;
} else if (z <= 0.06) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x + (y / z)
t_1 = -x / z
if (z <= (-4.5d-75)) then
tmp = t_0
else if (z <= (-2.9d-286)) then
tmp = t_1
else if (z <= 1.15d-267) then
tmp = y / z
else if (z <= 3d-132) then
tmp = t_1
else if (z <= 2.45d-73) then
tmp = y / z
else if (z <= 0.06d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (y / z);
double t_1 = -x / z;
double tmp;
if (z <= -4.5e-75) {
tmp = t_0;
} else if (z <= -2.9e-286) {
tmp = t_1;
} else if (z <= 1.15e-267) {
tmp = y / z;
} else if (z <= 3e-132) {
tmp = t_1;
} else if (z <= 2.45e-73) {
tmp = y / z;
} else if (z <= 0.06) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (y / z) t_1 = -x / z tmp = 0 if z <= -4.5e-75: tmp = t_0 elif z <= -2.9e-286: tmp = t_1 elif z <= 1.15e-267: tmp = y / z elif z <= 3e-132: tmp = t_1 elif z <= 2.45e-73: tmp = y / z elif z <= 0.06: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(y / z)) t_1 = Float64(Float64(-x) / z) tmp = 0.0 if (z <= -4.5e-75) tmp = t_0; elseif (z <= -2.9e-286) tmp = t_1; elseif (z <= 1.15e-267) tmp = Float64(y / z); elseif (z <= 3e-132) tmp = t_1; elseif (z <= 2.45e-73) tmp = Float64(y / z); elseif (z <= 0.06) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (y / z); t_1 = -x / z; tmp = 0.0; if (z <= -4.5e-75) tmp = t_0; elseif (z <= -2.9e-286) tmp = t_1; elseif (z <= 1.15e-267) tmp = y / z; elseif (z <= 3e-132) tmp = t_1; elseif (z <= 2.45e-73) tmp = y / z; elseif (z <= 0.06) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-x) / z), $MachinePrecision]}, If[LessEqual[z, -4.5e-75], t$95$0, If[LessEqual[z, -2.9e-286], t$95$1, If[LessEqual[z, 1.15e-267], N[(y / z), $MachinePrecision], If[LessEqual[z, 3e-132], t$95$1, If[LessEqual[z, 2.45e-73], N[(y / z), $MachinePrecision], If[LessEqual[z, 0.06], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{y}{z}\\
t_1 := \frac{-x}{z}\\
\mathbf{if}\;z \leq -4.5 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{-286}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-267}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{-73}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 0.06:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -4.5000000000000003e-75 or 0.059999999999999998 < z Initial program 100.0%
div-sub100.0%
associate-+r-100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
unsub-neg100.0%
associate--r+100.0%
+-commutative100.0%
distribute-frac-neg100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 95.7%
neg-mul-195.7%
distribute-neg-frac95.7%
Simplified95.7%
Taylor expanded in x around 0 95.7%
+-commutative95.7%
Simplified95.7%
if -4.5000000000000003e-75 < z < -2.8999999999999998e-286 or 1.15000000000000003e-267 < z < 3e-132 or 2.45000000000000014e-73 < z < 0.059999999999999998Initial program 100.0%
div-sub97.8%
associate-+r-97.8%
remove-double-neg97.8%
distribute-frac-neg97.8%
unsub-neg97.8%
associate--r+97.8%
+-commutative97.8%
distribute-frac-neg97.8%
sub-neg97.8%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 68.7%
distribute-lft-out--68.7%
*-rgt-identity68.7%
associate-*r/68.8%
*-rgt-identity68.8%
Simplified68.8%
Taylor expanded in z around 0 67.2%
mul-1-neg67.2%
Simplified67.2%
if -2.8999999999999998e-286 < z < 1.15000000000000003e-267 or 3e-132 < z < 2.45000000000000014e-73Initial program 100.0%
div-sub91.3%
associate-+r-91.3%
remove-double-neg91.3%
distribute-frac-neg91.3%
unsub-neg91.3%
associate--r+91.3%
+-commutative91.3%
distribute-frac-neg91.3%
sub-neg91.3%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 74.7%
Final simplification83.7%
(FPCore (x y z)
:precision binary64
(if (or (<= x -6400000.0)
(not (or (<= x 7e-88) (and (not (<= x 1.45e-71)) (<= x 1.85e-7)))))
(- x (/ x z))
(+ x (/ y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6400000.0) || !((x <= 7e-88) || (!(x <= 1.45e-71) && (x <= 1.85e-7)))) {
tmp = x - (x / z);
} else {
tmp = x + (y / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-6400000.0d0)) .or. (.not. (x <= 7d-88) .or. (.not. (x <= 1.45d-71)) .and. (x <= 1.85d-7))) then
tmp = x - (x / z)
else
tmp = x + (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -6400000.0) || !((x <= 7e-88) || (!(x <= 1.45e-71) && (x <= 1.85e-7)))) {
tmp = x - (x / z);
} else {
tmp = x + (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6400000.0) or not ((x <= 7e-88) or (not (x <= 1.45e-71) and (x <= 1.85e-7))): tmp = x - (x / z) else: tmp = x + (y / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -6400000.0) || !((x <= 7e-88) || (!(x <= 1.45e-71) && (x <= 1.85e-7)))) tmp = Float64(x - Float64(x / z)); else tmp = Float64(x + Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -6400000.0) || ~(((x <= 7e-88) || (~((x <= 1.45e-71)) && (x <= 1.85e-7))))) tmp = x - (x / z); else tmp = x + (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -6400000.0], N[Not[Or[LessEqual[x, 7e-88], And[N[Not[LessEqual[x, 1.45e-71]], $MachinePrecision], LessEqual[x, 1.85e-7]]]], $MachinePrecision]], N[(x - N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6400000 \lor \neg \left(x \leq 7 \cdot 10^{-88} \lor \neg \left(x \leq 1.45 \cdot 10^{-71}\right) \land x \leq 1.85 \cdot 10^{-7}\right):\\
\;\;\;\;x - \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{z}\\
\end{array}
\end{array}
if x < -6.4e6 or 7.0000000000000002e-88 < x < 1.4499999999999999e-71 or 1.85000000000000002e-7 < x Initial program 100.0%
div-sub97.2%
associate-+r-97.2%
remove-double-neg97.2%
distribute-frac-neg97.2%
unsub-neg97.2%
associate--r+97.2%
+-commutative97.2%
distribute-frac-neg97.2%
sub-neg97.2%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 92.6%
distribute-lft-out--92.6%
*-rgt-identity92.6%
associate-*r/92.7%
*-rgt-identity92.7%
Simplified92.7%
if -6.4e6 < x < 7.0000000000000002e-88 or 1.4499999999999999e-71 < x < 1.85000000000000002e-7Initial program 100.0%
div-sub100.0%
associate-+r-100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
unsub-neg100.0%
associate--r+100.0%
+-commutative100.0%
distribute-frac-neg100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 91.4%
neg-mul-191.4%
distribute-neg-frac91.4%
Simplified91.4%
Taylor expanded in x around 0 91.4%
+-commutative91.4%
Simplified91.4%
Final simplification92.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -90.0) (not (<= z 1.0))) (+ x (/ y z)) (/ (- y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -90.0) || !(z <= 1.0)) {
tmp = x + (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 ((z <= (-90.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x + (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 ((z <= -90.0) || !(z <= 1.0)) {
tmp = x + (y / z);
} else {
tmp = (y - x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -90.0) or not (z <= 1.0): tmp = x + (y / z) else: tmp = (y - x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -90.0) || !(z <= 1.0)) tmp = Float64(x + Float64(y / z)); else tmp = Float64(Float64(y - x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -90.0) || ~((z <= 1.0))) tmp = x + (y / z); else tmp = (y - x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -90.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x + N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -90 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x + \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{z}\\
\end{array}
\end{array}
if z < -90 or 1 < z Initial program 100.0%
div-sub100.0%
associate-+r-100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
unsub-neg100.0%
associate--r+100.0%
+-commutative100.0%
distribute-frac-neg100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 98.1%
neg-mul-198.1%
distribute-neg-frac98.1%
Simplified98.1%
Taylor expanded in x around 0 98.1%
+-commutative98.1%
Simplified98.1%
if -90 < z < 1Initial program 100.0%
div-sub96.8%
associate-+r-96.8%
remove-double-neg96.8%
distribute-frac-neg96.8%
unsub-neg96.8%
associate--r+96.8%
+-commutative96.8%
distribute-frac-neg96.8%
sub-neg96.8%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around 0 98.7%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z -6.5e+26) x (if (<= z 9e+19) (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+26) {
tmp = x;
} else if (z <= 9e+19) {
tmp = y / 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 <= (-6.5d+26)) then
tmp = x
else if (z <= 9d+19) then
tmp = y / z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.5e+26) {
tmp = x;
} else if (z <= 9e+19) {
tmp = y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.5e+26: tmp = x elif z <= 9e+19: tmp = y / z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.5e+26) tmp = x; elseif (z <= 9e+19) tmp = Float64(y / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.5e+26) tmp = x; elseif (z <= 9e+19) tmp = y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.5e+26], x, If[LessEqual[z, 9e+19], N[(y / z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+26}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+19}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.50000000000000022e26 or 9e19 < z Initial program 100.0%
div-sub100.0%
associate-+r-100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
unsub-neg100.0%
associate--r+100.0%
+-commutative100.0%
distribute-frac-neg100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around inf 77.3%
if -6.50000000000000022e26 < z < 9e19Initial program 100.0%
div-sub97.1%
associate-+r-97.1%
remove-double-neg97.1%
distribute-frac-neg97.1%
unsub-neg97.1%
associate--r+97.1%
+-commutative97.1%
distribute-frac-neg97.1%
sub-neg97.1%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 48.1%
Final simplification61.6%
(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 100.0%
div-sub98.4%
associate-+r-98.4%
remove-double-neg98.4%
distribute-frac-neg98.4%
unsub-neg98.4%
associate--r+98.4%
+-commutative98.4%
distribute-frac-neg98.4%
sub-neg98.4%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around inf 38.1%
Final simplification38.1%
herbie shell --seed 2024018
(FPCore (x y z)
:name "Statistics.Sample:$swelfordMean from math-functions-0.1.5.2"
:precision binary64
(+ x (/ (- y x) z)))