
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
return 10.0 / (1.0 - (x * x));
}
def code(x): return 10.0 / (1.0 - (x * x))
function code(x) return Float64(10.0 / Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = 10.0 / (1.0 - (x * x)); end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{10}{1 - x \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
return 10.0 / (1.0 - (x * x));
}
def code(x): return 10.0 / (1.0 - (x * x))
function code(x) return Float64(10.0 / Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = 10.0 / (1.0 - (x * x)); end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{10}{1 - x \cdot x}
\end{array}
(FPCore (x) :precision binary64 (/ -10.0 (fma x x -1.0)))
double code(double x) {
return -10.0 / fma(x, x, -1.0);
}
function code(x) return Float64(-10.0 / fma(x, x, -1.0)) end
code[x_] := N[(-10.0 / N[(x * x + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-10}{\mathsf{fma}\left(x, x, -1\right)}
\end{array}
Initial program 87.7%
sqr-neg87.7%
cancel-sign-sub87.7%
+-commutative87.7%
+-lft-identity87.7%
cancel-sign-sub87.7%
associate-+l-87.7%
sub0-neg87.7%
neg-mul-187.7%
associate-/r*87.7%
metadata-eval87.7%
sqr-neg87.7%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (/ 10.0 (- 1.0 (* x x))))
double code(double x) {
return 10.0 / (1.0 - (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 10.0d0 / (1.0d0 - (x * x))
end function
public static double code(double x) {
return 10.0 / (1.0 - (x * x));
}
def code(x): return 10.0 / (1.0 - (x * x))
function code(x) return Float64(10.0 / Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = 10.0 / (1.0 - (x * x)); end
code[x_] := N[(10.0 / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{10}{1 - x \cdot x}
\end{array}
Initial program 87.7%
Final simplification87.7%
(FPCore (x) :precision binary64 (if (<= x 1.0) 10.0 -10.0))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 10.0;
} else {
tmp = -10.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 10.0d0
else
tmp = -10.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 10.0;
} else {
tmp = -10.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = 10.0 else: tmp = -10.0 return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = 10.0; else tmp = -10.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = 10.0; else tmp = -10.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], 10.0, -10.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;10\\
\mathbf{else}:\\
\;\;\;\;-10\\
\end{array}
\end{array}
if x < 1Initial program 88.1%
sqr-neg88.1%
cancel-sign-sub88.1%
+-commutative88.1%
+-lft-identity88.1%
cancel-sign-sub88.1%
associate-+l-88.1%
sub0-neg88.1%
neg-mul-188.1%
associate-/r*88.1%
metadata-eval88.1%
sqr-neg88.1%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 13.5%
if 1 < x Initial program 86.9%
sqr-neg86.9%
cancel-sign-sub86.9%
+-commutative86.9%
+-lft-identity86.9%
cancel-sign-sub86.9%
associate-+l-86.9%
sub0-neg86.9%
neg-mul-186.9%
associate-/r*86.9%
metadata-eval86.9%
sqr-neg86.9%
fma-neg99.5%
metadata-eval99.5%
Simplified99.5%
add-cbrt-cube98.9%
pow399.0%
Applied egg-rr99.0%
rem-cbrt-cube99.5%
pow199.5%
metadata-eval99.5%
pow-sqr0.0%
pow-prod-down1.5%
frac-times1.5%
metadata-eval1.5%
pow21.5%
Applied egg-rr1.5%
unpow1/21.5%
Simplified1.5%
Taylor expanded in x around 0 13.5%
Final simplification13.5%
(FPCore (x) :precision binary64 -10.0)
double code(double x) {
return -10.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -10.0d0
end function
public static double code(double x) {
return -10.0;
}
def code(x): return -10.0
function code(x) return -10.0 end
function tmp = code(x) tmp = -10.0; end
code[x_] := -10.0
\begin{array}{l}
\\
-10
\end{array}
Initial program 87.7%
sqr-neg87.7%
cancel-sign-sub87.7%
+-commutative87.7%
+-lft-identity87.7%
cancel-sign-sub87.7%
associate-+l-87.7%
sub0-neg87.7%
neg-mul-187.7%
associate-/r*87.7%
metadata-eval87.7%
sqr-neg87.7%
fma-neg99.6%
metadata-eval99.6%
Simplified99.6%
add-cbrt-cube99.1%
pow399.1%
Applied egg-rr99.1%
rem-cbrt-cube99.6%
pow199.6%
metadata-eval99.6%
pow-sqr68.8%
pow-prod-down69.7%
frac-times69.8%
metadata-eval69.8%
pow269.8%
Applied egg-rr69.8%
unpow1/269.8%
Simplified69.8%
Taylor expanded in x around 0 5.2%
Final simplification5.2%
herbie shell --seed 2023309
(FPCore (x)
:name "ENA, Section 1.4, Mentioned, B"
:precision binary64
:pre (and (<= 0.999 x) (<= x 1.001))
(/ 10.0 (- 1.0 (* x x))))