
(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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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 7 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))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
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}
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_1 (pow t_0 -1.0))
(t_2 (fma (fabs x) 0.3275911 1.0))
(t_3 (pow t_2 -1.0))
(t_4 (pow t_0 -0.5))
(t_5 (* t_4 t_4))
(t_6 (pow (pow t_2 2.0) -0.5))
(t_7 (pow (pow (exp -1.0) x) x))
(t_8 (fma (/ 1.061405429 t_0) 1.0 -1.453152027))
(t_9
(*
(* t_7 t_5)
(+
(fma -0.284496736 t_5 (* t_5 (* (fma t_8 t_5 1.421413741) t_5)))
0.254829592)))
(t_10 (* t_9 t_9))
(t_11
(pow
(*
(* t_7 t_1)
(+
(fma -0.284496736 t_1 (* t_1 (* (fma t_8 t_1 1.421413741) t_1)))
0.254829592))
3.0))
(t_12 (* t_11 t_11)))
(/
(/ (/ (- 1.0 (* t_12 t_12)) (+ 1.0 t_12)) (+ 1.0 (fma t_10 t_10 t_10)))
(-
1.0
(*
(* -1.0 t_7)
(*
t_3
(fma
t_3
-0.284496736
(fma
(* t_6 t_6)
(fma t_3 (fma (* t_3 1.061405429) 1.0 -1.453152027) 1.421413741)
0.254829592))))))))
double code(double x) {
double t_0 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_1 = pow(t_0, -1.0);
double t_2 = fma(fabs(x), 0.3275911, 1.0);
double t_3 = pow(t_2, -1.0);
double t_4 = pow(t_0, -0.5);
double t_5 = t_4 * t_4;
double t_6 = pow(pow(t_2, 2.0), -0.5);
double t_7 = pow(pow(exp(-1.0), x), x);
double t_8 = fma((1.061405429 / t_0), 1.0, -1.453152027);
double t_9 = (t_7 * t_5) * (fma(-0.284496736, t_5, (t_5 * (fma(t_8, t_5, 1.421413741) * t_5))) + 0.254829592);
double t_10 = t_9 * t_9;
double t_11 = pow(((t_7 * t_1) * (fma(-0.284496736, t_1, (t_1 * (fma(t_8, t_1, 1.421413741) * t_1))) + 0.254829592)), 3.0);
double t_12 = t_11 * t_11;
return (((1.0 - (t_12 * t_12)) / (1.0 + t_12)) / (1.0 + fma(t_10, t_10, t_10))) / (1.0 - ((-1.0 * t_7) * (t_3 * fma(t_3, -0.284496736, fma((t_6 * t_6), fma(t_3, fma((t_3 * 1.061405429), 1.0, -1.453152027), 1.421413741), 0.254829592)))));
}
function code(x) t_0 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_1 = t_0 ^ -1.0 t_2 = fma(abs(x), 0.3275911, 1.0) t_3 = t_2 ^ -1.0 t_4 = t_0 ^ -0.5 t_5 = Float64(t_4 * t_4) t_6 = (t_2 ^ 2.0) ^ -0.5 t_7 = (exp(-1.0) ^ x) ^ x t_8 = fma(Float64(1.061405429 / t_0), 1.0, -1.453152027) t_9 = Float64(Float64(t_7 * t_5) * Float64(fma(-0.284496736, t_5, Float64(t_5 * Float64(fma(t_8, t_5, 1.421413741) * t_5))) + 0.254829592)) t_10 = Float64(t_9 * t_9) t_11 = Float64(Float64(t_7 * t_1) * Float64(fma(-0.284496736, t_1, Float64(t_1 * Float64(fma(t_8, t_1, 1.421413741) * t_1))) + 0.254829592)) ^ 3.0 t_12 = Float64(t_11 * t_11) return Float64(Float64(Float64(Float64(1.0 - Float64(t_12 * t_12)) / Float64(1.0 + t_12)) / Float64(1.0 + fma(t_10, t_10, t_10))) / Float64(1.0 - Float64(Float64(-1.0 * t_7) * Float64(t_3 * fma(t_3, -0.284496736, fma(Float64(t_6 * t_6), fma(t_3, fma(Float64(t_3 * 1.061405429), 1.0, -1.453152027), 1.421413741), 0.254829592)))))) end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[x], $MachinePrecision] * 0.3275911 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, -1.0], $MachinePrecision]}, Block[{t$95$4 = N[Power[t$95$0, -0.5], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Power[t$95$2, 2.0], $MachinePrecision], -0.5], $MachinePrecision]}, Block[{t$95$7 = N[Power[N[Power[N[Exp[-1.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]}, Block[{t$95$8 = N[(N[(1.061405429 / t$95$0), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision]}, Block[{t$95$9 = N[(N[(t$95$7 * t$95$5), $MachinePrecision] * N[(N[(-0.284496736 * t$95$5 + N[(t$95$5 * N[(N[(t$95$8 * t$95$5 + 1.421413741), $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.254829592), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$10 = N[(t$95$9 * t$95$9), $MachinePrecision]}, Block[{t$95$11 = N[Power[N[(N[(t$95$7 * t$95$1), $MachinePrecision] * N[(N[(-0.284496736 * t$95$1 + N[(t$95$1 * N[(N[(t$95$8 * t$95$1 + 1.421413741), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.254829592), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$12 = N[(t$95$11 * t$95$11), $MachinePrecision]}, N[(N[(N[(N[(1.0 - N[(t$95$12 * t$95$12), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$12), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$10 * t$95$10 + t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[(-1.0 * t$95$7), $MachinePrecision] * N[(t$95$3 * N[(t$95$3 * -0.284496736 + N[(N[(t$95$6 * t$95$6), $MachinePrecision] * N[(t$95$3 * N[(N[(t$95$3 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] + 1.421413741), $MachinePrecision] + 0.254829592), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_1 := {t\_0}^{-1}\\
t_2 := \mathsf{fma}\left(\left|x\right|, 0.3275911, 1\right)\\
t_3 := {t\_2}^{-1}\\
t_4 := {t\_0}^{-0.5}\\
t_5 := t\_4 \cdot t\_4\\
t_6 := {\left({t\_2}^{2}\right)}^{-0.5}\\
t_7 := {\left({\left(e^{-1}\right)}^{x}\right)}^{x}\\
t_8 := \mathsf{fma}\left(\frac{1.061405429}{t\_0}, 1, -1.453152027\right)\\
t_9 := \left(t\_7 \cdot t\_5\right) \cdot \left(\mathsf{fma}\left(-0.284496736, t\_5, t\_5 \cdot \left(\mathsf{fma}\left(t\_8, t\_5, 1.421413741\right) \cdot t\_5\right)\right) + 0.254829592\right)\\
t_10 := t\_9 \cdot t\_9\\
t_11 := {\left(\left(t\_7 \cdot t\_1\right) \cdot \left(\mathsf{fma}\left(-0.284496736, t\_1, t\_1 \cdot \left(\mathsf{fma}\left(t\_8, t\_1, 1.421413741\right) \cdot t\_1\right)\right) + 0.254829592\right)\right)}^{3}\\
t_12 := t\_11 \cdot t\_11\\
\frac{\frac{\frac{1 - t\_12 \cdot t\_12}{1 + t\_12}}{1 + \mathsf{fma}\left(t\_10, t\_10, t\_10\right)}}{1 - \left(-1 \cdot t\_7\right) \cdot \left(t\_3 \cdot \mathsf{fma}\left(t\_3, -0.284496736, \mathsf{fma}\left(t\_6 \cdot t\_6, \mathsf{fma}\left(t\_3, \mathsf{fma}\left(t\_3 \cdot 1.061405429, 1, -1.453152027\right), 1.421413741\right), 0.254829592\right)\right)\right)}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites77.8%
Applied rewrites77.8%
Applied rewrites79.1%
Applied rewrites79.2%
Final simplification79.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_1 (pow (exp -1.0) (* x x)))
(t_2 (fma (fabs x) 0.3275911 1.0))
(t_3 (/ -1.0 t_0))
(t_4 (pow (pow (exp -1.0) x) x))
(t_5 (pow t_0 -0.5))
(t_6 (* t_5 t_5))
(t_7
(pow
(*
t_4
(*
t_3
(fma
(fma
(fma (fma (/ 1.061405429 t_0) 1.0 -1.453152027) t_6 1.421413741)
t_6
-0.284496736)
t_6
0.254829592)))
9.0))
(t_8 (pow t_0 -1.0))
(t_9 (pow t_2 -1.0))
(t_10
(pow
(*
t_4
(*
(fma
t_9
(fma
t_9
(fma t_9 (fma (* t_9 1.061405429) 1.0 -1.453152027) 1.421413741)
-0.284496736)
0.254829592)
(/ -1.0 t_2)))
3.0))
(t_11
(fma
(fma
(fma (fma (* t_8 1.061405429) 1.0 -1.453152027) t_8 1.421413741)
t_8
-0.284496736)
t_8
0.254829592)))
(/
(/
(/ (+ 1.0 (pow t_7 3.0)) (+ 1.0 (- (* t_7 t_7) t_7)))
(+ 1.0 (- (* t_10 t_10) t_10)))
(+
1.0
(-
(* (* (* (* t_1 t_8) t_11) (* t_11 t_8)) t_1)
(* (* (* -1.0 t_3) (* -1.0 t_11)) t_1))))))
double code(double x) {
double t_0 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_1 = pow(exp(-1.0), (x * x));
double t_2 = fma(fabs(x), 0.3275911, 1.0);
double t_3 = -1.0 / t_0;
double t_4 = pow(pow(exp(-1.0), x), x);
double t_5 = pow(t_0, -0.5);
double t_6 = t_5 * t_5;
double t_7 = pow((t_4 * (t_3 * fma(fma(fma(fma((1.061405429 / t_0), 1.0, -1.453152027), t_6, 1.421413741), t_6, -0.284496736), t_6, 0.254829592))), 9.0);
double t_8 = pow(t_0, -1.0);
double t_9 = pow(t_2, -1.0);
double t_10 = pow((t_4 * (fma(t_9, fma(t_9, fma(t_9, fma((t_9 * 1.061405429), 1.0, -1.453152027), 1.421413741), -0.284496736), 0.254829592) * (-1.0 / t_2))), 3.0);
double t_11 = fma(fma(fma(fma((t_8 * 1.061405429), 1.0, -1.453152027), t_8, 1.421413741), t_8, -0.284496736), t_8, 0.254829592);
return (((1.0 + pow(t_7, 3.0)) / (1.0 + ((t_7 * t_7) - t_7))) / (1.0 + ((t_10 * t_10) - t_10))) / (1.0 + (((((t_1 * t_8) * t_11) * (t_11 * t_8)) * t_1) - (((-1.0 * t_3) * (-1.0 * t_11)) * t_1)));
}
function code(x) t_0 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_1 = exp(-1.0) ^ Float64(x * x) t_2 = fma(abs(x), 0.3275911, 1.0) t_3 = Float64(-1.0 / t_0) t_4 = (exp(-1.0) ^ x) ^ x t_5 = t_0 ^ -0.5 t_6 = Float64(t_5 * t_5) t_7 = Float64(t_4 * Float64(t_3 * fma(fma(fma(fma(Float64(1.061405429 / t_0), 1.0, -1.453152027), t_6, 1.421413741), t_6, -0.284496736), t_6, 0.254829592))) ^ 9.0 t_8 = t_0 ^ -1.0 t_9 = t_2 ^ -1.0 t_10 = Float64(t_4 * Float64(fma(t_9, fma(t_9, fma(t_9, fma(Float64(t_9 * 1.061405429), 1.0, -1.453152027), 1.421413741), -0.284496736), 0.254829592) * Float64(-1.0 / t_2))) ^ 3.0 t_11 = fma(fma(fma(fma(Float64(t_8 * 1.061405429), 1.0, -1.453152027), t_8, 1.421413741), t_8, -0.284496736), t_8, 0.254829592) return Float64(Float64(Float64(Float64(1.0 + (t_7 ^ 3.0)) / Float64(1.0 + Float64(Float64(t_7 * t_7) - t_7))) / Float64(1.0 + Float64(Float64(t_10 * t_10) - t_10))) / Float64(1.0 + Float64(Float64(Float64(Float64(Float64(t_1 * t_8) * t_11) * Float64(t_11 * t_8)) * t_1) - Float64(Float64(Float64(-1.0 * t_3) * Float64(-1.0 * t_11)) * t_1)))) end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[x], $MachinePrecision] * 0.3275911 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 / t$95$0), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Power[N[Exp[-1.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]}, Block[{t$95$5 = N[Power[t$95$0, -0.5], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$5 * t$95$5), $MachinePrecision]}, Block[{t$95$7 = N[Power[N[(t$95$4 * N[(t$95$3 * N[(N[(N[(N[(N[(1.061405429 / t$95$0), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$6 + 1.421413741), $MachinePrecision] * t$95$6 + -0.284496736), $MachinePrecision] * t$95$6 + 0.254829592), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 9.0], $MachinePrecision]}, Block[{t$95$8 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$9 = N[Power[t$95$2, -1.0], $MachinePrecision]}, Block[{t$95$10 = N[Power[N[(t$95$4 * N[(N[(t$95$9 * N[(t$95$9 * N[(t$95$9 * N[(N[(t$95$9 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] + 1.421413741), $MachinePrecision] + -0.284496736), $MachinePrecision] + 0.254829592), $MachinePrecision] * N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]}, Block[{t$95$11 = N[(N[(N[(N[(N[(t$95$8 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$8 + 1.421413741), $MachinePrecision] * t$95$8 + -0.284496736), $MachinePrecision] * t$95$8 + 0.254829592), $MachinePrecision]}, N[(N[(N[(N[(1.0 + N[Power[t$95$7, 3.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(t$95$7 * t$95$7), $MachinePrecision] - t$95$7), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(t$95$10 * t$95$10), $MachinePrecision] - t$95$10), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(N[(N[(N[(t$95$1 * t$95$8), $MachinePrecision] * t$95$11), $MachinePrecision] * N[(t$95$11 * t$95$8), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[(N[(-1.0 * t$95$3), $MachinePrecision] * N[(-1.0 * t$95$11), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_1 := {\left(e^{-1}\right)}^{\left(x \cdot x\right)}\\
t_2 := \mathsf{fma}\left(\left|x\right|, 0.3275911, 1\right)\\
t_3 := \frac{-1}{t\_0}\\
t_4 := {\left({\left(e^{-1}\right)}^{x}\right)}^{x}\\
t_5 := {t\_0}^{-0.5}\\
t_6 := t\_5 \cdot t\_5\\
t_7 := {\left(t\_4 \cdot \left(t\_3 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1.061405429}{t\_0}, 1, -1.453152027\right), t\_6, 1.421413741\right), t\_6, -0.284496736\right), t\_6, 0.254829592\right)\right)\right)}^{9}\\
t_8 := {t\_0}^{-1}\\
t_9 := {t\_2}^{-1}\\
t_10 := {\left(t\_4 \cdot \left(\mathsf{fma}\left(t\_9, \mathsf{fma}\left(t\_9, \mathsf{fma}\left(t\_9, \mathsf{fma}\left(t\_9 \cdot 1.061405429, 1, -1.453152027\right), 1.421413741\right), -0.284496736\right), 0.254829592\right) \cdot \frac{-1}{t\_2}\right)\right)}^{3}\\
t_11 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(t\_8 \cdot 1.061405429, 1, -1.453152027\right), t\_8, 1.421413741\right), t\_8, -0.284496736\right), t\_8, 0.254829592\right)\\
\frac{\frac{\frac{1 + {t\_7}^{3}}{1 + \left(t\_7 \cdot t\_7 - t\_7\right)}}{1 + \left(t\_10 \cdot t\_10 - t\_10\right)}}{1 + \left(\left(\left(\left(t\_1 \cdot t\_8\right) \cdot t\_11\right) \cdot \left(t\_11 \cdot t\_8\right)\right) \cdot t\_1 - \left(\left(-1 \cdot t\_3\right) \cdot \left(-1 \cdot t\_11\right)\right) \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites79.0%
Applied rewrites79.1%
Applied rewrites79.1%
Final simplification79.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (fabs x) 0.3275911 1.0))
(t_1 (pow (exp -1.0) (* x x)))
(t_2 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_3 (pow t_2 -1.0))
(t_4
(fma
(fma
(fma (fma (* t_3 1.061405429) 1.0 -1.453152027) t_3 1.421413741)
t_3
-0.284496736)
t_3
0.254829592))
(t_5 (pow t_0 -1.0))
(t_6
(pow
(*
(pow (pow (exp -1.0) x) x)
(*
(fma
t_5
(fma
t_5
(fma t_5 (fma (* t_5 1.061405429) 1.0 -1.453152027) 1.421413741)
-0.284496736)
0.254829592)
(/ -1.0 t_0)))
3.0)))
(/
(/ (+ 1.0 (pow t_6 3.0)) (+ 1.0 (- (* t_6 t_6) t_6)))
(+
1.0
(-
(* (* (* (* t_1 t_3) t_4) (* t_4 t_3)) t_1)
(* (* (* -1.0 (/ -1.0 t_2)) (* -1.0 t_4)) t_1))))))
double code(double x) {
double t_0 = fma(fabs(x), 0.3275911, 1.0);
double t_1 = pow(exp(-1.0), (x * x));
double t_2 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_3 = pow(t_2, -1.0);
double t_4 = fma(fma(fma(fma((t_3 * 1.061405429), 1.0, -1.453152027), t_3, 1.421413741), t_3, -0.284496736), t_3, 0.254829592);
double t_5 = pow(t_0, -1.0);
double t_6 = pow((pow(pow(exp(-1.0), x), x) * (fma(t_5, fma(t_5, fma(t_5, fma((t_5 * 1.061405429), 1.0, -1.453152027), 1.421413741), -0.284496736), 0.254829592) * (-1.0 / t_0))), 3.0);
return ((1.0 + pow(t_6, 3.0)) / (1.0 + ((t_6 * t_6) - t_6))) / (1.0 + (((((t_1 * t_3) * t_4) * (t_4 * t_3)) * t_1) - (((-1.0 * (-1.0 / t_2)) * (-1.0 * t_4)) * t_1)));
}
function code(x) t_0 = fma(abs(x), 0.3275911, 1.0) t_1 = exp(-1.0) ^ Float64(x * x) t_2 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_3 = t_2 ^ -1.0 t_4 = fma(fma(fma(fma(Float64(t_3 * 1.061405429), 1.0, -1.453152027), t_3, 1.421413741), t_3, -0.284496736), t_3, 0.254829592) t_5 = t_0 ^ -1.0 t_6 = Float64(((exp(-1.0) ^ x) ^ x) * Float64(fma(t_5, fma(t_5, fma(t_5, fma(Float64(t_5 * 1.061405429), 1.0, -1.453152027), 1.421413741), -0.284496736), 0.254829592) * Float64(-1.0 / t_0))) ^ 3.0 return Float64(Float64(Float64(1.0 + (t_6 ^ 3.0)) / Float64(1.0 + Float64(Float64(t_6 * t_6) - t_6))) / Float64(1.0 + Float64(Float64(Float64(Float64(Float64(t_1 * t_3) * t_4) * Float64(t_4 * t_3)) * t_1) - Float64(Float64(Float64(-1.0 * Float64(-1.0 / t_2)) * Float64(-1.0 * t_4)) * t_1)))) end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * 0.3275911 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, -1.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(N[(N[(t$95$3 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$3 + 1.421413741), $MachinePrecision] * t$95$3 + -0.284496736), $MachinePrecision] * t$95$3 + 0.254829592), $MachinePrecision]}, Block[{t$95$5 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(N[Power[N[Power[N[Exp[-1.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision] * N[(N[(t$95$5 * N[(t$95$5 * N[(t$95$5 * N[(N[(t$95$5 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] + 1.421413741), $MachinePrecision] + -0.284496736), $MachinePrecision] + 0.254829592), $MachinePrecision] * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision]}, N[(N[(N[(1.0 + N[Power[t$95$6, 3.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(t$95$6 * t$95$6), $MachinePrecision] - t$95$6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(N[(N[(N[(t$95$1 * t$95$3), $MachinePrecision] * t$95$4), $MachinePrecision] * N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[(N[(-1.0 * N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * t$95$4), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right|, 0.3275911, 1\right)\\
t_1 := {\left(e^{-1}\right)}^{\left(x \cdot x\right)}\\
t_2 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_3 := {t\_2}^{-1}\\
t_4 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(t\_3 \cdot 1.061405429, 1, -1.453152027\right), t\_3, 1.421413741\right), t\_3, -0.284496736\right), t\_3, 0.254829592\right)\\
t_5 := {t\_0}^{-1}\\
t_6 := {\left({\left({\left(e^{-1}\right)}^{x}\right)}^{x} \cdot \left(\mathsf{fma}\left(t\_5, \mathsf{fma}\left(t\_5, \mathsf{fma}\left(t\_5, \mathsf{fma}\left(t\_5 \cdot 1.061405429, 1, -1.453152027\right), 1.421413741\right), -0.284496736\right), 0.254829592\right) \cdot \frac{-1}{t\_0}\right)\right)}^{3}\\
\frac{\frac{1 + {t\_6}^{3}}{1 + \left(t\_6 \cdot t\_6 - t\_6\right)}}{1 + \left(\left(\left(\left(t\_1 \cdot t\_3\right) \cdot t\_4\right) \cdot \left(t\_4 \cdot t\_3\right)\right) \cdot t\_1 - \left(\left(-1 \cdot \frac{-1}{t\_2}\right) \cdot \left(-1 \cdot t\_4\right)\right) \cdot t\_1\right)}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites79.0%
Applied rewrites79.1%
Final simplification79.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (fabs x) 0.3275911 1.0))
(t_1 (pow t_0 -1.0))
(t_2 (pow (pow t_0 2.0) -0.5))
(t_3 (* -1.0 (pow (pow (exp -1.0) x) x)))
(t_4
(*
t_3
(*
t_1
(fma
t_1
-0.284496736
(fma
(* t_2 t_2)
(fma t_1 (fma (* t_1 1.061405429) 1.0 -1.453152027) 1.421413741)
0.254829592)))))
(t_5 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_6 (pow t_5 -0.5))
(t_7 (* t_6 t_6)))
(/
(-
1.0
(*
t_4
(*
t_3
(*
t_1
(+
(fma
-0.284496736
t_7
(*
t_7
(*
(fma (fma (/ 1.061405429 t_5) 1.0 -1.453152027) t_7 1.421413741)
t_7)))
0.254829592)))))
(- 1.0 t_4))))
double code(double x) {
double t_0 = fma(fabs(x), 0.3275911, 1.0);
double t_1 = pow(t_0, -1.0);
double t_2 = pow(pow(t_0, 2.0), -0.5);
double t_3 = -1.0 * pow(pow(exp(-1.0), x), x);
double t_4 = t_3 * (t_1 * fma(t_1, -0.284496736, fma((t_2 * t_2), fma(t_1, fma((t_1 * 1.061405429), 1.0, -1.453152027), 1.421413741), 0.254829592)));
double t_5 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_6 = pow(t_5, -0.5);
double t_7 = t_6 * t_6;
return (1.0 - (t_4 * (t_3 * (t_1 * (fma(-0.284496736, t_7, (t_7 * (fma(fma((1.061405429 / t_5), 1.0, -1.453152027), t_7, 1.421413741) * t_7))) + 0.254829592))))) / (1.0 - t_4);
}
function code(x) t_0 = fma(abs(x), 0.3275911, 1.0) t_1 = t_0 ^ -1.0 t_2 = (t_0 ^ 2.0) ^ -0.5 t_3 = Float64(-1.0 * ((exp(-1.0) ^ x) ^ x)) t_4 = Float64(t_3 * Float64(t_1 * fma(t_1, -0.284496736, fma(Float64(t_2 * t_2), fma(t_1, fma(Float64(t_1 * 1.061405429), 1.0, -1.453152027), 1.421413741), 0.254829592)))) t_5 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_6 = t_5 ^ -0.5 t_7 = Float64(t_6 * t_6) return Float64(Float64(1.0 - Float64(t_4 * Float64(t_3 * Float64(t_1 * Float64(fma(-0.284496736, t_7, Float64(t_7 * Float64(fma(fma(Float64(1.061405429 / t_5), 1.0, -1.453152027), t_7, 1.421413741) * t_7))) + 0.254829592))))) / Float64(1.0 - t_4)) end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * 0.3275911 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], -0.5], $MachinePrecision]}, Block[{t$95$3 = N[(-1.0 * N[Power[N[Power[N[Exp[-1.0], $MachinePrecision], x], $MachinePrecision], x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$1 * N[(t$95$1 * -0.284496736 + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(t$95$1 * N[(N[(t$95$1 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] + 1.421413741), $MachinePrecision] + 0.254829592), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$6 = N[Power[t$95$5, -0.5], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$6 * t$95$6), $MachinePrecision]}, N[(N[(1.0 - N[(t$95$4 * N[(t$95$3 * N[(t$95$1 * N[(N[(-0.284496736 * t$95$7 + N[(t$95$7 * N[(N[(N[(N[(1.061405429 / t$95$5), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$7 + 1.421413741), $MachinePrecision] * t$95$7), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.254829592), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - t$95$4), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right|, 0.3275911, 1\right)\\
t_1 := {t\_0}^{-1}\\
t_2 := {\left({t\_0}^{2}\right)}^{-0.5}\\
t_3 := -1 \cdot {\left({\left(e^{-1}\right)}^{x}\right)}^{x}\\
t_4 := t\_3 \cdot \left(t\_1 \cdot \mathsf{fma}\left(t\_1, -0.284496736, \mathsf{fma}\left(t\_2 \cdot t\_2, \mathsf{fma}\left(t\_1, \mathsf{fma}\left(t\_1 \cdot 1.061405429, 1, -1.453152027\right), 1.421413741\right), 0.254829592\right)\right)\right)\\
t_5 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_6 := {t\_5}^{-0.5}\\
t_7 := t\_6 \cdot t\_6\\
\frac{1 - t\_4 \cdot \left(t\_3 \cdot \left(t\_1 \cdot \left(\mathsf{fma}\left(-0.284496736, t\_7, t\_7 \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{1.061405429}{t\_5}, 1, -1.453152027\right), t\_7, 1.421413741\right) \cdot t\_7\right)\right) + 0.254829592\right)\right)\right)}{1 - t\_4}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites77.8%
Applied rewrites77.8%
Applied rewrites79.0%
Final simplification79.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_1 (pow (exp -1.0) (* x x)))
(t_2 (pow t_0 -1.0))
(t_3
(fma
(fma
(fma (fma (* t_2 1.061405429) 1.0 -1.453152027) t_2 1.421413741)
t_2
-0.284496736)
t_2
0.254829592))
(t_4 (* (* (* -1.0 (/ -1.0 t_0)) (* -1.0 t_3)) t_1)))
(/
(+ 1.0 (pow t_4 3.0))
(+ 1.0 (- (* (* (* (* t_1 t_2) t_3) (* t_3 t_2)) t_1) t_4)))))
double code(double x) {
double t_0 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_1 = pow(exp(-1.0), (x * x));
double t_2 = pow(t_0, -1.0);
double t_3 = fma(fma(fma(fma((t_2 * 1.061405429), 1.0, -1.453152027), t_2, 1.421413741), t_2, -0.284496736), t_2, 0.254829592);
double t_4 = ((-1.0 * (-1.0 / t_0)) * (-1.0 * t_3)) * t_1;
return (1.0 + pow(t_4, 3.0)) / (1.0 + (((((t_1 * t_2) * t_3) * (t_3 * t_2)) * t_1) - t_4));
}
function code(x) t_0 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_1 = exp(-1.0) ^ Float64(x * x) t_2 = t_0 ^ -1.0 t_3 = fma(fma(fma(fma(Float64(t_2 * 1.061405429), 1.0, -1.453152027), t_2, 1.421413741), t_2, -0.284496736), t_2, 0.254829592) t_4 = Float64(Float64(Float64(-1.0 * Float64(-1.0 / t_0)) * Float64(-1.0 * t_3)) * t_1) return Float64(Float64(1.0 + (t_4 ^ 3.0)) / Float64(1.0 + Float64(Float64(Float64(Float64(Float64(t_1 * t_2) * t_3) * Float64(t_3 * t_2)) * t_1) - t_4))) end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[-1.0], $MachinePrecision], N[(x * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(t$95$2 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$2 + 1.421413741), $MachinePrecision] * t$95$2 + -0.284496736), $MachinePrecision] * t$95$2 + 0.254829592), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(-1.0 * N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * t$95$3), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, N[(N[(1.0 + N[Power[t$95$4, 3.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(N[(N[(N[(t$95$1 * t$95$2), $MachinePrecision] * t$95$3), $MachinePrecision] * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_1 := {\left(e^{-1}\right)}^{\left(x \cdot x\right)}\\
t_2 := {t\_0}^{-1}\\
t_3 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(t\_2 \cdot 1.061405429, 1, -1.453152027\right), t\_2, 1.421413741\right), t\_2, -0.284496736\right), t\_2, 0.254829592\right)\\
t_4 := \left(\left(-1 \cdot \frac{-1}{t\_0}\right) \cdot \left(-1 \cdot t\_3\right)\right) \cdot t\_1\\
\frac{1 + {t\_4}^{3}}{1 + \left(\left(\left(\left(t\_1 \cdot t\_2\right) \cdot t\_3\right) \cdot \left(t\_3 \cdot t\_2\right)\right) \cdot t\_1 - t\_4\right)}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites79.0%
Final simplification79.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (fma (* (fabs x) 0.3275911) 1.0 1.0))
(t_1 (* -1.0 (pow (pow t_0 2.0) -1.0)))
(t_2 (pow t_0 -1.0))
(t_3
(fma
(fma (fma (* t_2 1.061405429) 1.0 -1.453152027) t_2 1.421413741)
t_2
-0.284496736))
(t_4 (* t_1 t_3))
(t_5 (* t_2 0.254829592)))
(-
1.0
(*
(/ (- (* t_5 t_5) (* t_4 t_4)) (- t_5 (* t_1 (* -1.0 t_3))))
(exp (* -1.0 (* x x)))))))
double code(double x) {
double t_0 = fma((fabs(x) * 0.3275911), 1.0, 1.0);
double t_1 = -1.0 * pow(pow(t_0, 2.0), -1.0);
double t_2 = pow(t_0, -1.0);
double t_3 = fma(fma(fma((t_2 * 1.061405429), 1.0, -1.453152027), t_2, 1.421413741), t_2, -0.284496736);
double t_4 = t_1 * t_3;
double t_5 = t_2 * 0.254829592;
return 1.0 - ((((t_5 * t_5) - (t_4 * t_4)) / (t_5 - (t_1 * (-1.0 * t_3)))) * exp((-1.0 * (x * x))));
}
function code(x) t_0 = fma(Float64(abs(x) * 0.3275911), 1.0, 1.0) t_1 = Float64(-1.0 * ((t_0 ^ 2.0) ^ -1.0)) t_2 = t_0 ^ -1.0 t_3 = fma(fma(fma(Float64(t_2 * 1.061405429), 1.0, -1.453152027), t_2, 1.421413741), t_2, -0.284496736) t_4 = Float64(t_1 * t_3) t_5 = Float64(t_2 * 0.254829592) return Float64(1.0 - Float64(Float64(Float64(Float64(t_5 * t_5) - Float64(t_4 * t_4)) / Float64(t_5 - Float64(t_1 * Float64(-1.0 * t_3)))) * exp(Float64(-1.0 * Float64(x * x))))) end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * 0.3275911), $MachinePrecision] * 1.0 + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(-1.0 * N[Power[N[Power[t$95$0, 2.0], $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$0, -1.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(t$95$2 * 1.061405429), $MachinePrecision] * 1.0 + -1.453152027), $MachinePrecision] * t$95$2 + 1.421413741), $MachinePrecision] * t$95$2 + -0.284496736), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 * 0.254829592), $MachinePrecision]}, N[(1.0 - N[(N[(N[(N[(t$95$5 * t$95$5), $MachinePrecision] - N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision] / N[(t$95$5 - N[(t$95$1 * N[(-1.0 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(-1.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left|x\right| \cdot 0.3275911, 1, 1\right)\\
t_1 := -1 \cdot {\left({t\_0}^{2}\right)}^{-1}\\
t_2 := {t\_0}^{-1}\\
t_3 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(t\_2 \cdot 1.061405429, 1, -1.453152027\right), t\_2, 1.421413741\right), t\_2, -0.284496736\right)\\
t_4 := t\_1 \cdot t\_3\\
t_5 := t\_2 \cdot 0.254829592\\
1 - \frac{t\_5 \cdot t\_5 - t\_4 \cdot t\_4}{t\_5 - t\_1 \cdot \left(-1 \cdot t\_3\right)} \cdot e^{-1 \cdot \left(x \cdot x\right)}
\end{array}
\end{array}
Initial program 78.9%
Applied rewrites79.0%
Final simplification79.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 1.0 (+ 1.0 (* 0.3275911 (fabs x))))))
(-
1.0
(*
(*
(* -1.0 t_0)
(+
0.254829592
(*
t_0
(+
-0.284496736
(*
t_0
(+ 1.421413741 (* t_0 (+ -1.453152027 (* t_0 1.061405429)))))))))
(* -1.0 (exp (* -1.0 (* x x))))))))
double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * fabs(x)));
return 1.0 - (((-1.0 * t_0) * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * (-1.0 * exp((-1.0 * (x * x)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 1.0d0 / (1.0d0 + (0.3275911d0 * abs(x)))
code = 1.0d0 - ((((-1.0d0) * t_0) * (0.254829592d0 + (t_0 * ((-0.284496736d0) + (t_0 * (1.421413741d0 + (t_0 * ((-1.453152027d0) + (t_0 * 1.061405429d0))))))))) * ((-1.0d0) * exp(((-1.0d0) * (x * x)))))
end function
public static double code(double x) {
double t_0 = 1.0 / (1.0 + (0.3275911 * Math.abs(x)));
return 1.0 - (((-1.0 * t_0) * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * (-1.0 * Math.exp((-1.0 * (x * x)))));
}
def code(x): t_0 = 1.0 / (1.0 + (0.3275911 * math.fabs(x))) return 1.0 - (((-1.0 * t_0) * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * (-1.0 * math.exp((-1.0 * (x * x)))))
function code(x) t_0 = Float64(1.0 / Float64(1.0 + Float64(0.3275911 * abs(x)))) return Float64(1.0 - Float64(Float64(Float64(-1.0 * 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))))))))) * Float64(-1.0 * exp(Float64(-1.0 * Float64(x * x)))))) end
function tmp = code(x) t_0 = 1.0 / (1.0 + (0.3275911 * abs(x))); tmp = 1.0 - (((-1.0 * t_0) * (0.254829592 + (t_0 * (-0.284496736 + (t_0 * (1.421413741 + (t_0 * (-1.453152027 + (t_0 * 1.061405429))))))))) * (-1.0 * exp((-1.0 * (x * 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[(N[(-1.0 * t$95$0), $MachinePrecision] * 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[(-1.0 * N[Exp[N[(-1.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{1 + 0.3275911 \cdot \left|x\right|}\\
1 - \left(\left(-1 \cdot t\_0\right) \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 \left(-1 \cdot e^{-1 \cdot \left(x \cdot x\right)}\right)
\end{array}
\end{array}
Initial program 78.9%
Final simplification78.9%
herbie shell --seed 2025064
(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)))))))