| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 13120 |
\[\sqrt{x - 1} \cdot \sqrt{x}
\]
(FPCore (x) :precision binary64 (* (sqrt (- x 1.0)) (sqrt x)))
(FPCore (x)
:precision binary64
(let* ((t_0 (* (sqrt (+ x -1.0)) (sqrt x))))
(if (!= t_0 0.0)
(/
-1.0
(*
(if (!= (+ -1.0 x) 0.0) (pow (+ -1.0 x) -0.5) (/ 1.0 (sqrt (+ -1.0 x))))
(/ -1.0 (sqrt x))))
t_0)))double code(double x) {
return sqrt((x - 1.0)) * sqrt(x);
}
double code(double x) {
double t_0 = sqrt((x + -1.0)) * sqrt(x);
double tmp_1;
if (t_0 != 0.0) {
double tmp_2;
if ((-1.0 + x) != 0.0) {
tmp_2 = pow((-1.0 + x), -0.5);
} else {
tmp_2 = 1.0 / sqrt((-1.0 + x));
}
tmp_1 = -1.0 / (tmp_2 * (-1.0 / sqrt(x)));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x - 1.0d0)) * sqrt(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt((x + (-1.0d0))) * sqrt(x)
if (t_0 /= 0.0d0) then
if (((-1.0d0) + x) /= 0.0d0) then
tmp_2 = ((-1.0d0) + x) ** (-0.5d0)
else
tmp_2 = 1.0d0 / sqrt(((-1.0d0) + x))
end if
tmp_1 = (-1.0d0) / (tmp_2 * ((-1.0d0) / sqrt(x)))
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double x) {
return Math.sqrt((x - 1.0)) * Math.sqrt(x);
}
public static double code(double x) {
double t_0 = Math.sqrt((x + -1.0)) * Math.sqrt(x);
double tmp_1;
if (t_0 != 0.0) {
double tmp_2;
if ((-1.0 + x) != 0.0) {
tmp_2 = Math.pow((-1.0 + x), -0.5);
} else {
tmp_2 = 1.0 / Math.sqrt((-1.0 + x));
}
tmp_1 = -1.0 / (tmp_2 * (-1.0 / Math.sqrt(x)));
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(x): return math.sqrt((x - 1.0)) * math.sqrt(x)
def code(x): t_0 = math.sqrt((x + -1.0)) * math.sqrt(x) tmp_1 = 0 if t_0 != 0.0: tmp_2 = 0 if (-1.0 + x) != 0.0: tmp_2 = math.pow((-1.0 + x), -0.5) else: tmp_2 = 1.0 / math.sqrt((-1.0 + x)) tmp_1 = -1.0 / (tmp_2 * (-1.0 / math.sqrt(x))) else: tmp_1 = t_0 return tmp_1
function code(x) return Float64(sqrt(Float64(x - 1.0)) * sqrt(x)) end
function code(x) t_0 = Float64(sqrt(Float64(x + -1.0)) * sqrt(x)) tmp_1 = 0.0 if (t_0 != 0.0) tmp_2 = 0.0 if (Float64(-1.0 + x) != 0.0) tmp_2 = Float64(-1.0 + x) ^ -0.5; else tmp_2 = Float64(1.0 / sqrt(Float64(-1.0 + x))); end tmp_1 = Float64(-1.0 / Float64(tmp_2 * Float64(-1.0 / sqrt(x)))); else tmp_1 = t_0; end return tmp_1 end
function tmp = code(x) tmp = sqrt((x - 1.0)) * sqrt(x); end
function tmp_4 = code(x) t_0 = sqrt((x + -1.0)) * sqrt(x); tmp_2 = 0.0; if (t_0 ~= 0.0) tmp_3 = 0.0; if ((-1.0 + x) ~= 0.0) tmp_3 = (-1.0 + x) ^ -0.5; else tmp_3 = 1.0 / sqrt((-1.0 + x)); end tmp_2 = -1.0 / (tmp_3 * (-1.0 / sqrt(x))); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[x_] := N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(N[Sqrt[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[Unequal[t$95$0, 0.0], N[(-1.0 / N[(If[Unequal[N[(-1.0 + x), $MachinePrecision], 0.0], N[Power[N[(-1.0 + x), $MachinePrecision], -0.5], $MachinePrecision], N[(1.0 / N[Sqrt[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] * N[(-1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\sqrt{x - 1} \cdot \sqrt{x}
\begin{array}{l}
t_0 := \sqrt{x + -1} \cdot \sqrt{x}\\
\mathbf{if}\;t_0 \ne 0:\\
\;\;\;\;\frac{-1}{\begin{array}{l}
\mathbf{if}\;-1 + x \ne 0:\\
\;\;\;\;{\left(-1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{-1 + x}}\\
\end{array} \cdot \frac{-1}{\sqrt{x}}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Initial program 0.5
Applied egg-rr42.9
Applied egg-rr0.5
Simplified0.5
Applied egg-rr0.7
Applied egg-rr0.5
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 13120 |
herbie shell --seed 2023010
(FPCore (x)
:name "sqrt times"
:precision binary64
(* (sqrt (- x 1.0)) (sqrt x)))