
(FPCore (x) :precision binary64 (sqrt (- (pow x 2.0) 1.0)))
double code(double x) {
return sqrt((pow(x, 2.0) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((x ** 2.0d0) - 1.0d0))
end function
public static double code(double x) {
return Math.sqrt((Math.pow(x, 2.0) - 1.0));
}
def code(x): return math.sqrt((math.pow(x, 2.0) - 1.0))
function code(x) return sqrt(Float64((x ^ 2.0) - 1.0)) end
function tmp = code(x) tmp = sqrt(((x ^ 2.0) - 1.0)); end
code[x_] := N[Sqrt[N[(N[Power[x, 2.0], $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision]
\sqrt{{x}^{2} - 1}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (sqrt (- (pow x 2.0) 1.0)))
double code(double x) {
return sqrt((pow(x, 2.0) - 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt(((x ** 2.0d0) - 1.0d0))
end function
public static double code(double x) {
return Math.sqrt((Math.pow(x, 2.0) - 1.0));
}
def code(x): return math.sqrt((math.pow(x, 2.0) - 1.0))
function code(x) return sqrt(Float64((x ^ 2.0) - 1.0)) end
function tmp = code(x) tmp = sqrt(((x ^ 2.0) - 1.0)); end
code[x_] := N[Sqrt[N[(N[Power[x, 2.0], $MachinePrecision] - 1.0), $MachinePrecision]], $MachinePrecision]
\sqrt{{x}^{2} - 1}
(FPCore (x) :precision binary64 (- x (/ 0.5 x)))
double code(double x) {
return x - (0.5 / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x - (0.5d0 / x)
end function
public static double code(double x) {
return x - (0.5 / x);
}
def code(x): return x - (0.5 / x)
function code(x) return Float64(x - Float64(0.5 / x)) end
function tmp = code(x) tmp = x - (0.5 / x); end
code[x_] := N[(x - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]
x - \frac{0.5}{x}
Initial program 52.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6499.5%
Applied rewrites99.5%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-rgt-neg-outN/A
*-commutativeN/A
mul-1-negN/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
associate-*l*N/A
metadata-evalN/A
metadata-evalN/A
Applied rewrites99.5%
(FPCore (x) :precision binary64 (/ -0.5 x))
double code(double x) {
return -0.5 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-0.5d0) / x
end function
public static double code(double x) {
return -0.5 / x;
}
def code(x): return -0.5 / x
function code(x) return Float64(-0.5 / x) end
function tmp = code(x) tmp = -0.5 / x; end
code[x_] := N[(-0.5 / x), $MachinePrecision]
\frac{-0.5}{x}
Initial program 52.9%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6499.5%
Applied rewrites99.5%
Taylor expanded in x around 0
lower-/.f641.6%
Applied rewrites1.6%
(FPCore (x) :precision binary64 (- x))
double code(double x) {
return -x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -x
end function
public static double code(double x) {
return -x;
}
def code(x): return -x
function code(x) return Float64(-x) end
function tmp = code(x) tmp = -x; end
code[x_] := (-x)
-x
Initial program 52.9%
Taylor expanded in x around -inf
lower-*.f640.7%
Applied rewrites0.7%
lift-*.f64N/A
metadata-evalN/A
distribute-lft-neg-outN/A
metadata-evalN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-neg.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
*-rgt-identity0.7%
Applied rewrites0.7%
herbie shell --seed 1
(FPCore (x)
:name "sqrt(x^2 -1)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1.79e+308))
(sqrt (- (pow x 2.0) 1.0)))