GTR1 distribution

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

Specification

?
\[\left(0 \leq cosTheta \land cosTheta \leq 1\right) \land \left(0.0001 \leq \alpha \land \alpha \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha - 1\\ \frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (- (* alpha alpha) 1.0)))
   (/
    t_0
    (* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}

Sampling outcomes in binary32 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 := \alpha \cdot \alpha - 1\\ \frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (- (* alpha alpha) 1.0)))
   (/
    t_0
    (* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha - 1\\ \frac{t\_0}{\left(\left(cosTheta \cdot t\_0\right) \cdot cosTheta + 1\right) \cdot \left(\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (- (* alpha alpha) 1.0)))
   (/
    t_0
    (* (+ (* (* cosTheta t_0) cosTheta) 1.0) (* (log (* alpha alpha)) (PI))))))
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\left(cosTheta \cdot t\_0\right) \cdot cosTheta + 1\right) \cdot \left(\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Final simplification98.4%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\left(\left(cosTheta \cdot \left(\alpha \cdot \alpha - 1\right)\right) \cdot cosTheta + 1\right) \cdot \left(\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)\right)} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024346 
(FPCore (cosTheta alpha)
  :name "GTR1 distribution"
  :precision binary32
  :pre (and (and (<= 0.0 cosTheta) (<= cosTheta 1.0)) (and (<= 0.0001 alpha) (<= alpha 1.0)))
  (/ (- (* alpha alpha) 1.0) (* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* (- (* alpha alpha) 1.0) cosTheta) cosTheta)))))