Beckmann Distribution sample, tan2theta, alphax == alphay

?

Percentage Accurate: 55.7% → 99.0%
Time: 6.6s
Precision: binary32
Cost: 3424

?

\[\left(0.0001 \leq \alpha \land \alpha \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\]
\[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
\[\begin{array}{l} \\ \alpha \cdot \left(\alpha \cdot \left(-\mathsf{log1p}\left(-u0\right)\right)\right) \end{array} \]
(FPCore (alpha u0)
 :precision binary32
 (* (* (- alpha) alpha) (log (- 1.0 u0))))
(FPCore (alpha u0) :precision binary32 (* alpha (* alpha (- (log1p (- u0))))))
float code(float alpha, float u0) {
	return (-alpha * alpha) * logf((1.0f - u0));
}
float code(float alpha, float u0) {
	return alpha * (alpha * -log1pf(-u0));
}
function code(alpha, u0)
	return Float32(Float32(Float32(-alpha) * alpha) * log(Float32(Float32(1.0) - u0)))
end
function code(alpha, u0)
	return Float32(alpha * Float32(alpha * Float32(-log1p(Float32(-u0)))))
end
\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right)
\begin{array}{l}

\\
\alpha \cdot \left(\alpha \cdot \left(-\mathsf{log1p}\left(-u0\right)\right)\right)
\end{array}

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.

Herbie found 6 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 51.5%

    \[\left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]
  2. Simplified99.2%

    \[\leadsto \color{blue}{\left(-\alpha\right) \cdot \left(\alpha \cdot \mathsf{log1p}\left(-u0\right)\right)} \]
    Step-by-step derivation

    [Start]51.5%

    \[ \left(\left(-\alpha\right) \cdot \alpha\right) \cdot \log \left(1 - u0\right) \]

    associate-*l* [=>]51.5%

    \[ \color{blue}{\left(-\alpha\right) \cdot \left(\alpha \cdot \log \left(1 - u0\right)\right)} \]

    sub-neg [=>]51.5%

    \[ \left(-\alpha\right) \cdot \left(\alpha \cdot \log \color{blue}{\left(1 + \left(-u0\right)\right)}\right) \]

    log1p-def [=>]99.2%

    \[ \left(-\alpha\right) \cdot \left(\alpha \cdot \color{blue}{\mathsf{log1p}\left(-u0\right)}\right) \]
  3. Final simplification99.2%

    \[\leadsto \alpha \cdot \left(\alpha \cdot \left(-\mathsf{log1p}\left(-u0\right)\right)\right) \]

Alternatives

Alternative 1
Accuracy99.0%
Cost3424
\[\alpha \cdot \left(\alpha \cdot \left(-\mathsf{log1p}\left(-u0\right)\right)\right) \]
Alternative 2
Accuracy91.7%
Cost480
\[\left(\alpha \cdot \alpha\right) \cdot \left(u0 + \left(u0 \cdot u0\right) \cdot \left(0.5 + u0 \cdot 0.3333333333333333\right)\right) \]
Alternative 3
Accuracy91.6%
Cost480
\[\alpha \cdot \left(\alpha \cdot \left(u0 - \left(u0 \cdot u0\right) \cdot \left(-0.5 + u0 \cdot -0.3333333333333333\right)\right)\right) \]
Alternative 4
Accuracy87.6%
Cost352
\[\left(\alpha \cdot \alpha\right) \cdot \left(u0 + \left(u0 \cdot u0\right) \cdot 0.5\right) \]
Alternative 5
Accuracy87.5%
Cost352
\[\alpha \cdot \left(\alpha \cdot \left(u0 - u0 \cdot \left(u0 \cdot -0.5\right)\right)\right) \]
Alternative 6
Accuracy74.7%
Cost160
\[\alpha \cdot \left(\alpha \cdot u0\right) \]

Reproduce?

herbie shell --seed 2023167 
(FPCore (alpha u0)
  :name "Beckmann Distribution sample, tan2theta, alphax == alphay"
  :precision binary32
  :pre (and (and (<= 0.0001 alpha) (<= alpha 1.0)) (and (<= 2.328306437e-10 u0) (<= u0 1.0)))
  (* (* (- alpha) alpha) (log (- 1.0 u0))))