
(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 7 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%
remove-double-neg87.7%
distribute-neg-frac87.7%
distribute-frac-neg287.7%
metadata-eval87.7%
neg-sub087.7%
associate--r-87.7%
metadata-eval87.7%
+-commutative87.7%
sqr-neg87.7%
fma-define99.5%
Simplified99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* x x) (* x x))))
(/
10.0
(*
(/ 1.0 (/ (+ 1.0 t_0) (- 1.0 (* x (* x (* x (* x t_0)))))))
(/ 1.0 (+ 1.0 (* x x)))))))
double code(double x) {
double t_0 = (x * x) * (x * x);
return 10.0 / ((1.0 / ((1.0 + t_0) / (1.0 - (x * (x * (x * (x * t_0))))))) * (1.0 / (1.0 + (x * x))));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = (x * x) * (x * x)
code = 10.0d0 / ((1.0d0 / ((1.0d0 + t_0) / (1.0d0 - (x * (x * (x * (x * t_0))))))) * (1.0d0 / (1.0d0 + (x * x))))
end function
public static double code(double x) {
double t_0 = (x * x) * (x * x);
return 10.0 / ((1.0 / ((1.0 + t_0) / (1.0 - (x * (x * (x * (x * t_0))))))) * (1.0 / (1.0 + (x * x))));
}
def code(x): t_0 = (x * x) * (x * x) return 10.0 / ((1.0 / ((1.0 + t_0) / (1.0 - (x * (x * (x * (x * t_0))))))) * (1.0 / (1.0 + (x * x))))
function code(x) t_0 = Float64(Float64(x * x) * Float64(x * x)) return Float64(10.0 / Float64(Float64(1.0 / Float64(Float64(1.0 + t_0) / Float64(1.0 - Float64(x * Float64(x * Float64(x * Float64(x * t_0))))))) * Float64(1.0 / Float64(1.0 + Float64(x * x))))) end
function tmp = code(x) t_0 = (x * x) * (x * x); tmp = 10.0 / ((1.0 / ((1.0 + t_0) / (1.0 - (x * (x * (x * (x * t_0))))))) * (1.0 / (1.0 + (x * x)))); end
code[x_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[(10.0 / N[(N[(1.0 / N[(N[(1.0 + t$95$0), $MachinePrecision] / N[(1.0 - N[(x * N[(x * N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\frac{10}{\frac{1}{\frac{1 + t\_0}{1 - x \cdot \left(x \cdot \left(x \cdot \left(x \cdot t\_0\right)\right)\right)}} \cdot \frac{1}{1 + x \cdot x}}
\end{array}
\end{array}
Initial program 87.7%
flip--87.6%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
flip--87.5%
clear-num87.5%
metadata-eval87.5%
Applied egg-rr87.5%
expm1-log1p-u87.3%
expm1-undefine87.2%
log1p-undefine87.4%
add-exp-log87.4%
Applied egg-rr87.4%
add-exp-log87.4%
expm1-define87.3%
log1p-define87.3%
add-sqr-sqrt87.3%
sqrt-prod87.3%
associate-*r*87.3%
expm1-log1p-u87.5%
add-sqr-sqrt87.5%
sqrt-prod87.5%
associate-*r*87.5%
add-sqr-sqrt87.5%
associate-*l*88.3%
Applied egg-rr88.8%
(FPCore (x) :precision binary64 (/ 10.0 (* (/ 1.0 (+ 1.0 (* x x))) (- 1.0 (* x (* x (* x x)))))))
double code(double x) {
return 10.0 / ((1.0 / (1.0 + (x * x))) * (1.0 - (x * (x * (x * x)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 10.0d0 / ((1.0d0 / (1.0d0 + (x * x))) * (1.0d0 - (x * (x * (x * x)))))
end function
public static double code(double x) {
return 10.0 / ((1.0 / (1.0 + (x * x))) * (1.0 - (x * (x * (x * x)))));
}
def code(x): return 10.0 / ((1.0 / (1.0 + (x * x))) * (1.0 - (x * (x * (x * x)))))
function code(x) return Float64(10.0 / Float64(Float64(1.0 / Float64(1.0 + Float64(x * x))) * Float64(1.0 - Float64(x * Float64(x * Float64(x * x)))))) end
function tmp = code(x) tmp = 10.0 / ((1.0 / (1.0 + (x * x))) * (1.0 - (x * (x * (x * x))))); end
code[x_] := N[(10.0 / N[(N[(1.0 / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{10}{\frac{1}{1 + x \cdot x} \cdot \left(1 - x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)}
\end{array}
Initial program 87.7%
flip--87.6%
div-inv87.6%
metadata-eval87.6%
Applied egg-rr87.6%
associate-*r*88.3%
associate-*r*88.3%
Applied egg-rr88.3%
Final simplification88.3%
(FPCore (x) :precision binary64 (/ 1.0 (/ 1.0 (* -10.0 (/ 1.0 (+ -1.0 (* x x)))))))
double code(double x) {
return 1.0 / (1.0 / (-10.0 * (1.0 / (-1.0 + (x * x)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (1.0d0 / ((-10.0d0) * (1.0d0 / ((-1.0d0) + (x * x)))))
end function
public static double code(double x) {
return 1.0 / (1.0 / (-10.0 * (1.0 / (-1.0 + (x * x)))));
}
def code(x): return 1.0 / (1.0 / (-10.0 * (1.0 / (-1.0 + (x * x)))))
function code(x) return Float64(1.0 / Float64(1.0 / Float64(-10.0 * Float64(1.0 / Float64(-1.0 + Float64(x * x)))))) end
function tmp = code(x) tmp = 1.0 / (1.0 / (-10.0 * (1.0 / (-1.0 + (x * x))))); end
code[x_] := N[(1.0 / N[(1.0 / N[(-10.0 * N[(1.0 / N[(-1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{-10 \cdot \frac{1}{-1 + x \cdot x}}}
\end{array}
Initial program 87.7%
sqr-neg87.7%
remove-double-neg87.7%
distribute-neg-frac87.7%
distribute-frac-neg287.7%
metadata-eval87.7%
neg-sub087.7%
associate--r-87.7%
metadata-eval87.7%
+-commutative87.7%
sqr-neg87.7%
fma-define99.5%
Simplified99.5%
clear-num99.4%
inv-pow99.4%
add-sqr-sqrt35.6%
associate-/l*35.6%
unpow-prod-down35.7%
inv-pow35.7%
pow1/235.7%
fma-undefine31.8%
+-commutative31.8%
pow1/231.8%
fma-undefine31.3%
+-commutative31.3%
Applied egg-rr31.3%
unpow-131.3%
associate-*r/31.3%
*-rgt-identity31.3%
unpow1/231.3%
+-commutative31.3%
fma-define31.8%
unpow1/231.8%
+-commutative31.8%
fma-define35.6%
Simplified35.6%
clear-num35.6%
clear-num35.6%
associate-/r/35.6%
div-inv35.6%
frac-times35.6%
metadata-eval35.6%
add-sqr-sqrt99.3%
fma-undefine87.7%
Applied egg-rr87.7%
Final simplification87.7%
(FPCore (x) :precision binary64 (if (<= (* x x) 1.0) 10.0 (/ -10.0 (* x x))))
double code(double x) {
double tmp;
if ((x * x) <= 1.0) {
tmp = 10.0;
} else {
tmp = -10.0 / (x * x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x * x) <= 1.0d0) then
tmp = 10.0d0
else
tmp = (-10.0d0) / (x * x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x * x) <= 1.0) {
tmp = 10.0;
} else {
tmp = -10.0 / (x * x);
}
return tmp;
}
def code(x): tmp = 0 if (x * x) <= 1.0: tmp = 10.0 else: tmp = -10.0 / (x * x) return tmp
function code(x) tmp = 0.0 if (Float64(x * x) <= 1.0) tmp = 10.0; else tmp = Float64(-10.0 / Float64(x * x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x * x) <= 1.0) tmp = 10.0; else tmp = -10.0 / (x * x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.0], 10.0, N[(-10.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1:\\
\;\;\;\;10\\
\mathbf{else}:\\
\;\;\;\;\frac{-10}{x \cdot x}\\
\end{array}
\end{array}
if (*.f64 x x) < 1Initial program 88.1%
sqr-neg88.1%
remove-double-neg88.1%
distribute-neg-frac88.1%
distribute-frac-neg288.1%
metadata-eval88.1%
neg-sub088.1%
associate--r-88.1%
metadata-eval88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define99.5%
Simplified99.5%
Taylor expanded in x around 0 13.5%
if 1 < (*.f64 x x) Initial program 87.0%
sqr-neg87.0%
remove-double-neg87.0%
distribute-neg-frac87.0%
distribute-frac-neg287.0%
metadata-eval87.0%
neg-sub087.0%
associate--r-87.0%
metadata-eval87.0%
+-commutative87.0%
sqr-neg87.0%
fma-define99.5%
Simplified99.5%
Taylor expanded in x around inf 13.5%
unpow213.5%
Simplified13.5%
(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%
(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%
remove-double-neg87.7%
distribute-neg-frac87.7%
distribute-frac-neg287.7%
metadata-eval87.7%
neg-sub087.7%
associate--r-87.7%
metadata-eval87.7%
+-commutative87.7%
sqr-neg87.7%
fma-define99.5%
Simplified99.5%
Taylor expanded in x around 0 9.2%
herbie shell --seed 2024097
(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))))