
(FPCore (x) :precision binary64 (/ (sqrt (pow x 4.0)) (sqrt x)))
double code(double x) {
return sqrt(pow(x, 4.0)) / sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x ** 4.0d0)) / sqrt(x)
end function
public static double code(double x) {
return Math.sqrt(Math.pow(x, 4.0)) / Math.sqrt(x);
}
def code(x): return math.sqrt(math.pow(x, 4.0)) / math.sqrt(x)
function code(x) return Float64(sqrt((x ^ 4.0)) / sqrt(x)) end
function tmp = code(x) tmp = sqrt((x ^ 4.0)) / sqrt(x); end
code[x_] := N[(N[Sqrt[N[Power[x, 4.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{{x}^{4}}}{\sqrt{x}}
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (sqrt (pow x 4.0)) (sqrt x)))
double code(double x) {
return sqrt(pow(x, 4.0)) / sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x ** 4.0d0)) / sqrt(x)
end function
public static double code(double x) {
return Math.sqrt(Math.pow(x, 4.0)) / Math.sqrt(x);
}
def code(x): return math.sqrt(math.pow(x, 4.0)) / math.sqrt(x)
function code(x) return Float64(sqrt((x ^ 4.0)) / sqrt(x)) end
function tmp = code(x) tmp = sqrt((x ^ 4.0)) / sqrt(x); end
code[x_] := N[(N[Sqrt[N[Power[x, 4.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\frac{\sqrt{{x}^{4}}}{\sqrt{x}}
(FPCore (x) :precision binary64 (pow x 1.5))
double code(double x) {
return pow(x, 1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** 1.5d0
end function
public static double code(double x) {
return Math.pow(x, 1.5);
}
def code(x): return math.pow(x, 1.5)
function code(x) return x ^ 1.5 end
function tmp = code(x) tmp = x ^ 1.5; end
code[x_] := N[Power[x, 1.5], $MachinePrecision]
{x}^{1.5}
Initial program 59.9%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
sqrt-fabs-revN/A
sqrt-undivN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
rem-sqrt-square-revN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-pow.f64N/A
pow2N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
metadata-evalN/A
pow-divN/A
Applied rewrites100.0%
(FPCore (x) :precision binary64 (* (sqrt x) x))
double code(double x) {
return sqrt(x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(x) * x
end function
public static double code(double x) {
return Math.sqrt(x) * x;
}
def code(x): return math.sqrt(x) * x
function code(x) return Float64(sqrt(x) * x) end
function tmp = code(x) tmp = sqrt(x) * x; end
code[x_] := N[(N[Sqrt[x], $MachinePrecision] * x), $MachinePrecision]
\sqrt{x} \cdot x
Initial program 59.9%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
sqrt-fabs-revN/A
sqrt-undivN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
rem-sqrt-square-revN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-pow.f64N/A
pow2N/A
lift-sqrt.f64N/A
sqrt-pow2N/A
metadata-evalN/A
pow-divN/A
Applied rewrites99.7%
herbie shell --seed 1
(FPCore (x)
:name "sqrt(x^4) / sqrt(x)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1.0))
(/ (sqrt (pow x 4.0)) (sqrt x)))