
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))))
(-
1.0
(*
(*
t_0
(+
0.254829592
(*
t_0
(+
-0.284496736
(*
t_0
(+ 1.421413741 (* t_0 (+ -1.453152027 (* t_0 1.061405429)))))))))
(exp (- (* (fabs x) (fabs x))))))))
double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * fabs(x)));
return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * exp(-(fabs(x) * fabs(x))));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 1.0d0 / (1.0d0 + (0.3275911d0 * abs(x)))
code = 1.0d0 - ((t_0 * (0.254829592d0 + (t_0 * ((-0.284496736d0) + (t_0 * (1.421413741d0 + (t_0 * ((-1.453152027d0) + (t_0 * 1.061405429d0))))))))) * exp(-(abs(x) * abs(x))))
end function
public static double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * Math.abs(x)));
return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * Math.exp(-(Math.abs(x) * Math.abs(x))));
}
def code(x): t_0 = 1.0 / (1.0 + (0.3275911 * math.fabs(x))) return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * math.exp(-(math.fabs(x) * math.fabs(x))))
function code(x) t_0 = Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) return Float64(1.0 - Float64(Float64(t_0 * Float64(0.254829592 + Float64(t_0 * Float64(-0.284496736 + Float64(t_0 * Float64(1.421413741 + Float64(t_0 * Float64(-1.453152027 + Float64(t_0 * 1.061405429))))))))) * exp(Float64(-Float64(abs(x) * abs(x)))))) end
function tmp = code(x) t_0 = 1.0 / (1.0 + (0.3275911 * abs(x))); tmp = 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * exp(-(abs(x) * abs(x)))); end
code[x_] := Block[{t$95$0 = N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(1.0 - N[(N[(t$95$0 * N[(0.254829592 + N[(t$95$0 * N[(-0.284496736 + N[(t$95$0 * N[(1.421413741 + N[(t$95$0 * N[(-1.453152027 + N[(t$95$0 * 1.061405429), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{1 + 0.3275911 \cdot \left|x\right|}\\
1 - \left(t_0 \cdot \left(0.254829592 + t_0 \cdot \left(-0.284496736 + t_0 \cdot \left(1.421413741 + t_0 \cdot \left(-1.453152027 + t_0 \cdot 1.061405429\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))))
(-
1.0
(*
(*
t_0
(+
0.254829592
(*
t_0
(+
-0.284496736
(*
t_0
(+ 1.421413741 (* t_0 (+ -1.453152027 (* t_0 1.061405429)))))))))
(exp (- (* (fabs x) (fabs x))))))))
double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * fabs(x)));
return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * exp(-(fabs(x) * fabs(x))));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 1.0d0 / (1.0d0 + (0.3275911d0 * abs(x)))
code = 1.0d0 - ((t_0 * (0.254829592d0 + (t_0 * ((-0.284496736d0) + (t_0 * (1.421413741d0 + (t_0 * ((-1.453152027d0) + (t_0 * 1.061405429d0))))))))) * exp(-(abs(x) * abs(x))))
end function
public static double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * Math.abs(x)));
return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * Math.exp(-(Math.abs(x) * Math.abs(x))));
}
def code(x): t_0 = 1.0 / (1.0 + (0.3275911 * math.fabs(x))) return 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * math.exp(-(math.fabs(x) * math.fabs(x))))
function code(x) t_0 = Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) return Float64(1.0 - Float64(Float64(t_0 * Float64(0.254829592 + Float64(t_0 * Float64(-0.284496736 + Float64(t_0 * Float64(1.421413741 + Float64(t_0 * Float64(-1.453152027 + Float64(t_0 * 1.061405429))))))))) * exp(Float64(-Float64(abs(x) * abs(x)))))) end
function tmp = code(x) t_0 = 1.0 / (1.0 + (0.3275911 * abs(x))); tmp = 1.0 - ((t_0 * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * exp(-(abs(x) * abs(x)))); end
code[x_] := Block[{t$95$0 = N[(1.0 / N[(1.0 + N[(0.3275911 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(1.0 - N[(N[(t$95$0 * N[(0.254829592 + N[(t$95$0 * N[(-0.284496736 + N[(t$95$0 * N[(1.421413741 + N[(t$95$0 * N[(-1.453152027 + N[(t$95$0 * 1.061405429), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[(-N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{1 + 0.3275911 \cdot \left|x\right|}\\
1 - \left(t_0 \cdot \left(0.254829592 + t_0 \cdot \left(-0.284496736 + t_0 \cdot \left(1.421413741 + t_0 \cdot \left(-1.453152027 + t_0 \cdot 1.061405429\right)\right)\right)\right)\right) \cdot e^{-\left|x\right| \cdot \left|x\right|}
\end{array}
\end{array}
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0
(sqrt
(fma
-0.00011824294398844343
(* x x)
(fma -0.37545125292247583 (pow x 3.0) (* x 1.128386358070218))))))
(if (<= (fabs x) 0.0001)
(fma t_0 t_0 1e-9)
(- 1.0 (/ 0.7778892405807117 (* x (exp (* x x))))))))x = abs(x);
double code(double x) {
double t_0 = sqrt(fma(-0.00011824294398844343, (x * x), fma(-0.37545125292247583, pow(x, 3.0), (x * 1.128386358070218))));
double tmp;
if (fabs(x) <= 0.0001) {
tmp = fma(t_0, t_0, 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / (x * exp((x * x))));
}
return tmp;
}
x = abs(x) function code(x) t_0 = sqrt(fma(-0.00011824294398844343, Float64(x * x), fma(-0.37545125292247583, (x ^ 3.0), Float64(x * 1.128386358070218)))) tmp = 0.0 if (abs(x) <= 0.0001) tmp = fma(t_0, t_0, 1e-9); else tmp = Float64(1.0 - Float64(0.7778892405807117 / Float64(x * exp(Float64(x * x))))); end return tmp end
NOTE: x should be positive before calling this function
code[x_] := Block[{t$95$0 = N[Sqrt[N[(-0.00011824294398844343 * N[(x * x), $MachinePrecision] + N[(-0.37545125292247583 * N[Power[x, 3.0], $MachinePrecision] + N[(x * 1.128386358070218), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 0.0001], N[(t$95$0 * t$95$0 + 1e-9), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / N[(x * N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-0.00011824294398844343, x \cdot x, \mathsf{fma}\left(-0.37545125292247583, {x}^{3}, x \cdot 1.128386358070218\right)\right)}\\
\mathbf{if}\;\left|x\right| \leq 0.0001:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_0, 10^{-9}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x \cdot e^{x \cdot x}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 1.00000000000000005e-4Initial program 58.0%
Applied egg-rr57.7%
distribute-neg-frac57.7%
Simplified57.7%
Taylor expanded in x around 0 99.0%
add-cbrt-cube97.6%
Applied egg-rr97.6%
add-cbrt-cube99.0%
+-commutative99.0%
add-sqr-sqrt53.5%
fma-def53.5%
*-commutative53.5%
*-commutative53.5%
Applied egg-rr53.5%
if 1.00000000000000005e-4 < (fabs.f64 x) Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification76.9%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(if (<= (fabs x) 0.0001)
(+
(* (* x x) (+ -0.00011824294398844343 (* x -0.37545125292247583)))
(/
(+ (* (* x x) 1.2732557730789702) -1e-18)
(fma 1.128386358070218 x -1e-9)))
(- 1.0 (/ 0.7778892405807117 (* x (exp (* x x)))))))x = abs(x);
double code(double x) {
double tmp;
if (fabs(x) <= 0.0001) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((((x * x) * 1.2732557730789702) + -1e-18) / fma(1.128386358070218, x, -1e-9));
} else {
tmp = 1.0 - (0.7778892405807117 / (x * exp((x * x))));
}
return tmp;
}
x = abs(x) function code(x) tmp = 0.0 if (abs(x) <= 0.0001) tmp = Float64(Float64(Float64(x * x) * Float64(-0.00011824294398844343 + Float64(x * -0.37545125292247583))) + Float64(Float64(Float64(Float64(x * x) * 1.2732557730789702) + -1e-18) / fma(1.128386358070218, x, -1e-9))); else tmp = Float64(1.0 - Float64(0.7778892405807117 / Float64(x * exp(Float64(x * x))))); end return tmp end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 0.0001], N[(N[(N[(x * x), $MachinePrecision] * N[(-0.00011824294398844343 + N[(x * -0.37545125292247583), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(x * x), $MachinePrecision] * 1.2732557730789702), $MachinePrecision] + -1e-18), $MachinePrecision] / N[(1.128386358070218 * x + -1e-9), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / N[(x * N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.0001:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(-0.00011824294398844343 + x \cdot -0.37545125292247583\right) + \frac{\left(x \cdot x\right) \cdot 1.2732557730789702 + -1 \cdot 10^{-18}}{\mathsf{fma}\left(1.128386358070218, x, -1 \cdot 10^{-9}\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x \cdot e^{x \cdot x}}\\
\end{array}
\end{array}
if (fabs.f64 x) < 1.00000000000000005e-4Initial program 58.0%
Applied egg-rr57.7%
distribute-neg-frac57.7%
Simplified57.7%
Taylor expanded in x around 0 99.0%
*-un-lft-identity99.0%
fma-def99.0%
pow299.0%
fma-def99.0%
*-commutative99.0%
Applied egg-rr99.0%
*-lft-identity99.0%
+-commutative99.0%
fma-udef99.0%
fma-udef99.0%
associate-+r+99.0%
unpow299.0%
associate-+l+99.0%
*-commutative99.0%
*-commutative99.0%
unpow399.0%
unpow299.0%
associate-*l*99.0%
distribute-lft-out99.0%
unpow299.0%
*-commutative99.0%
fma-def99.0%
Simplified99.0%
fma-udef99.0%
*-commutative99.0%
flip-+99.0%
pow299.0%
*-commutative99.0%
metadata-eval99.0%
*-commutative99.0%
fma-neg99.0%
metadata-eval99.0%
Applied egg-rr99.0%
sub-neg99.0%
unpow299.0%
swap-sqr99.0%
metadata-eval99.0%
metadata-eval99.0%
Simplified99.0%
if 1.00000000000000005e-4 < (fabs.f64 x) Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.5%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(if (<= x 1.05)
(+
(* (* x x) (+ -0.00011824294398844343 (* x -0.37545125292247583)))
(+ (* x 1.128386358070218) 1e-9))
(- 1.0 (/ 0.7778892405807117 (* x (exp (* x x)))))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.05) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / (x * exp((x * x))));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.05d0) then
tmp = ((x * x) * ((-0.00011824294398844343d0) + (x * (-0.37545125292247583d0)))) + ((x * 1.128386358070218d0) + 1d-9)
else
tmp = 1.0d0 - (0.7778892405807117d0 / (x * exp((x * x))))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.05) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / (x * Math.exp((x * x))));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.05: tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9) else: tmp = 1.0 - (0.7778892405807117 / (x * math.exp((x * x)))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.05) tmp = Float64(Float64(Float64(x * x) * Float64(-0.00011824294398844343 + Float64(x * -0.37545125292247583))) + Float64(Float64(x * 1.128386358070218) + 1e-9)); else tmp = Float64(1.0 - Float64(0.7778892405807117 / Float64(x * exp(Float64(x * x))))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.05) tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9); else tmp = 1.0 - (0.7778892405807117 / (x * exp((x * x)))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.05], N[(N[(N[(x * x), $MachinePrecision] * N[(-0.00011824294398844343 + N[(x * -0.37545125292247583), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * 1.128386358070218), $MachinePrecision] + 1e-9), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / N[(x * N[Exp[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.05:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(-0.00011824294398844343 + x \cdot -0.37545125292247583\right) + \left(x \cdot 1.128386358070218 + 10^{-9}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x \cdot e^{x \cdot x}}\\
\end{array}
\end{array}
if x < 1.05000000000000004Initial program 72.4%
Applied egg-rr72.2%
distribute-neg-frac72.2%
Simplified72.2%
Taylor expanded in x around 0 66.0%
*-un-lft-identity66.0%
fma-def66.0%
pow266.0%
fma-def66.0%
*-commutative66.0%
Applied egg-rr66.0%
*-lft-identity66.0%
+-commutative66.0%
fma-udef66.0%
fma-udef66.0%
associate-+r+66.0%
unpow266.0%
associate-+l+66.0%
*-commutative66.0%
*-commutative66.0%
unpow366.0%
unpow266.0%
associate-*l*66.0%
distribute-lft-out66.5%
unpow266.5%
*-commutative66.5%
fma-def66.5%
Simplified66.5%
fma-udef66.5%
Applied egg-rr66.5%
if 1.05000000000000004 < x Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification74.8%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(if (<= x 1.15)
(+
(* (* x x) (+ -0.00011824294398844343 (* x -0.37545125292247583)))
(+ (* x 1.128386358070218) 1e-9))
(- 1.0 (/ 0.7778892405807117 (+ x (pow x 3.0))))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.15) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / (x + pow(x, 3.0)));
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.15d0) then
tmp = ((x * x) * ((-0.00011824294398844343d0) + (x * (-0.37545125292247583d0)))) + ((x * 1.128386358070218d0) + 1d-9)
else
tmp = 1.0d0 - (0.7778892405807117d0 / (x + (x ** 3.0d0)))
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.15) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / (x + Math.pow(x, 3.0)));
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.15: tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9) else: tmp = 1.0 - (0.7778892405807117 / (x + math.pow(x, 3.0))) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.15) tmp = Float64(Float64(Float64(x * x) * Float64(-0.00011824294398844343 + Float64(x * -0.37545125292247583))) + Float64(Float64(x * 1.128386358070218) + 1e-9)); else tmp = Float64(1.0 - Float64(0.7778892405807117 / Float64(x + (x ^ 3.0)))); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.15) tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9); else tmp = 1.0 - (0.7778892405807117 / (x + (x ^ 3.0))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.15], N[(N[(N[(x * x), $MachinePrecision] * N[(-0.00011824294398844343 + N[(x * -0.37545125292247583), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * 1.128386358070218), $MachinePrecision] + 1e-9), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / N[(x + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.15:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(-0.00011824294398844343 + x \cdot -0.37545125292247583\right) + \left(x \cdot 1.128386358070218 + 10^{-9}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x + {x}^{3}}\\
\end{array}
\end{array}
if x < 1.1499999999999999Initial program 72.4%
Applied egg-rr72.2%
distribute-neg-frac72.2%
Simplified72.2%
Taylor expanded in x around 0 66.0%
*-un-lft-identity66.0%
fma-def66.0%
pow266.0%
fma-def66.0%
*-commutative66.0%
Applied egg-rr66.0%
*-lft-identity66.0%
+-commutative66.0%
fma-udef66.0%
fma-udef66.0%
associate-+r+66.0%
unpow266.0%
associate-+l+66.0%
*-commutative66.0%
*-commutative66.0%
unpow366.0%
unpow266.0%
associate-*l*66.0%
distribute-lft-out66.5%
unpow266.5%
*-commutative66.5%
fma-def66.5%
Simplified66.5%
fma-udef66.5%
Applied egg-rr66.5%
if 1.1499999999999999 < x Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification74.8%
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(if (<= x 1.5)
(+
(* (* x x) (+ -0.00011824294398844343 (* x -0.37545125292247583)))
(+ (* x 1.128386358070218) 1e-9))
(- 1.0 (/ 0.7778892405807117 x))))x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.5) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.5d0) then
tmp = ((x * x) * ((-0.00011824294398844343d0) + (x * (-0.37545125292247583d0)))) + ((x * 1.128386358070218d0) + 1d-9)
else
tmp = 1.0d0 - (0.7778892405807117d0 / x)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.5) {
tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9);
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.5: tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9) else: tmp = 1.0 - (0.7778892405807117 / x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.5) tmp = Float64(Float64(Float64(x * x) * Float64(-0.00011824294398844343 + Float64(x * -0.37545125292247583))) + Float64(Float64(x * 1.128386358070218) + 1e-9)); else tmp = Float64(1.0 - Float64(0.7778892405807117 / x)); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.5) tmp = ((x * x) * (-0.00011824294398844343 + (x * -0.37545125292247583))) + ((x * 1.128386358070218) + 1e-9); else tmp = 1.0 - (0.7778892405807117 / x); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.5], N[(N[(N[(x * x), $MachinePrecision] * N[(-0.00011824294398844343 + N[(x * -0.37545125292247583), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * 1.128386358070218), $MachinePrecision] + 1e-9), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(-0.00011824294398844343 + x \cdot -0.37545125292247583\right) + \left(x \cdot 1.128386358070218 + 10^{-9}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x}\\
\end{array}
\end{array}
if x < 1.5Initial program 72.4%
Applied egg-rr72.2%
distribute-neg-frac72.2%
Simplified72.2%
Taylor expanded in x around 0 66.0%
*-un-lft-identity66.0%
fma-def66.0%
pow266.0%
fma-def66.0%
*-commutative66.0%
Applied egg-rr66.0%
*-lft-identity66.0%
+-commutative66.0%
fma-udef66.0%
fma-udef66.0%
associate-+r+66.0%
unpow266.0%
associate-+l+66.0%
*-commutative66.0%
*-commutative66.0%
unpow366.0%
unpow266.0%
associate-*l*66.0%
distribute-lft-out66.5%
unpow266.5%
*-commutative66.5%
fma-def66.5%
Simplified66.5%
fma-udef66.5%
Applied egg-rr66.5%
if 1.5 < x Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 99.2%
Final simplification74.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 1.65) (+ (+ (* x 1.128386358070218) 1e-9) (* x (* x -0.00011824294398844343))) (- 1.0 (/ 0.7778892405807117 x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = ((x * 1.128386358070218) + 1e-9) + (x * (x * -0.00011824294398844343));
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.65d0) then
tmp = ((x * 1.128386358070218d0) + 1d-9) + (x * (x * (-0.00011824294398844343d0)))
else
tmp = 1.0d0 - (0.7778892405807117d0 / x)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = ((x * 1.128386358070218) + 1e-9) + (x * (x * -0.00011824294398844343));
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.65: tmp = ((x * 1.128386358070218) + 1e-9) + (x * (x * -0.00011824294398844343)) else: tmp = 1.0 - (0.7778892405807117 / x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.65) tmp = Float64(Float64(Float64(x * 1.128386358070218) + 1e-9) + Float64(x * Float64(x * -0.00011824294398844343))); else tmp = Float64(1.0 - Float64(0.7778892405807117 / x)); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.65) tmp = ((x * 1.128386358070218) + 1e-9) + (x * (x * -0.00011824294398844343)); else tmp = 1.0 - (0.7778892405807117 / x); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.65], N[(N[(N[(x * 1.128386358070218), $MachinePrecision] + 1e-9), $MachinePrecision] + N[(x * N[(x * -0.00011824294398844343), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65:\\
\;\;\;\;\left(x \cdot 1.128386358070218 + 10^{-9}\right) + x \cdot \left(x \cdot -0.00011824294398844343\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x}\\
\end{array}
\end{array}
if x < 1.6499999999999999Initial program 72.4%
Applied egg-rr72.2%
distribute-neg-frac72.2%
Simplified72.2%
Taylor expanded in x around 0 65.2%
+-commutative65.2%
associate-+r+65.2%
+-commutative65.2%
*-commutative65.2%
fma-def65.2%
*-commutative65.2%
unpow265.2%
associate-*l*65.2%
Simplified65.2%
fma-udef65.2%
Applied egg-rr65.2%
if 1.6499999999999999 < x Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 99.2%
Final simplification73.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 1.65) (+ (* x 1.128386358070218) 1e-9) (- 1.0 (/ 0.7778892405807117 x))))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = (x * 1.128386358070218) + 1e-9;
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.65d0) then
tmp = (x * 1.128386358070218d0) + 1d-9
else
tmp = 1.0d0 - (0.7778892405807117d0 / x)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 1.65) {
tmp = (x * 1.128386358070218) + 1e-9;
} else {
tmp = 1.0 - (0.7778892405807117 / x);
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 1.65: tmp = (x * 1.128386358070218) + 1e-9 else: tmp = 1.0 - (0.7778892405807117 / x) return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 1.65) tmp = Float64(Float64(x * 1.128386358070218) + 1e-9); else tmp = Float64(1.0 - Float64(0.7778892405807117 / x)); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 1.65) tmp = (x * 1.128386358070218) + 1e-9; else tmp = 1.0 - (0.7778892405807117 / x); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 1.65], N[(N[(x * 1.128386358070218), $MachinePrecision] + 1e-9), $MachinePrecision], N[(1.0 - N[(0.7778892405807117 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65:\\
\;\;\;\;x \cdot 1.128386358070218 + 10^{-9}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{0.7778892405807117}{x}\\
\end{array}
\end{array}
if x < 1.6499999999999999Initial program 72.4%
Applied egg-rr72.2%
distribute-neg-frac72.2%
Simplified72.2%
Taylor expanded in x around 0 65.2%
*-commutative65.2%
Simplified65.2%
if 1.6499999999999999 < x Initial program 100.0%
Applied egg-rr100.0%
distribute-neg-frac100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
associate-*r/100.0%
metadata-eval100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in x around 0 99.2%
Final simplification73.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 1e-9)
x = abs(x);
double code(double x) {
return 1e-9;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = 1d-9
end function
x = Math.abs(x);
public static double code(double x) {
return 1e-9;
}
x = abs(x) def code(x): return 1e-9
x = abs(x) function code(x) return 1e-9 end
x = abs(x) function tmp = code(x) tmp = 1e-9; end
NOTE: x should be positive before calling this function code[x_] := 1e-9
\begin{array}{l}
x = |x|\\
\\
10^{-9}
\end{array}
Initial program 79.2%
Applied egg-rr79.0%
distribute-neg-frac79.0%
Simplified79.0%
Taylor expanded in x around 0 53.8%
Final simplification53.8%
herbie shell --seed 2023201
(FPCore (x)
:name "Jmat.Real.erf"
:precision binary64
(- 1.0 (* (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ 0.254829592 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ -0.284496736 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ 1.421413741 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) (+ -1.453152027 (* (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x)))) 1.061405429))))))))) (exp (- (* (fabs x) (fabs x)))))))