Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5

Percentage Accurate: 60.6% → 98.4%
Time: 20.0s
Alternatives: 7
Speedup: 8.9×

Specification

?
\[\left(\left(\left(\left(0.0001 \leq alphax \land alphax \leq 1\right) \land \left(0.0001 \leq alphay \land alphay \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u0 \land u0 \leq 1\right)\right) \land \left(0 \leq cos2phi \land cos2phi \leq 1\right)\right) \land 0 \leq sin2phi\]
\[\begin{array}{l} \\ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (- (log (- 1.0 u0)))
  (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return -logf((1.0f - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4), intent (in) :: u0
    real(4), intent (in) :: cos2phi
    real(4), intent (in) :: sin2phi
    code = -log((1.0e0 - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(-log(Float32(Float32(1.0) - u0))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay))))
end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = -log((single(1.0) - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
end
\begin{array}{l}

\\
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\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 7 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: 60.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (- (log (- 1.0 u0)))
  (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return -logf((1.0f - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
}
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4), intent (in) :: u0
    real(4), intent (in) :: cos2phi
    real(4), intent (in) :: sin2phi
    code = -log((1.0e0 - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(-log(Float32(Float32(1.0) - u0))) / Float32(Float32(cos2phi / Float32(alphax * alphax)) + Float32(sin2phi / Float32(alphay * alphay))))
end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = -log((single(1.0) - u0)) / ((cos2phi / (alphax * alphax)) + (sin2phi / (alphay * alphay)));
end
\begin{array}{l}

\\
\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}
\end{array}

Alternative 1: 98.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, {alphax}^{-2}, sin2phi \cdot {alphay}^{-2}\right)} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (- (log1p (- u0)))
  (fma cos2phi (pow alphax -2.0) (* sin2phi (pow alphay -2.0)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return -log1pf(-u0) / fmaf(cos2phi, powf(alphax, -2.0f), (sin2phi * powf(alphay, -2.0f)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(-log1p(Float32(-u0))) / fma(cos2phi, (alphax ^ Float32(-2.0)), Float32(sin2phi * (alphay ^ Float32(-2.0)))))
end
\begin{array}{l}

\\
\frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, {alphax}^{-2}, sin2phi \cdot {alphay}^{-2}\right)}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Step-by-step derivation
    1. distribute-frac-neg58.0%

      \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    2. distribute-neg-frac258.0%

      \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    3. sub-neg58.0%

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    4. log1p-define98.4%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-u0\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    5. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{0 - \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    6. associate--r+98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(0 - \frac{cos2phi}{alphax \cdot alphax}\right) - \frac{sin2phi}{alphay \cdot alphay}}} \]
    7. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{cos2phi}{alphax \cdot alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. associate-/r*98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    9. distribute-neg-frac298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{-alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}} \]
  4. Add Preprocessing
  5. Applied egg-rr97.0%

    \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}\right)}^{2} \cdot \left(-\sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}\right)}} \]
  6. Step-by-step derivation
    1. distribute-rgt-neg-out97.0%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{-{\left(\sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}\right)}^{2} \cdot \sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}}} \]
    2. unpow297.0%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{-\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}\right)} \cdot \sqrt[3]{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}} \]
    3. rem-3cbrt-lft98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{-\color{blue}{\mathsf{fma}\left(sin2phi, {alphay}^{-2}, cos2phi \cdot {alphax}^{-2}\right)}} \]
    4. fma-define98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{-\color{blue}{\left(sin2phi \cdot {alphay}^{-2} + cos2phi \cdot {alphax}^{-2}\right)}} \]
    5. +-commutative98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{-\color{blue}{\left(cos2phi \cdot {alphax}^{-2} + sin2phi \cdot {alphay}^{-2}\right)}} \]
    6. fma-define98.5%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{-\color{blue}{\mathsf{fma}\left(cos2phi, {alphax}^{-2}, sin2phi \cdot {alphay}^{-2}\right)}} \]
  7. Simplified98.5%

    \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{-\mathsf{fma}\left(cos2phi, {alphax}^{-2}, sin2phi \cdot {alphay}^{-2}\right)}} \]
  8. Final simplification98.5%

    \[\leadsto \frac{-\mathsf{log1p}\left(-u0\right)}{\mathsf{fma}\left(cos2phi, {alphax}^{-2}, sin2phi \cdot {alphay}^{-2}\right)} \]
  9. Add Preprocessing

Alternative 2: 98.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + cos2phi \cdot {alphax}^{-2}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (- (log1p (- u0)))
  (+ (/ sin2phi (* alphay alphay)) (* cos2phi (pow alphax -2.0)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return -log1pf(-u0) / ((sin2phi / (alphay * alphay)) + (cos2phi * powf(alphax, -2.0f)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(-log1p(Float32(-u0))) / Float32(Float32(sin2phi / Float32(alphay * alphay)) + Float32(cos2phi * (alphax ^ Float32(-2.0)))))
end
\begin{array}{l}

\\
\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + cos2phi \cdot {alphax}^{-2}}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Step-by-step derivation
    1. distribute-frac-neg58.0%

      \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    2. distribute-neg-frac258.0%

      \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    3. sub-neg58.0%

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    4. log1p-define98.4%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-u0\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    5. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{0 - \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    6. associate--r+98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(0 - \frac{cos2phi}{alphax \cdot alphax}\right) - \frac{sin2phi}{alphay \cdot alphay}}} \]
    7. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{cos2phi}{alphax \cdot alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. associate-/r*98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    9. distribute-neg-frac298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{-alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. distribute-frac-neg298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{\frac{cos2phi}{alphax}}{alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
    2. associate-/r*98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{cos2phi}{alphax \cdot alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    3. div-inv98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{cos2phi \cdot \frac{1}{alphax \cdot alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    4. distribute-lft-neg-in98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-cos2phi\right) \cdot \frac{1}{alphax \cdot alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    5. pow298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot \frac{1}{\color{blue}{{alphax}^{2}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    6. pow-flip98.5%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot \color{blue}{{alphax}^{\left(-2\right)}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    7. metadata-eval98.5%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot {alphax}^{\color{blue}{-2}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  6. Applied egg-rr98.5%

    \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-cos2phi\right) \cdot {alphax}^{-2}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  7. Final simplification98.5%

    \[\leadsto \frac{-\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot alphay} + cos2phi \cdot {alphax}^{-2}} \]
  8. Add Preprocessing

Alternative 3: 86.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t\_0 \leq 400:\\ \;\;\;\;\frac{u0}{\frac{alphax \cdot \frac{sin2phi}{alphay} + alphay \cdot \frac{cos2phi}{alphax}}{alphax \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{alphax} - t\_0}\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (let* ((t_0 (/ sin2phi (* alphay alphay))))
   (if (<= t_0 400.0)
     (/
      u0
      (/
       (+ (* alphax (/ sin2phi alphay)) (* alphay (/ cos2phi alphax)))
       (* alphax alphay)))
     (/ (log1p (- u0)) (- (/ (/ cos2phi alphax) alphax) t_0)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float t_0 = sin2phi / (alphay * alphay);
	float tmp;
	if (t_0 <= 400.0f) {
		tmp = u0 / (((alphax * (sin2phi / alphay)) + (alphay * (cos2phi / alphax))) / (alphax * alphay));
	} else {
		tmp = log1pf(-u0) / (((cos2phi / alphax) / alphax) - t_0);
	}
	return tmp;
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	t_0 = Float32(sin2phi / Float32(alphay * alphay))
	tmp = Float32(0.0)
	if (t_0 <= Float32(400.0))
		tmp = Float32(u0 / Float32(Float32(Float32(alphax * Float32(sin2phi / alphay)) + Float32(alphay * Float32(cos2phi / alphax))) / Float32(alphax * alphay)));
	else
		tmp = Float32(log1p(Float32(-u0)) / Float32(Float32(Float32(cos2phi / alphax) / alphax) - t_0));
	end
	return tmp
end
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{sin2phi}{alphay \cdot alphay}\\
\mathbf{if}\;t\_0 \leq 400:\\
\;\;\;\;\frac{u0}{\frac{alphax \cdot \frac{sin2phi}{alphay} + alphay \cdot \frac{cos2phi}{alphax}}{alphax \cdot alphay}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{alphax} - t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f32 sin2phi (*.f32 alphay alphay)) < 400

    1. Initial program 51.1%

      \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    2. Add Preprocessing
    3. Taylor expanded in u0 around 0 78.0%

      \[\leadsto \frac{-\color{blue}{-1 \cdot u0}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    4. Step-by-step derivation
      1. mul-1-neg78.0%

        \[\leadsto \frac{-\color{blue}{\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    5. Simplified78.0%

      \[\leadsto \frac{-\color{blue}{\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    6. Step-by-step derivation
      1. associate-/r*78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{\frac{sin2phi}{alphay}}{alphay}}} \]
      2. div-inv78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{sin2phi}{alphay} \cdot \frac{1}{alphay}}} \]
    7. Applied egg-rr78.0%

      \[\leadsto \frac{-\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{sin2phi}{alphay} \cdot \frac{1}{alphay}}} \]
    8. Step-by-step derivation
      1. un-div-inv78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{\frac{sin2phi}{alphay}}{alphay}}} \]
      2. associate-/r*78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \color{blue}{\frac{sin2phi}{alphay \cdot alphay}}} \]
      3. +-commutative78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\color{blue}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}}} \]
      4. associate-/r*78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\color{blue}{\frac{\frac{sin2phi}{alphay}}{alphay}} + \frac{cos2phi}{alphax \cdot alphax}} \]
      5. associate-/r*78.0%

        \[\leadsto \frac{-\left(-u0\right)}{\frac{\frac{sin2phi}{alphay}}{alphay} + \color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}} \]
      6. frac-add78.1%

        \[\leadsto \frac{-\left(-u0\right)}{\color{blue}{\frac{\frac{sin2phi}{alphay} \cdot alphax + alphay \cdot \frac{cos2phi}{alphax}}{alphay \cdot alphax}}} \]
    9. Applied egg-rr78.1%

      \[\leadsto \frac{-\left(-u0\right)}{\color{blue}{\frac{\frac{sin2phi}{alphay} \cdot alphax + alphay \cdot \frac{cos2phi}{alphax}}{alphay \cdot alphax}}} \]

    if 400 < (/.f32 sin2phi (*.f32 alphay alphay))

    1. Initial program 63.7%

      \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    2. Step-by-step derivation
      1. distribute-frac-neg63.7%

        \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
      2. distribute-neg-frac263.7%

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg63.7%

        \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
      4. log1p-define98.1%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-u0\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
      5. neg-sub098.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{0 - \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      6. associate--r+98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(0 - \frac{cos2phi}{alphax \cdot alphax}\right) - \frac{sin2phi}{alphay \cdot alphay}}} \]
      7. neg-sub098.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{cos2phi}{alphax \cdot alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
      8. associate-/r*98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
      9. distribute-neg-frac298.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{-alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    3. Simplified98.1%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. distribute-frac-neg298.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{\frac{cos2phi}{alphax}}{alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
      2. associate-/r*98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{cos2phi}{alphax \cdot alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
      3. div-inv98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{cos2phi \cdot \frac{1}{alphax \cdot alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
      4. distribute-lft-neg-in98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-cos2phi\right) \cdot \frac{1}{alphax \cdot alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      5. pow298.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot \frac{1}{\color{blue}{{alphax}^{2}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      6. pow-flip98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot \color{blue}{{alphax}^{\left(-2\right)}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      7. metadata-eval98.1%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-cos2phi\right) \cdot {alphax}^{\color{blue}{-2}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    6. Applied egg-rr98.1%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-cos2phi\right) \cdot {alphax}^{-2}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt-0.0%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(\sqrt{-cos2phi} \cdot \sqrt{-cos2phi}\right)} \cdot {alphax}^{-2} - \frac{sin2phi}{alphay \cdot alphay}} \]
      2. sqrt-unprod97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\sqrt{\left(-cos2phi\right) \cdot \left(-cos2phi\right)}} \cdot {alphax}^{-2} - \frac{sin2phi}{alphay \cdot alphay}} \]
      3. sqr-neg97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\sqrt{\color{blue}{cos2phi \cdot cos2phi}} \cdot {alphax}^{-2} - \frac{sin2phi}{alphay \cdot alphay}} \]
      4. sqrt-unprod97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(\sqrt{cos2phi} \cdot \sqrt{cos2phi}\right)} \cdot {alphax}^{-2} - \frac{sin2phi}{alphay \cdot alphay}} \]
      5. add-sqr-sqrt97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{cos2phi} \cdot {alphax}^{-2} - \frac{sin2phi}{alphay \cdot alphay}} \]
      6. metadata-eval97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{cos2phi \cdot {alphax}^{\color{blue}{\left(-2\right)}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      7. pow-flip97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{cos2phi \cdot \color{blue}{\frac{1}{{alphax}^{2}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      8. pow297.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{cos2phi \cdot \frac{1}{\color{blue}{alphax \cdot alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      9. div-inv97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{cos2phi}{alphax \cdot alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      10. associate-/r*97.9%

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. Applied egg-rr97.9%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{sin2phi}{alphay \cdot alphay} \leq 400:\\ \;\;\;\;\frac{u0}{\frac{alphax \cdot \frac{sin2phi}{alphay} + alphay \cdot \frac{cos2phi}{alphax}}{alphax \cdot alphay}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{alphax} - \frac{sin2phi}{alphay \cdot alphay}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{\frac{cos2phi}{alphax}}{alphax}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (log1p (- u0))
  (- (/ sin2phi (* alphay (- alphay))) (/ (/ cos2phi alphax) alphax))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return log1pf(-u0) / ((sin2phi / (alphay * -alphay)) - ((cos2phi / alphax) / alphax));
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(log1p(Float32(-u0)) / Float32(Float32(sin2phi / Float32(alphay * Float32(-alphay))) - Float32(Float32(cos2phi / alphax) / alphax)))
end
\begin{array}{l}

\\
\frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{\frac{cos2phi}{alphax}}{alphax}}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Step-by-step derivation
    1. distribute-frac-neg58.0%

      \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    2. distribute-neg-frac258.0%

      \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    3. sub-neg58.0%

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    4. log1p-define98.4%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-u0\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    5. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{0 - \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    6. associate--r+98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(0 - \frac{cos2phi}{alphax \cdot alphax}\right) - \frac{sin2phi}{alphay \cdot alphay}}} \]
    7. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{cos2phi}{alphax \cdot alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. associate-/r*98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    9. distribute-neg-frac298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{-alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}} \]
  4. Add Preprocessing
  5. Final simplification98.4%

    \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{\frac{cos2phi}{alphax}}{alphax}} \]
  6. Add Preprocessing

Alternative 5: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{cos2phi}{alphax \cdot alphax}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/
  (log1p (- u0))
  (- (/ sin2phi (* alphay (- alphay))) (/ cos2phi (* alphax alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return log1pf(-u0) / ((sin2phi / (alphay * -alphay)) - (cos2phi / (alphax * alphax)));
}
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(log1p(Float32(-u0)) / Float32(Float32(sin2phi / Float32(alphay * Float32(-alphay))) - Float32(cos2phi / Float32(alphax * alphax))))
end
\begin{array}{l}

\\
\frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{cos2phi}{alphax \cdot alphax}}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Step-by-step derivation
    1. distribute-frac-neg58.0%

      \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    2. distribute-neg-frac258.0%

      \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    3. neg-mul-158.0%

      \[\leadsto \frac{\log \left(1 - u0\right)}{\color{blue}{-1 \cdot \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    4. associate-/r*58.0%

      \[\leadsto \color{blue}{\frac{\frac{\log \left(1 - u0\right)}{-1}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    5. remove-double-neg58.0%

      \[\leadsto \frac{\frac{\color{blue}{-\left(-\log \left(1 - u0\right)\right)}}{-1}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    6. distribute-frac-neg58.0%

      \[\leadsto \frac{\color{blue}{-\frac{-\log \left(1 - u0\right)}{-1}}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    7. distribute-neg-frac258.0%

      \[\leadsto \frac{\color{blue}{\frac{-\log \left(1 - u0\right)}{--1}}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    8. metadata-eval58.0%

      \[\leadsto \frac{\frac{-\log \left(1 - u0\right)}{\color{blue}{1}}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    9. /-rgt-identity58.0%

      \[\leadsto \frac{\color{blue}{-\log \left(1 - u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    10. sub-neg58.0%

      \[\leadsto \frac{-\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
    11. log1p-define98.4%

      \[\leadsto \frac{-\color{blue}{\mathsf{log1p}\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{-\mathsf{log1p}\left(-u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
  4. Add Preprocessing
  5. Final simplification98.4%

    \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{sin2phi}{alphay \cdot \left(-alphay\right)} - \frac{cos2phi}{alphax \cdot alphax}} \]
  6. Add Preprocessing

Alternative 6: 75.8% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/ u0 (+ (/ sin2phi (* alphay alphay)) (/ cos2phi (* alphax alphax)))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax)));
}
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4), intent (in) :: u0
    real(4), intent (in) :: cos2phi
    real(4), intent (in) :: sin2phi
    code = u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax)))
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(u0 / Float32(Float32(sin2phi / Float32(alphay * alphay)) + Float32(cos2phi / Float32(alphax * alphax))))
end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = u0 / ((sin2phi / (alphay * alphay)) + (cos2phi / (alphax * alphax)));
end
\begin{array}{l}

\\
\frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Add Preprocessing
  3. Taylor expanded in u0 around 0 76.8%

    \[\leadsto \frac{-\color{blue}{-1 \cdot u0}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  4. Step-by-step derivation
    1. mul-1-neg76.8%

      \[\leadsto \frac{-\color{blue}{\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  5. Simplified76.8%

    \[\leadsto \frac{-\color{blue}{\left(-u0\right)}}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  6. Final simplification76.8%

    \[\leadsto \frac{u0}{\frac{sin2phi}{alphay \cdot alphay} + \frac{cos2phi}{alphax \cdot alphax}} \]
  7. Add Preprocessing

Alternative 7: 23.6% accurate, 16.6× speedup?

\[\begin{array}{l} \\ \frac{u0 \cdot \left(alphax \cdot alphax\right)}{cos2phi} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (/ (* u0 (* alphax alphax)) cos2phi))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return (u0 * (alphax * alphax)) / cos2phi;
}
real(4) function code(alphax, alphay, u0, cos2phi, sin2phi)
    real(4), intent (in) :: alphax
    real(4), intent (in) :: alphay
    real(4), intent (in) :: u0
    real(4), intent (in) :: cos2phi
    real(4), intent (in) :: sin2phi
    code = (u0 * (alphax * alphax)) / cos2phi
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32(Float32(u0 * Float32(alphax * alphax)) / cos2phi)
end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = (u0 * (alphax * alphax)) / cos2phi;
end
\begin{array}{l}

\\
\frac{u0 \cdot \left(alphax \cdot alphax\right)}{cos2phi}
\end{array}
Derivation
  1. Initial program 58.0%

    \[\frac{-\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}} \]
  2. Step-by-step derivation
    1. distribute-frac-neg58.0%

      \[\leadsto \color{blue}{-\frac{\log \left(1 - u0\right)}{\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}}} \]
    2. distribute-neg-frac258.0%

      \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    3. sub-neg58.0%

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    4. log1p-define98.4%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-u0\right)}}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)} \]
    5. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{0 - \left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
    6. associate--r+98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(0 - \frac{cos2phi}{alphax \cdot alphax}\right) - \frac{sin2phi}{alphay \cdot alphay}}} \]
    7. neg-sub098.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\left(-\frac{cos2phi}{alphax \cdot alphax}\right)} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. associate-/r*98.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\left(-\color{blue}{\frac{\frac{cos2phi}{alphax}}{alphax}}\right) - \frac{sin2phi}{alphay \cdot alphay}} \]
    9. distribute-neg-frac298.4%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\color{blue}{\frac{\frac{cos2phi}{alphax}}{-alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
  3. Simplified98.4%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{-alphax} - \frac{sin2phi}{alphay \cdot alphay}}} \]
  4. Add Preprocessing
  5. Taylor expanded in cos2phi around inf 18.6%

    \[\leadsto \color{blue}{-1 \cdot \frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
  6. Step-by-step derivation
    1. mul-1-neg18.6%

      \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
    2. distribute-neg-frac218.6%

      \[\leadsto \color{blue}{\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{-cos2phi}} \]
    3. sub-neg18.6%

      \[\leadsto \frac{{alphax}^{2} \cdot \log \color{blue}{\left(1 + \left(-u0\right)\right)}}{-cos2phi} \]
    4. mul-1-neg18.6%

      \[\leadsto \frac{{alphax}^{2} \cdot \log \left(1 + \color{blue}{-1 \cdot u0}\right)}{-cos2phi} \]
    5. log1p-define23.9%

      \[\leadsto \frac{{alphax}^{2} \cdot \color{blue}{\mathsf{log1p}\left(-1 \cdot u0\right)}}{-cos2phi} \]
    6. mul-1-neg23.9%

      \[\leadsto \frac{{alphax}^{2} \cdot \mathsf{log1p}\left(\color{blue}{-u0}\right)}{-cos2phi} \]
  7. Simplified23.9%

    \[\leadsto \color{blue}{\frac{{alphax}^{2} \cdot \mathsf{log1p}\left(-u0\right)}{-cos2phi}} \]
  8. Step-by-step derivation
    1. pow223.9%

      \[\leadsto \frac{\color{blue}{\left(alphax \cdot alphax\right)} \cdot \mathsf{log1p}\left(-u0\right)}{-cos2phi} \]
  9. Applied egg-rr23.9%

    \[\leadsto \frac{\color{blue}{\left(alphax \cdot alphax\right)} \cdot \mathsf{log1p}\left(-u0\right)}{-cos2phi} \]
  10. Taylor expanded in u0 around 0 21.0%

    \[\leadsto \frac{\left(alphax \cdot alphax\right) \cdot \color{blue}{\left(-1 \cdot u0\right)}}{-cos2phi} \]
  11. Step-by-step derivation
    1. mul-1-neg21.0%

      \[\leadsto \frac{\left(alphax \cdot alphax\right) \cdot \color{blue}{\left(-u0\right)}}{-cos2phi} \]
  12. Simplified21.0%

    \[\leadsto \frac{\left(alphax \cdot alphax\right) \cdot \color{blue}{\left(-u0\right)}}{-cos2phi} \]
  13. Final simplification21.0%

    \[\leadsto \frac{u0 \cdot \left(alphax \cdot alphax\right)}{cos2phi} \]
  14. Add Preprocessing

Reproduce

?
herbie shell --seed 2024050 
(FPCore (alphax alphay u0 cos2phi sin2phi)
  :name "Beckmann Distribution sample, tan2theta, alphax != alphay, u1 <= 0.5"
  :precision binary32
  :pre (and (and (and (and (and (<= 0.0001 alphax) (<= alphax 1.0)) (and (<= 0.0001 alphay) (<= alphay 1.0))) (and (<= 2.328306437e-10 u0) (<= u0 1.0))) (and (<= 0.0 cos2phi) (<= cos2phi 1.0))) (<= 0.0 sin2phi))
  (/ (- (log (- 1.0 u0))) (+ (/ cos2phi (* alphax alphax)) (/ sin2phi (* alphay alphay)))))