
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}
(FPCore (x) :precision binary64 (- 1.0 (fma (* x 0.12) x (* x 0.253))))
double code(double x) {
return 1.0 - fma((x * 0.12), x, (x * 0.253));
}
function code(x) return Float64(1.0 - fma(Float64(x * 0.12), x, Float64(x * 0.253))) end
code[x_] := N[(1.0 - N[(N[(x * 0.12), $MachinePrecision] * x + N[(x * 0.253), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \mathsf{fma}\left(x \cdot 0.12, x, x \cdot 0.253\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
distribute-rgt-in99.9%
fma-def99.9%
*-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (- 1.0 (* x (+ (* x 0.12) 0.253))))
double code(double x) {
return 1.0 - (x * ((x * 0.12) + 0.253));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * ((x * 0.12d0) + 0.253d0))
end function
public static double code(double x) {
return 1.0 - (x * ((x * 0.12) + 0.253));
}
def code(x): return 1.0 - (x * ((x * 0.12) + 0.253))
function code(x) return Float64(1.0 - Float64(x * Float64(Float64(x * 0.12) + 0.253))) end
function tmp = code(x) tmp = 1.0 - (x * ((x * 0.12) + 0.253)); end
code[x_] := N[(1.0 - N[(x * N[(N[(x * 0.12), $MachinePrecision] + 0.253), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(x \cdot 0.12 + 0.253\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (<= x -4.2) (/ x 3.952569169960474) (if (<= x 2.1) 1.0 (* x -0.253))))
double code(double x) {
double tmp;
if (x <= -4.2) {
tmp = x / 3.952569169960474;
} else if (x <= 2.1) {
tmp = 1.0;
} else {
tmp = x * -0.253;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4.2d0)) then
tmp = x / 3.952569169960474d0
else if (x <= 2.1d0) then
tmp = 1.0d0
else
tmp = x * (-0.253d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4.2) {
tmp = x / 3.952569169960474;
} else if (x <= 2.1) {
tmp = 1.0;
} else {
tmp = x * -0.253;
}
return tmp;
}
def code(x): tmp = 0 if x <= -4.2: tmp = x / 3.952569169960474 elif x <= 2.1: tmp = 1.0 else: tmp = x * -0.253 return tmp
function code(x) tmp = 0.0 if (x <= -4.2) tmp = Float64(x / 3.952569169960474); elseif (x <= 2.1) tmp = 1.0; else tmp = Float64(x * -0.253); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4.2) tmp = x / 3.952569169960474; elseif (x <= 2.1) tmp = 1.0; else tmp = x * -0.253; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4.2], N[(x / 3.952569169960474), $MachinePrecision], If[LessEqual[x, 2.1], 1.0, N[(x * -0.253), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2:\\
\;\;\;\;\frac{x}{3.952569169960474}\\
\mathbf{elif}\;x \leq 2.1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot -0.253\\
\end{array}
\end{array}
if x < -4.20000000000000018Initial program 99.8%
Taylor expanded in x around 0 0.5%
*-commutative0.5%
Simplified0.5%
Taylor expanded in x around inf 0.5%
*-commutative0.5%
Simplified0.5%
add-sqr-sqrt0.5%
sqrt-unprod0.5%
swap-sqr0.5%
metadata-eval0.5%
metadata-eval0.5%
swap-sqr0.5%
metadata-eval0.5%
div-inv0.5%
metadata-eval0.5%
div-inv0.5%
sqrt-unprod0.0%
add-sqr-sqrt7.0%
Applied egg-rr7.0%
if -4.20000000000000018 < x < 2.10000000000000009Initial program 100.0%
Taylor expanded in x around 0 99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 98.0%
if 2.10000000000000009 < x Initial program 99.8%
Taylor expanded in x around 0 7.0%
*-commutative7.0%
Simplified7.0%
Taylor expanded in x around inf 7.0%
*-commutative7.0%
Simplified7.0%
Final simplification46.4%
(FPCore (x) :precision binary64 (if (<= x -4.2) (/ x 3.952569169960474) (- 1.0 (* x 0.253))))
double code(double x) {
double tmp;
if (x <= -4.2) {
tmp = x / 3.952569169960474;
} else {
tmp = 1.0 - (x * 0.253);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4.2d0)) then
tmp = x / 3.952569169960474d0
else
tmp = 1.0d0 - (x * 0.253d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4.2) {
tmp = x / 3.952569169960474;
} else {
tmp = 1.0 - (x * 0.253);
}
return tmp;
}
def code(x): tmp = 0 if x <= -4.2: tmp = x / 3.952569169960474 else: tmp = 1.0 - (x * 0.253) return tmp
function code(x) tmp = 0.0 if (x <= -4.2) tmp = Float64(x / 3.952569169960474); else tmp = Float64(1.0 - Float64(x * 0.253)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4.2) tmp = x / 3.952569169960474; else tmp = 1.0 - (x * 0.253); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4.2], N[(x / 3.952569169960474), $MachinePrecision], N[(1.0 - N[(x * 0.253), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2:\\
\;\;\;\;\frac{x}{3.952569169960474}\\
\mathbf{else}:\\
\;\;\;\;1 - x \cdot 0.253\\
\end{array}
\end{array}
if x < -4.20000000000000018Initial program 99.8%
Taylor expanded in x around 0 0.5%
*-commutative0.5%
Simplified0.5%
Taylor expanded in x around inf 0.5%
*-commutative0.5%
Simplified0.5%
add-sqr-sqrt0.5%
sqrt-unprod0.5%
swap-sqr0.5%
metadata-eval0.5%
metadata-eval0.5%
swap-sqr0.5%
metadata-eval0.5%
div-inv0.5%
metadata-eval0.5%
div-inv0.5%
sqrt-unprod0.0%
add-sqr-sqrt7.0%
Applied egg-rr7.0%
if -4.20000000000000018 < x Initial program 99.9%
Taylor expanded in x around 0 64.6%
*-commutative64.6%
Simplified64.6%
Final simplification47.0%
(FPCore (x) :precision binary64 (- 1.0 (* x (/ x 8.333333333333334))))
double code(double x) {
return 1.0 - (x * (x / 8.333333333333334));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (x / 8.333333333333334d0))
end function
public static double code(double x) {
return 1.0 - (x * (x / 8.333333333333334));
}
def code(x): return 1.0 - (x * (x / 8.333333333333334))
function code(x) return Float64(1.0 - Float64(x * Float64(x / 8.333333333333334))) end
function tmp = code(x) tmp = 1.0 - (x * (x / 8.333333333333334)); end
code[x_] := N[(1.0 - N[(x * N[(x / 8.333333333333334), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \frac{x}{8.333333333333334}
\end{array}
Initial program 99.9%
flip-+99.9%
associate-*r/88.3%
metadata-eval88.3%
pow288.3%
*-commutative88.3%
cancel-sign-sub-inv88.3%
metadata-eval88.3%
Applied egg-rr88.3%
associate-/l*99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 97.7%
clear-num97.7%
inv-pow97.7%
associate-/l/97.8%
pow297.8%
Applied egg-rr97.8%
unpow-197.8%
clear-num97.7%
unpow297.7%
associate-/l*97.7%
Applied egg-rr97.7%
associate-/r/97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (x) :precision binary64 (+ 1.0 (* x (* x -0.12))))
double code(double x) {
return 1.0 + (x * (x * -0.12));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + (x * (x * (-0.12d0)))
end function
public static double code(double x) {
return 1.0 + (x * (x * -0.12));
}
def code(x): return 1.0 + (x * (x * -0.12))
function code(x) return Float64(1.0 + Float64(x * Float64(x * -0.12))) end
function tmp = code(x) tmp = 1.0 + (x * (x * -0.12)); end
code[x_] := N[(1.0 + N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + x \cdot \left(x \cdot -0.12\right)
\end{array}
Initial program 99.9%
flip-+99.9%
associate-*r/88.3%
metadata-eval88.3%
pow288.3%
*-commutative88.3%
cancel-sign-sub-inv88.3%
metadata-eval88.3%
Applied egg-rr88.3%
associate-/l*99.8%
*-commutative99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 97.7%
frac-2neg97.7%
associate-/r/97.7%
metadata-eval97.7%
Applied egg-rr97.7%
Taylor expanded in x around 0 97.8%
*-commutative97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x 2.1) 1.0 (* x -0.253)))
double code(double x) {
double tmp;
if (x <= 2.1) {
tmp = 1.0;
} else {
tmp = x * -0.253;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.1d0) then
tmp = 1.0d0
else
tmp = x * (-0.253d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 2.1) {
tmp = 1.0;
} else {
tmp = x * -0.253;
}
return tmp;
}
def code(x): tmp = 0 if x <= 2.1: tmp = 1.0 else: tmp = x * -0.253 return tmp
function code(x) tmp = 0.0 if (x <= 2.1) tmp = 1.0; else tmp = Float64(x * -0.253); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2.1) tmp = 1.0; else tmp = x * -0.253; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2.1], 1.0, N[(x * -0.253), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;x \cdot -0.253\\
\end{array}
\end{array}
if x < 2.10000000000000009Initial program 99.9%
Taylor expanded in x around 0 58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in x around 0 57.9%
if 2.10000000000000009 < x Initial program 99.8%
Taylor expanded in x around 0 7.0%
*-commutative7.0%
Simplified7.0%
Taylor expanded in x around inf 7.0%
*-commutative7.0%
Simplified7.0%
Final simplification44.6%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 45.1%
*-commutative45.1%
Simplified45.1%
Taylor expanded in x around 0 43.0%
Final simplification43.0%
herbie shell --seed 2023336
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(- 1.0 (* x (+ 0.253 (* x 0.12)))))