Jmat.Real.erfi, branch x greater than or equal to 5

Percentage Accurate: 100.0% → 100.0%
Time: 5.7s
Alternatives: 1
Speedup: 1.0×

Specification

?
\[x \geq 0.5\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\ t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\ \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ 1.0 (fabs x)))
        (t_1 (* (* t_0 t_0) t_0))
        (t_2 (* (* t_1 t_0) t_0)))
   (*
    (* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x))))
    (+
     (+ (+ t_0 (* (/ 1.0 2.0) t_1)) (* (/ 3.0 4.0) t_2))
     (* (/ 15.0 8.0) (* (* t_2 t_0) t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right)
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 1 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\ t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\ \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ 1.0 (fabs x)))
        (t_1 (* (* t_0 t_0) t_0))
        (t_2 (* (* t_1 t_0) t_0)))
   (*
    (* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x))))
    (+
     (+ (+ t_0 (* (/ 1.0 2.0) t_1)) (* (/ 3.0 4.0) t_2))
     (* (/ 15.0 8.0) (* (* t_2 t_0) t_0))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(t\_0 + \frac{1}{2} \cdot t\_1\right) + \frac{3}{4} \cdot t\_2\right) + \frac{15}{8} \cdot \left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right)\right)
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{\left|x\right|}\\ t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\ t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\ \left(\left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8} + \left(t\_2 \cdot \frac{3}{4} + \left(t\_1 \cdot \frac{1}{2} + t\_0\right)\right)\right) \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right) \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ 1.0 (fabs x)))
        (t_1 (* (* t_0 t_0) t_0))
        (t_2 (* (* t_1 t_0) t_0)))
   (*
    (+
     (* (* (* t_2 t_0) t_0) (/ 15.0 8.0))
     (+ (* t_2 (/ 3.0 4.0)) (+ (* t_1 (/ 1.0 2.0)) t_0)))
    (* (exp (* (fabs x) (fabs x))) (/ 1.0 (sqrt (PI)))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{\left|x\right|}\\
t_1 := \left(t\_0 \cdot t\_0\right) \cdot t\_0\\
t_2 := \left(t\_1 \cdot t\_0\right) \cdot t\_0\\
\left(\left(\left(t\_2 \cdot t\_0\right) \cdot t\_0\right) \cdot \frac{15}{8} + \left(t\_2 \cdot \frac{3}{4} + \left(t\_1 \cdot \frac{1}{2} + t\_0\right)\right)\right) \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right)
\end{array}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)}} \cdot e^{\left|x\right| \cdot \left|x\right|}\right) \cdot \left(\left(\left(\frac{1}{\left|x\right|} + \frac{1}{2} \cdot \left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right)\right) + \frac{3}{4} \cdot \left(\left(\left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right)\right) + \frac{15}{8} \cdot \left(\left(\left(\left(\left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right)\right) \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \left(\left(\left(\left(\left(\left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{15}{8} + \left(\left(\left(\left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{3}{4} + \left(\left(\left(\frac{1}{\left|x\right|} \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{\left|x\right|}\right) \cdot \frac{1}{2} + \frac{1}{\left|x\right|}\right)\right)\right) \cdot \left(e^{\left|x\right| \cdot \left|x\right|} \cdot \frac{1}{\sqrt{\mathsf{PI}\left(\right)}}\right) \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024345 
(FPCore (x)
  :name "Jmat.Real.erfi, branch x greater than or equal to 5"
  :precision binary64
  :pre (>= x 0.5)
  (* (* (/ 1.0 (sqrt (PI))) (exp (* (fabs x) (fabs x)))) (+ (+ (+ (/ 1.0 (fabs x)) (* (/ 1.0 2.0) (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))))) (* (/ 3.0 4.0) (* (* (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))))) (* (/ 15.0 8.0) (* (* (* (* (* (* (/ 1.0 (fabs x)) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x))) (/ 1.0 (fabs x)))))))