| Alternative 1 | |
|---|---|
| Error | 1.4 |
| Cost | 32256 |
\[{\left(\left|\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{x}\right|\right)}^{3}
\]
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
(FPCore (x) :precision binary64 (if (<= x -2.713715200157104e-299) (* (sqrt 2.0) (- x)) (* (sqrt (* 2.0 x)) (sqrt x))))
double code(double x) {
return sqrt(((2.0 * x) * x));
}
double code(double x) {
double tmp;
if (x <= -2.713715200157104e-299) {
tmp = sqrt(2.0) * -x;
} else {
tmp = sqrt((2.0 * x)) * sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((2.0d0 * x) * x))
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-2.713715200157104d-299)) then
tmp = sqrt(2.0d0) * -x
else
tmp = sqrt((2.0d0 * x)) * sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
return Math.sqrt(((2.0 * x) * x));
}
public static double code(double x) {
double tmp;
if (x <= -2.713715200157104e-299) {
tmp = Math.sqrt(2.0) * -x;
} else {
tmp = Math.sqrt((2.0 * x)) * Math.sqrt(x);
}
return tmp;
}
def code(x): return math.sqrt(((2.0 * x) * x))
def code(x): tmp = 0 if x <= -2.713715200157104e-299: tmp = math.sqrt(2.0) * -x else: tmp = math.sqrt((2.0 * x)) * math.sqrt(x) return tmp
function code(x) return sqrt(Float64(Float64(2.0 * x) * x)) end
function code(x) tmp = 0.0 if (x <= -2.713715200157104e-299) tmp = Float64(sqrt(2.0) * Float64(-x)); else tmp = Float64(sqrt(Float64(2.0 * x)) * sqrt(x)); end return tmp end
function tmp = code(x) tmp = sqrt(((2.0 * x) * x)); end
function tmp_2 = code(x) tmp = 0.0; if (x <= -2.713715200157104e-299) tmp = sqrt(2.0) * -x; else tmp = sqrt((2.0 * x)) * sqrt(x); end tmp_2 = tmp; end
code[x_] := N[Sqrt[N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
code[x_] := If[LessEqual[x, -2.713715200157104e-299], N[(N[Sqrt[2.0], $MachinePrecision] * (-x)), $MachinePrecision], N[(N[Sqrt[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\sqrt{\left(2 \cdot x\right) \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq -2.713715200157104 \cdot 10^{-299}:\\
\;\;\;\;\sqrt{2} \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot x} \cdot \sqrt{x}\\
\end{array}
Results
if x < -2.7137152001571041e-299Initial program 29.5
Taylor expanded in x around -inf 0.4
Simplified0.4
if -2.7137152001571041e-299 < x Initial program 30.2
Applied egg-rr1.3
Final simplification0.9
| Alternative 1 | |
|---|---|
| Error | 1.4 |
| Cost | 32256 |
| Alternative 2 | |
|---|---|
| Error | 1.4 |
| Cost | 25984 |
| Alternative 3 | |
|---|---|
| Error | 1.4 |
| Cost | 25856 |
| Alternative 4 | |
|---|---|
| Error | 0.9 |
| Cost | 6788 |
| Alternative 5 | |
|---|---|
| Error | 31.2 |
| Cost | 6592 |

herbie shell --seed 2022295
(FPCore (x)
:name "sqrt B"
:precision binary64
(sqrt (* (* 2.0 x) x)))