
(FPCore (x) :precision binary64 (- (/ (+ 2.30753 (* x 0.27061)) (+ 1.0 (* x (+ 0.99229 (* x 0.04481))))) x))
double code(double x) {
return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.30753d0 + (x * 0.27061d0)) / (1.0d0 + (x * (0.99229d0 + (x * 0.04481d0))))) - x
end function
public static double code(double x) {
return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x;
}
def code(x): return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x
function code(x) return Float64(Float64(Float64(2.30753 + Float64(x * 0.27061)) / Float64(1.0 + Float64(x * Float64(0.99229 + Float64(x * 0.04481))))) - x) end
function tmp = code(x) tmp = ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x; end
code[x_] := N[(N[(N[(2.30753 + N[(x * 0.27061), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * N[(0.99229 + N[(x * 0.04481), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{2.30753 + x \cdot 0.27061}{1 + x \cdot \left(0.99229 + x \cdot 0.04481\right)} - x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ (+ 2.30753 (* x 0.27061)) (+ 1.0 (* x (+ 0.99229 (* x 0.04481))))) x))
double code(double x) {
return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((2.30753d0 + (x * 0.27061d0)) / (1.0d0 + (x * (0.99229d0 + (x * 0.04481d0))))) - x
end function
public static double code(double x) {
return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x;
}
def code(x): return ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x
function code(x) return Float64(Float64(Float64(2.30753 + Float64(x * 0.27061)) / Float64(1.0 + Float64(x * Float64(0.99229 + Float64(x * 0.04481))))) - x) end
function tmp = code(x) tmp = ((2.30753 + (x * 0.27061)) / (1.0 + (x * (0.99229 + (x * 0.04481))))) - x; end
code[x_] := N[(N[(N[(2.30753 + N[(x * 0.27061), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * N[(0.99229 + N[(x * 0.04481), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{2.30753 + x \cdot 0.27061}{1 + x \cdot \left(0.99229 + x \cdot 0.04481\right)} - x
\end{array}
(FPCore (x) :precision binary64 (- (/ (+ (* x 0.27061) 2.30753) (fma x (+ (* x 0.04481) 0.99229) 1.0)) x))
double code(double x) {
return (((x * 0.27061) + 2.30753) / fma(x, ((x * 0.04481) + 0.99229), 1.0)) - x;
}
function code(x) return Float64(Float64(Float64(Float64(x * 0.27061) + 2.30753) / fma(x, Float64(Float64(x * 0.04481) + 0.99229), 1.0)) - x) end
code[x_] := N[(N[(N[(N[(x * 0.27061), $MachinePrecision] + 2.30753), $MachinePrecision] / N[(x * N[(N[(x * 0.04481), $MachinePrecision] + 0.99229), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 0.27061 + 2.30753}{\mathsf{fma}\left(x, x \cdot 0.04481 + 0.99229, 1\right)} - x
\end{array}
Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
neg-mul-199.9%
neg-mul-199.9%
distribute-lft-in99.9%
distribute-rgt-in99.9%
*-commutative99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified100.0%
fma-udef100.0%
Applied egg-rr100.0%
fma-udef100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x) :precision binary64 (- (/ (+ (* x 0.27061) 2.30753) (+ 1.0 (* x (+ (* x 0.04481) 0.99229)))) x))
double code(double x) {
return (((x * 0.27061) + 2.30753) / (1.0 + (x * ((x * 0.04481) + 0.99229)))) - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((x * 0.27061d0) + 2.30753d0) / (1.0d0 + (x * ((x * 0.04481d0) + 0.99229d0)))) - x
end function
public static double code(double x) {
return (((x * 0.27061) + 2.30753) / (1.0 + (x * ((x * 0.04481) + 0.99229)))) - x;
}
def code(x): return (((x * 0.27061) + 2.30753) / (1.0 + (x * ((x * 0.04481) + 0.99229)))) - x
function code(x) return Float64(Float64(Float64(Float64(x * 0.27061) + 2.30753) / Float64(1.0 + Float64(x * Float64(Float64(x * 0.04481) + 0.99229)))) - x) end
function tmp = code(x) tmp = (((x * 0.27061) + 2.30753) / (1.0 + (x * ((x * 0.04481) + 0.99229)))) - x; end
code[x_] := N[(N[(N[(N[(x * 0.27061), $MachinePrecision] + 2.30753), $MachinePrecision] / N[(1.0 + N[(x * N[(N[(x * 0.04481), $MachinePrecision] + 0.99229), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 0.27061 + 2.30753}{1 + x \cdot \left(x \cdot 0.04481 + 0.99229\right)} - x
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (- (/ (+ (* x 0.27061) 2.30753) (+ 1.0 (* x 0.99229))) x))
double code(double x) {
return (((x * 0.27061) + 2.30753) / (1.0 + (x * 0.99229))) - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((x * 0.27061d0) + 2.30753d0) / (1.0d0 + (x * 0.99229d0))) - x
end function
public static double code(double x) {
return (((x * 0.27061) + 2.30753) / (1.0 + (x * 0.99229))) - x;
}
def code(x): return (((x * 0.27061) + 2.30753) / (1.0 + (x * 0.99229))) - x
function code(x) return Float64(Float64(Float64(Float64(x * 0.27061) + 2.30753) / Float64(1.0 + Float64(x * 0.99229))) - x) end
function tmp = code(x) tmp = (((x * 0.27061) + 2.30753) / (1.0 + (x * 0.99229))) - x; end
code[x_] := N[(N[(N[(N[(x * 0.27061), $MachinePrecision] + 2.30753), $MachinePrecision] / N[(1.0 + N[(x * 0.99229), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 0.27061 + 2.30753}{1 + x \cdot 0.99229} - x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (- 2.30753 x))
double code(double x) {
return 2.30753 - x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 2.30753d0 - x
end function
public static double code(double x) {
return 2.30753 - x;
}
def code(x): return 2.30753 - x
function code(x) return Float64(2.30753 - x) end
function tmp = code(x) tmp = 2.30753 - x; end
code[x_] := N[(2.30753 - x), $MachinePrecision]
\begin{array}{l}
\\
2.30753 - x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 98.4%
Final simplification98.4%
(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)
\begin{array}{l}
\\
-x
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 98.4%
Taylor expanded in x around inf 51.4%
neg-mul-151.4%
Simplified51.4%
Final simplification51.4%
herbie shell --seed 2023320
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, C"
:precision binary64
(- (/ (+ 2.30753 (* x 0.27061)) (+ 1.0 (* x (+ 0.99229 (* x 0.04481))))) x))