
(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 -1.7e+61)
x
(if (<= z -1.7e-78)
(/ y z)
(if (<= z -1.85e-90)
t_0
(if (<= z -1.55e-215)
(/ y z)
(if (<= z 5.5e-160)
t_0
(if (<= z 1.3e-48)
(/ y z)
(if (<= z 1.16e-12) t_0 (if (<= z 1.4e+105) (/ y z) x))))))))))
double code(double x, double y, double z) {
double t_0 = -x / z;
double tmp;
if (z <= -1.7e+61) {
tmp = x;
} else if (z <= -1.7e-78) {
tmp = y / z;
} else if (z <= -1.85e-90) {
tmp = t_0;
} else if (z <= -1.55e-215) {
tmp = y / z;
} else if (z <= 5.5e-160) {
tmp = t_0;
} else if (z <= 1.3e-48) {
tmp = y / z;
} else if (z <= 1.16e-12) {
tmp = t_0;
} else if (z <= 1.4e+105) {
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) :: t_0
real(8) :: tmp
t_0 = -x / z
if (z <= (-1.7d+61)) then
tmp = x
else if (z <= (-1.7d-78)) then
tmp = y / z
else if (z <= (-1.85d-90)) then
tmp = t_0
else if (z <= (-1.55d-215)) then
tmp = y / z
else if (z <= 5.5d-160) then
tmp = t_0
else if (z <= 1.3d-48) then
tmp = y / z
else if (z <= 1.16d-12) then
tmp = t_0
else if (z <= 1.4d+105) then
tmp = y / z
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 <= -1.7e+61) {
tmp = x;
} else if (z <= -1.7e-78) {
tmp = y / z;
} else if (z <= -1.85e-90) {
tmp = t_0;
} else if (z <= -1.55e-215) {
tmp = y / z;
} else if (z <= 5.5e-160) {
tmp = t_0;
} else if (z <= 1.3e-48) {
tmp = y / z;
} else if (z <= 1.16e-12) {
tmp = t_0;
} else if (z <= 1.4e+105) {
tmp = y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = -x / z tmp = 0 if z <= -1.7e+61: tmp = x elif z <= -1.7e-78: tmp = y / z elif z <= -1.85e-90: tmp = t_0 elif z <= -1.55e-215: tmp = y / z elif z <= 5.5e-160: tmp = t_0 elif z <= 1.3e-48: tmp = y / z elif z <= 1.16e-12: tmp = t_0 elif z <= 1.4e+105: tmp = y / z else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(Float64(-x) / z) tmp = 0.0 if (z <= -1.7e+61) tmp = x; elseif (z <= -1.7e-78) tmp = Float64(y / z); elseif (z <= -1.85e-90) tmp = t_0; elseif (z <= -1.55e-215) tmp = Float64(y / z); elseif (z <= 5.5e-160) tmp = t_0; elseif (z <= 1.3e-48) tmp = Float64(y / z); elseif (z <= 1.16e-12) tmp = t_0; elseif (z <= 1.4e+105) tmp = Float64(y / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -x / z; tmp = 0.0; if (z <= -1.7e+61) tmp = x; elseif (z <= -1.7e-78) tmp = y / z; elseif (z <= -1.85e-90) tmp = t_0; elseif (z <= -1.55e-215) tmp = y / z; elseif (z <= 5.5e-160) tmp = t_0; elseif (z <= 1.3e-48) tmp = y / z; elseif (z <= 1.16e-12) tmp = t_0; elseif (z <= 1.4e+105) tmp = y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) / z), $MachinePrecision]}, If[LessEqual[z, -1.7e+61], x, If[LessEqual[z, -1.7e-78], N[(y / z), $MachinePrecision], If[LessEqual[z, -1.85e-90], t$95$0, If[LessEqual[z, -1.55e-215], N[(y / z), $MachinePrecision], If[LessEqual[z, 5.5e-160], t$95$0, If[LessEqual[z, 1.3e-48], N[(y / z), $MachinePrecision], If[LessEqual[z, 1.16e-12], t$95$0, If[LessEqual[z, 1.4e+105], N[(y / z), $MachinePrecision], x]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{z}\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-78}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq -1.85 \cdot 10^{-90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.55 \cdot 10^{-215}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-160}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-48}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 1.16 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+105}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.70000000000000013e61 or 1.4000000000000001e105 < 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 83.6%
if -1.70000000000000013e61 < z < -1.70000000000000006e-78 or -1.85000000000000009e-90 < z < -1.54999999999999997e-215 or 5.5e-160 < z < 1.29999999999999994e-48 or 1.1599999999999999e-12 < z < 1.4000000000000001e105Initial 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 67.2%
if -1.70000000000000006e-78 < z < -1.85000000000000009e-90 or -1.54999999999999997e-215 < z < 5.5e-160 or 1.29999999999999994e-48 < z < 1.1599999999999999e-12Initial program 100.0%
div-sub96.9%
associate-+r-96.9%
remove-double-neg96.9%
distribute-frac-neg96.9%
unsub-neg96.9%
associate--r+96.9%
+-commutative96.9%
distribute-frac-neg96.9%
sub-neg96.9%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 74.2%
Taylor expanded in z around 0 73.9%
mul-1-neg73.9%
distribute-frac-neg73.9%
Simplified73.9%
Final simplification74.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ y z))) (t_1 (/ (- x) z)))
(if (<= z -1.6e-77)
t_0
(if (<= z -1.7e-90)
t_1
(if (<= z -3.2e-214)
t_0
(if (<= z 2.35e-160)
t_1
(if (<= z 1.9e-47) (/ y z) (if (<= z 4.2e-12) 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 <= -1.6e-77) {
tmp = t_0;
} else if (z <= -1.7e-90) {
tmp = t_1;
} else if (z <= -3.2e-214) {
tmp = t_0;
} else if (z <= 2.35e-160) {
tmp = t_1;
} else if (z <= 1.9e-47) {
tmp = y / z;
} else if (z <= 4.2e-12) {
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 <= (-1.6d-77)) then
tmp = t_0
else if (z <= (-1.7d-90)) then
tmp = t_1
else if (z <= (-3.2d-214)) then
tmp = t_0
else if (z <= 2.35d-160) then
tmp = t_1
else if (z <= 1.9d-47) then
tmp = y / z
else if (z <= 4.2d-12) 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 <= -1.6e-77) {
tmp = t_0;
} else if (z <= -1.7e-90) {
tmp = t_1;
} else if (z <= -3.2e-214) {
tmp = t_0;
} else if (z <= 2.35e-160) {
tmp = t_1;
} else if (z <= 1.9e-47) {
tmp = y / z;
} else if (z <= 4.2e-12) {
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 <= -1.6e-77: tmp = t_0 elif z <= -1.7e-90: tmp = t_1 elif z <= -3.2e-214: tmp = t_0 elif z <= 2.35e-160: tmp = t_1 elif z <= 1.9e-47: tmp = y / z elif z <= 4.2e-12: 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 <= -1.6e-77) tmp = t_0; elseif (z <= -1.7e-90) tmp = t_1; elseif (z <= -3.2e-214) tmp = t_0; elseif (z <= 2.35e-160) tmp = t_1; elseif (z <= 1.9e-47) tmp = Float64(y / z); elseif (z <= 4.2e-12) 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 <= -1.6e-77) tmp = t_0; elseif (z <= -1.7e-90) tmp = t_1; elseif (z <= -3.2e-214) tmp = t_0; elseif (z <= 2.35e-160) tmp = t_1; elseif (z <= 1.9e-47) tmp = y / z; elseif (z <= 4.2e-12) 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, -1.6e-77], t$95$0, If[LessEqual[z, -1.7e-90], t$95$1, If[LessEqual[z, -3.2e-214], t$95$0, If[LessEqual[z, 2.35e-160], t$95$1, If[LessEqual[z, 1.9e-47], N[(y / z), $MachinePrecision], If[LessEqual[z, 4.2e-12], 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 -1.6 \cdot 10^{-77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.2 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.35 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-47}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.6e-77 or -1.69999999999999997e-90 < z < -3.20000000000000013e-214 or 4.19999999999999988e-12 < 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 94.8%
neg-mul-194.8%
distribute-neg-frac94.8%
Simplified94.8%
Taylor expanded in x around 0 94.8%
+-commutative94.8%
Simplified94.8%
if -1.6e-77 < z < -1.69999999999999997e-90 or -3.20000000000000013e-214 < z < 2.3499999999999999e-160 or 1.90000000000000007e-47 < z < 4.19999999999999988e-12Initial program 100.0%
div-sub96.9%
associate-+r-96.9%
remove-double-neg96.9%
distribute-frac-neg96.9%
unsub-neg96.9%
associate--r+96.9%
+-commutative96.9%
distribute-frac-neg96.9%
sub-neg96.9%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 74.2%
Taylor expanded in z around 0 73.9%
mul-1-neg73.9%
distribute-frac-neg73.9%
Simplified73.9%
if 2.3499999999999999e-160 < z < 1.90000000000000007e-47Initial 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 63.2%
Final simplification85.8%
(FPCore (x y z)
:precision binary64
(if (<= z -1.45e+63)
x
(if (or (<= z 1.6e+14) (and (not (<= z 1.55e+71)) (<= z 3e+105)))
(/ y z)
x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.45e+63) {
tmp = x;
} else if ((z <= 1.6e+14) || (!(z <= 1.55e+71) && (z <= 3e+105))) {
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 <= (-1.45d+63)) then
tmp = x
else if ((z <= 1.6d+14) .or. (.not. (z <= 1.55d+71)) .and. (z <= 3d+105)) 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 <= -1.45e+63) {
tmp = x;
} else if ((z <= 1.6e+14) || (!(z <= 1.55e+71) && (z <= 3e+105))) {
tmp = y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.45e+63: tmp = x elif (z <= 1.6e+14) or (not (z <= 1.55e+71) and (z <= 3e+105)): tmp = y / z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.45e+63) tmp = x; elseif ((z <= 1.6e+14) || (!(z <= 1.55e+71) && (z <= 3e+105))) tmp = Float64(y / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.45e+63) tmp = x; elseif ((z <= 1.6e+14) || (~((z <= 1.55e+71)) && (z <= 3e+105))) tmp = y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.45e+63], x, If[Or[LessEqual[z, 1.6e+14], And[N[Not[LessEqual[z, 1.55e+71]], $MachinePrecision], LessEqual[z, 3e+105]]], N[(y / z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+14} \lor \neg \left(z \leq 1.55 \cdot 10^{+71}\right) \land z \leq 3 \cdot 10^{+105}:\\
\;\;\;\;\frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.45e63 or 1.6e14 < z < 1.55000000000000009e71 or 3.0000000000000001e105 < 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 83.3%
if -1.45e63 < z < 1.6e14 or 1.55000000000000009e71 < z < 3.0000000000000001e105Initial program 100.0%
div-sub98.7%
associate-+r-98.7%
remove-double-neg98.7%
distribute-frac-neg98.7%
unsub-neg98.7%
associate--r+98.7%
+-commutative98.7%
distribute-frac-neg98.7%
sub-neg98.7%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 56.6%
Final simplification66.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.2e-73) (not (<= y 1.42e+72))) (+ x (/ y z)) (- x (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-73) || !(y <= 1.42e+72)) {
tmp = x + (y / z);
} else {
tmp = x - (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.2d-73)) .or. (.not. (y <= 1.42d+72))) then
tmp = x + (y / z)
else
tmp = x - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.2e-73) || !(y <= 1.42e+72)) {
tmp = x + (y / z);
} else {
tmp = x - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.2e-73) or not (y <= 1.42e+72): tmp = x + (y / z) else: tmp = x - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.2e-73) || !(y <= 1.42e+72)) tmp = Float64(x + Float64(y / z)); else tmp = Float64(x - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.2e-73) || ~((y <= 1.42e+72))) tmp = x + (y / z); else tmp = x - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.2e-73], N[Not[LessEqual[y, 1.42e+72]], $MachinePrecision]], N[(x + N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-73} \lor \neg \left(y \leq 1.42 \cdot 10^{+72}\right):\\
\;\;\;\;x + \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.19999999999999986e-73 or 1.41999999999999997e72 < y Initial program 100.0%
div-sub98.5%
associate-+r-98.5%
remove-double-neg98.5%
distribute-frac-neg98.5%
unsub-neg98.5%
associate--r+98.5%
+-commutative98.5%
distribute-frac-neg98.5%
sub-neg98.5%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around 0 94.8%
neg-mul-194.8%
distribute-neg-frac94.8%
Simplified94.8%
Taylor expanded in x around 0 94.8%
+-commutative94.8%
Simplified94.8%
if -3.19999999999999986e-73 < y < 1.41999999999999997e72Initial 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 inf 87.5%
Final simplification91.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (+ x (/ y z)) (/ (- y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.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 <= (-1.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 <= -1.0) || !(z <= 1.0)) {
tmp = x + (y / z);
} else {
tmp = (y - x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.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 <= -1.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 <= -1.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, -1.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 -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x + \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{z}\\
\end{array}
\end{array}
if z < -1 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 99.2%
neg-mul-199.2%
distribute-neg-frac99.2%
Simplified99.2%
Taylor expanded in x around 0 99.2%
+-commutative99.2%
Simplified99.2%
if -1 < z < 1Initial program 100.0%
div-sub98.5%
associate-+r-98.5%
remove-double-neg98.5%
distribute-frac-neg98.5%
unsub-neg98.5%
associate--r+98.5%
+-commutative98.5%
distribute-frac-neg98.5%
sub-neg98.5%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around 0 99.0%
Final simplification99.1%
(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-sub99.2%
associate-+r-99.2%
remove-double-neg99.2%
distribute-frac-neg99.2%
unsub-neg99.2%
associate--r+99.2%
+-commutative99.2%
distribute-frac-neg99.2%
sub-neg99.2%
div-sub100.0%
Simplified100.0%
Taylor expanded in z around inf 35.2%
Final simplification35.2%
herbie shell --seed 2024041
(FPCore (x y z)
:name "Statistics.Sample:$swelfordMean from math-functions-0.1.5.2"
:precision binary64
(+ x (/ (- y x) z)))