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

Percentage Accurate: 61.0% → 98.4%
Time: 14.5s
Alternatives: 10
Speedup: 1.0×

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 10 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: 61.0% 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.5× speedup?

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

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

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

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

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

      \[\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.2%

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

      \[\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.2%

      \[\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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{sin2phi}{alphay \cdot alphay}\\ \mathbf{if}\;t\_0 \leq 2.0000000072549875 \cdot 10^{-15}:\\ \;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\ \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 2.0000000072549875e-15)
     (* (pow alphax 2.0) (* u0 (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
     (/ (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 <= 2.0000000072549875e-15f) {
		tmp = powf(alphax, 2.0f) * (u0 * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
	} 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(2.0000000072549875e-15))
		tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi))));
	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 2.0000000072549875 \cdot 10^{-15}:\\
\;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\

\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)) < 2.00000001e-15

    1. Initial program 50.3%

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

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

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

        \[\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.6%

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

        \[\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.6%

        \[\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.6%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
      2. associate-/l*41.7%

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

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

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

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

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

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

      \[\leadsto {alphax}^{2} \cdot \color{blue}{\left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)} \]

    if 2.00000001e-15 < (/.f32 sin2phi (*.f32 alphay alphay))

    1. Initial program 63.2%

      \[\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.2%

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

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

        \[\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. distribute-neg-frac298.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{\frac{cos2phi}{alphax}}{\color{blue}{\sqrt{alphax} \cdot \sqrt{alphax}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
      6. add-sqr-sqrt88.6%

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

      \[\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. Add Preprocessing

Alternative 3: 75.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\ \;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;u0 \cdot \left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (if (<= sin2phi 2.00000006274879e-22)
   (* (pow alphax 2.0) (* u0 (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
   (* u0 (* (pow alphay 2.0) (+ (* 0.5 (/ u0 sin2phi)) (/ 1.0 sin2phi))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float tmp;
	if (sin2phi <= 2.00000006274879e-22f) {
		tmp = powf(alphax, 2.0f) * (u0 * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
	} else {
		tmp = u0 * (powf(alphay, 2.0f) * ((0.5f * (u0 / sin2phi)) + (1.0f / sin2phi)));
	}
	return tmp;
}
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
    real(4) :: tmp
    if (sin2phi <= 2.00000006274879e-22) then
        tmp = (alphax ** 2.0e0) * (u0 * ((0.5e0 * (u0 / cos2phi)) + (1.0e0 / cos2phi)))
    else
        tmp = u0 * ((alphay ** 2.0e0) * ((0.5e0 * (u0 / sin2phi)) + (1.0e0 / sin2phi)))
    end if
    code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = Float32(0.0)
	if (sin2phi <= Float32(2.00000006274879e-22))
		tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi))));
	else
		tmp = Float32(u0 * Float32((alphay ^ Float32(2.0)) * Float32(Float32(Float32(0.5) * Float32(u0 / sin2phi)) + Float32(Float32(1.0) / sin2phi))));
	end
	return tmp
end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = single(0.0);
	if (sin2phi <= single(2.00000006274879e-22))
		tmp = (alphax ^ single(2.0)) * (u0 * ((single(0.5) * (u0 / cos2phi)) + (single(1.0) / cos2phi)));
	else
		tmp = u0 * ((alphay ^ single(2.0)) * ((single(0.5) * (u0 / sin2phi)) + (single(1.0) / sin2phi)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;{alphax}^{2} \cdot \left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;u0 \cdot \left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if sin2phi < 2.00000006e-22

    1. Initial program 51.5%

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

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

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

        \[\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.7%

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

        \[\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.7%

        \[\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.7%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
      2. associate-/l*42.2%

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

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

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

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

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

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

      \[\leadsto {alphax}^{2} \cdot \color{blue}{\left(u0 \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)} \]

    if 2.00000006e-22 < sin2phi

    1. Initial program 62.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-neg62.7%

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

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg62.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.0%

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

        \[\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.0%

        \[\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.0%

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

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

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

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

      \[\leadsto \color{blue}{u0 \cdot \left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} - \frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. sub-neg86.7%

        \[\leadsto u0 \cdot \color{blue}{\left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} + \left(-\frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)\right)} \]
    7. Simplified86.7%

      \[\leadsto \color{blue}{u0 \cdot \left(0.5 \cdot \frac{u0}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}} + \frac{1}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    8. Taylor expanded in alphay around 0 79.5%

      \[\leadsto u0 \cdot \color{blue}{\left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 75.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;u0 \cdot \left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (if (<= sin2phi 2.00000006274879e-22)
   (* u0 (* (pow alphax 2.0) (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
   (* u0 (* (pow alphay 2.0) (+ (* 0.5 (/ u0 sin2phi)) (/ 1.0 sin2phi))))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float tmp;
	if (sin2phi <= 2.00000006274879e-22f) {
		tmp = u0 * (powf(alphax, 2.0f) * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
	} else {
		tmp = u0 * (powf(alphay, 2.0f) * ((0.5f * (u0 / sin2phi)) + (1.0f / sin2phi)));
	}
	return tmp;
}
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
    real(4) :: tmp
    if (sin2phi <= 2.00000006274879e-22) then
        tmp = u0 * ((alphax ** 2.0e0) * ((0.5e0 * (u0 / cos2phi)) + (1.0e0 / cos2phi)))
    else
        tmp = u0 * ((alphay ** 2.0e0) * ((0.5e0 * (u0 / sin2phi)) + (1.0e0 / sin2phi)))
    end if
    code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = Float32(0.0)
	if (sin2phi <= Float32(2.00000006274879e-22))
		tmp = Float32(u0 * Float32((alphax ^ Float32(2.0)) * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi))));
	else
		tmp = Float32(u0 * Float32((alphay ^ Float32(2.0)) * Float32(Float32(Float32(0.5) * Float32(u0 / sin2phi)) + Float32(Float32(1.0) / sin2phi))));
	end
	return tmp
end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = single(0.0);
	if (sin2phi <= single(2.00000006274879e-22))
		tmp = u0 * ((alphax ^ single(2.0)) * ((single(0.5) * (u0 / cos2phi)) + (single(1.0) / cos2phi)));
	else
		tmp = u0 * ((alphay ^ single(2.0)) * ((single(0.5) * (u0 / sin2phi)) + (single(1.0) / sin2phi)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;u0 \cdot \left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;u0 \cdot \left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if sin2phi < 2.00000006e-22

    1. Initial program 51.5%

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

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

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

        \[\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.7%

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

        \[\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.7%

        \[\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.7%

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

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

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

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

      \[\leadsto \color{blue}{u0 \cdot \left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} - \frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. sub-neg87.7%

        \[\leadsto u0 \cdot \color{blue}{\left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} + \left(-\frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)\right)} \]
    7. Simplified87.7%

      \[\leadsto \color{blue}{u0 \cdot \left(0.5 \cdot \frac{u0}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}} + \frac{1}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    8. Taylor expanded in alphax around 0 73.2%

      \[\leadsto u0 \cdot \color{blue}{\left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)} \]

    if 2.00000006e-22 < sin2phi

    1. Initial program 62.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-neg62.7%

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

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg62.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.0%

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

        \[\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.0%

        \[\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.0%

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

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

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

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

      \[\leadsto \color{blue}{u0 \cdot \left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} - \frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. sub-neg86.7%

        \[\leadsto u0 \cdot \color{blue}{\left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} + \left(-\frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)\right)} \]
    7. Simplified86.7%

      \[\leadsto \color{blue}{u0 \cdot \left(0.5 \cdot \frac{u0}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}} + \frac{1}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    8. Taylor expanded in alphay around 0 79.5%

      \[\leadsto u0 \cdot \color{blue}{\left({alphay}^{2} \cdot \left(0.5 \cdot \frac{u0}{sin2phi} + \frac{1}{sin2phi}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 68.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\ \;\;\;\;u0 \cdot \left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (if (<= sin2phi 2.00000006274879e-22)
   (* u0 (* (pow alphax 2.0) (+ (* 0.5 (/ u0 cos2phi)) (/ 1.0 cos2phi))))
   (* (pow alphay 2.0) (/ u0 sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float tmp;
	if (sin2phi <= 2.00000006274879e-22f) {
		tmp = u0 * (powf(alphax, 2.0f) * ((0.5f * (u0 / cos2phi)) + (1.0f / cos2phi)));
	} else {
		tmp = powf(alphay, 2.0f) * (u0 / sin2phi);
	}
	return tmp;
}
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
    real(4) :: tmp
    if (sin2phi <= 2.00000006274879e-22) then
        tmp = u0 * ((alphax ** 2.0e0) * ((0.5e0 * (u0 / cos2phi)) + (1.0e0 / cos2phi)))
    else
        tmp = (alphay ** 2.0e0) * (u0 / sin2phi)
    end if
    code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = Float32(0.0)
	if (sin2phi <= Float32(2.00000006274879e-22))
		tmp = Float32(u0 * Float32((alphax ^ Float32(2.0)) * Float32(Float32(Float32(0.5) * Float32(u0 / cos2phi)) + Float32(Float32(1.0) / cos2phi))));
	else
		tmp = Float32((alphay ^ Float32(2.0)) * Float32(u0 / sin2phi));
	end
	return tmp
end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = single(0.0);
	if (sin2phi <= single(2.00000006274879e-22))
		tmp = u0 * ((alphax ^ single(2.0)) * ((single(0.5) * (u0 / cos2phi)) + (single(1.0) / cos2phi)));
	else
		tmp = (alphay ^ single(2.0)) * (u0 / sin2phi);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;u0 \cdot \left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if sin2phi < 2.00000006e-22

    1. Initial program 51.5%

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

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

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

        \[\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.7%

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

        \[\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.7%

        \[\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.7%

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

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

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

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

      \[\leadsto \color{blue}{u0 \cdot \left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} - \frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    6. Step-by-step derivation
      1. sub-neg87.7%

        \[\leadsto u0 \cdot \color{blue}{\left(-0.5 \cdot \frac{u0}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}} + \left(-\frac{1}{-1 \cdot \frac{cos2phi}{{alphax}^{2}} - \frac{sin2phi}{{alphay}^{2}}}\right)\right)} \]
    7. Simplified87.7%

      \[\leadsto \color{blue}{u0 \cdot \left(0.5 \cdot \frac{u0}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}} + \frac{1}{\frac{cos2phi}{{alphax}^{2}} + \frac{sin2phi}{{alphay}^{2}}}\right)} \]
    8. Taylor expanded in alphax around 0 73.2%

      \[\leadsto u0 \cdot \color{blue}{\left({alphax}^{2} \cdot \left(0.5 \cdot \frac{u0}{cos2phi} + \frac{1}{cos2phi}\right)\right)} \]

    if 2.00000006e-22 < sin2phi

    1. Initial program 62.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-neg62.7%

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

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg62.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.0%

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

        \[\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.0%

        \[\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.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{cos2phi}{{alphax}^{2}} + sin2phi \cdot {alphay}^{-2}}{\mathsf{log1p}\left(u0\right)}}} \]
    6. Taylor expanded in cos2phi around 0 42.2%

      \[\leadsto \frac{1}{\color{blue}{\frac{sin2phi}{{alphay}^{2} \cdot \log \left(1 + u0\right)}}} \]
    7. Step-by-step derivation
      1. associate-/r*42.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\log \left(1 + u0\right)}}} \]
      2. log1p-define65.1%

        \[\leadsto \frac{1}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\color{blue}{\mathsf{log1p}\left(u0\right)}}} \]
    8. Simplified65.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\mathsf{log1p}\left(u0\right)}}} \]
    9. Taylor expanded in u0 around 0 69.7%

      \[\leadsto \color{blue}{\frac{{alphay}^{2} \cdot u0}{sin2phi}} \]
    10. Step-by-step derivation
      1. associate-/l*69.8%

        \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
    11. Simplified69.8%

      \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 98.4% accurate, 1.0× speedup?

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

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

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

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

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

      \[\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.2%

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

      \[\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.2%

      \[\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.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{-\frac{cos2phi}{alphax}}{-\color{blue}{\sqrt{alphax} \cdot \sqrt{alphax}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    7. add-sqr-sqrt73.0%

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{-\frac{cos2phi}{alphax}}{-\color{blue}{alphax}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    8. add-sqr-sqrt-0.0%

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

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

      \[\leadsto \frac{\mathsf{log1p}\left(-u0\right)}{\frac{-\frac{cos2phi}{alphax}}{\sqrt{\color{blue}{alphax \cdot alphax}}} - \frac{sin2phi}{alphay \cdot alphay}} \]
    11. sqrt-unprod98.0%

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

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

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

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

Alternative 7: 98.4% accurate, 1.0× speedup?

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

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

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

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

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

      \[\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.2%

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

      \[\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.2%

      \[\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.2%

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

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

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

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

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

Alternative 8: 66.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\ \;\;\;\;\frac{1}{\frac{cos2phi}{u0 \cdot {alphax}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (if (<= sin2phi 2.00000006274879e-22)
   (/ 1.0 (/ cos2phi (* u0 (pow alphax 2.0))))
   (* (pow alphay 2.0) (/ u0 sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float tmp;
	if (sin2phi <= 2.00000006274879e-22f) {
		tmp = 1.0f / (cos2phi / (u0 * powf(alphax, 2.0f)));
	} else {
		tmp = powf(alphay, 2.0f) * (u0 / sin2phi);
	}
	return tmp;
}
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
    real(4) :: tmp
    if (sin2phi <= 2.00000006274879e-22) then
        tmp = 1.0e0 / (cos2phi / (u0 * (alphax ** 2.0e0)))
    else
        tmp = (alphay ** 2.0e0) * (u0 / sin2phi)
    end if
    code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = Float32(0.0)
	if (sin2phi <= Float32(2.00000006274879e-22))
		tmp = Float32(Float32(1.0) / Float32(cos2phi / Float32(u0 * (alphax ^ Float32(2.0)))));
	else
		tmp = Float32((alphay ^ Float32(2.0)) * Float32(u0 / sin2phi));
	end
	return tmp
end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = single(0.0);
	if (sin2phi <= single(2.00000006274879e-22))
		tmp = single(1.0) / (cos2phi / (u0 * (alphax ^ single(2.0))));
	else
		tmp = (alphay ^ single(2.0)) * (u0 / sin2phi);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;\frac{1}{\frac{cos2phi}{u0 \cdot {alphax}^{2}}}\\

\mathbf{else}:\\
\;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if sin2phi < 2.00000006e-22

    1. Initial program 51.5%

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

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

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

        \[\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.7%

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

        \[\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.7%

        \[\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.7%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
      2. associate-/l*42.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{alphax}^{2} \cdot u0}{cos2phi}} \]
    9. Step-by-step derivation
      1. clear-num65.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{cos2phi}{{alphax}^{2} \cdot u0}}} \]
      2. *-commutative65.3%

        \[\leadsto \frac{1}{\frac{cos2phi}{\color{blue}{u0 \cdot {alphax}^{2}}}} \]
    10. Applied egg-rr65.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{cos2phi}{u0 \cdot {alphax}^{2}}}} \]

    if 2.00000006e-22 < sin2phi

    1. Initial program 62.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-neg62.7%

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

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg62.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.0%

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

        \[\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.0%

        \[\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.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{cos2phi}{{alphax}^{2}} + sin2phi \cdot {alphay}^{-2}}{\mathsf{log1p}\left(u0\right)}}} \]
    6. Taylor expanded in cos2phi around 0 42.2%

      \[\leadsto \frac{1}{\color{blue}{\frac{sin2phi}{{alphay}^{2} \cdot \log \left(1 + u0\right)}}} \]
    7. Step-by-step derivation
      1. associate-/r*42.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\log \left(1 + u0\right)}}} \]
      2. log1p-define65.1%

        \[\leadsto \frac{1}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\color{blue}{\mathsf{log1p}\left(u0\right)}}} \]
    8. Simplified65.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\mathsf{log1p}\left(u0\right)}}} \]
    9. Taylor expanded in u0 around 0 69.7%

      \[\leadsto \color{blue}{\frac{{alphay}^{2} \cdot u0}{sin2phi}} \]
    10. Step-by-step derivation
      1. associate-/l*69.8%

        \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
    11. Simplified69.8%

      \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 66.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\ \;\;\;\;{alphax}^{2} \cdot \frac{u0}{cos2phi}\\ \mathbf{else}:\\ \;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\ \end{array} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (if (<= sin2phi 2.00000006274879e-22)
   (* (pow alphax 2.0) (/ u0 cos2phi))
   (* (pow alphay 2.0) (/ u0 sin2phi))))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	float tmp;
	if (sin2phi <= 2.00000006274879e-22f) {
		tmp = powf(alphax, 2.0f) * (u0 / cos2phi);
	} else {
		tmp = powf(alphay, 2.0f) * (u0 / sin2phi);
	}
	return tmp;
}
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
    real(4) :: tmp
    if (sin2phi <= 2.00000006274879e-22) then
        tmp = (alphax ** 2.0e0) * (u0 / cos2phi)
    else
        tmp = (alphay ** 2.0e0) * (u0 / sin2phi)
    end if
    code = tmp
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = Float32(0.0)
	if (sin2phi <= Float32(2.00000006274879e-22))
		tmp = Float32((alphax ^ Float32(2.0)) * Float32(u0 / cos2phi));
	else
		tmp = Float32((alphay ^ Float32(2.0)) * Float32(u0 / sin2phi));
	end
	return tmp
end
function tmp_2 = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = single(0.0);
	if (sin2phi <= single(2.00000006274879e-22))
		tmp = (alphax ^ single(2.0)) * (u0 / cos2phi);
	else
		tmp = (alphay ^ single(2.0)) * (u0 / sin2phi);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;sin2phi \leq 2.00000006274879 \cdot 10^{-22}:\\
\;\;\;\;{alphax}^{2} \cdot \frac{u0}{cos2phi}\\

\mathbf{else}:\\
\;\;\;\;{alphay}^{2} \cdot \frac{u0}{sin2phi}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if sin2phi < 2.00000006e-22

    1. Initial program 51.5%

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

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

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

        \[\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.7%

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

        \[\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.7%

        \[\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.7%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
      2. associate-/l*42.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{alphax}^{2} \cdot u0}{cos2phi}} \]
    9. Step-by-step derivation
      1. associate-/l*65.2%

        \[\leadsto \color{blue}{{alphax}^{2} \cdot \frac{u0}{cos2phi}} \]
    10. Simplified65.2%

      \[\leadsto \color{blue}{{alphax}^{2} \cdot \frac{u0}{cos2phi}} \]

    if 2.00000006e-22 < sin2phi

    1. Initial program 62.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-neg62.7%

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

        \[\leadsto \color{blue}{\frac{\log \left(1 - u0\right)}{-\left(\frac{cos2phi}{alphax \cdot alphax} + \frac{sin2phi}{alphay \cdot alphay}\right)}} \]
      3. sub-neg62.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.0%

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

        \[\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.0%

        \[\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.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{cos2phi}{{alphax}^{2}} + sin2phi \cdot {alphay}^{-2}}{\mathsf{log1p}\left(u0\right)}}} \]
    6. Taylor expanded in cos2phi around 0 42.2%

      \[\leadsto \frac{1}{\color{blue}{\frac{sin2phi}{{alphay}^{2} \cdot \log \left(1 + u0\right)}}} \]
    7. Step-by-step derivation
      1. associate-/r*42.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\log \left(1 + u0\right)}}} \]
      2. log1p-define65.1%

        \[\leadsto \frac{1}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\color{blue}{\mathsf{log1p}\left(u0\right)}}} \]
    8. Simplified65.1%

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{sin2phi}{{alphay}^{2}}}{\mathsf{log1p}\left(u0\right)}}} \]
    9. Taylor expanded in u0 around 0 69.7%

      \[\leadsto \color{blue}{\frac{{alphay}^{2} \cdot u0}{sin2phi}} \]
    10. Step-by-step derivation
      1. associate-/l*69.8%

        \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
    11. Simplified69.8%

      \[\leadsto \color{blue}{{alphay}^{2} \cdot \frac{u0}{sin2phi}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 23.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ {alphax}^{2} \cdot \frac{u0}{cos2phi} \end{array} \]
(FPCore (alphax alphay u0 cos2phi sin2phi)
 :precision binary32
 (* (pow alphax 2.0) (/ u0 cos2phi)))
float code(float alphax, float alphay, float u0, float cos2phi, float sin2phi) {
	return powf(alphax, 2.0f) * (u0 / 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 = (alphax ** 2.0e0) * (u0 / cos2phi)
end function
function code(alphax, alphay, u0, cos2phi, sin2phi)
	return Float32((alphax ^ Float32(2.0)) * Float32(u0 / cos2phi))
end
function tmp = code(alphax, alphay, u0, cos2phi, sin2phi)
	tmp = (alphax ^ single(2.0)) * (u0 / cos2phi);
end
\begin{array}{l}

\\
{alphax}^{2} \cdot \frac{u0}{cos2phi}
\end{array}
Derivation
  1. Initial program 60.5%

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

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

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

      \[\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.2%

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

      \[\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.2%

      \[\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.2%

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{{alphax}^{2} \cdot \log \left(1 - u0\right)}{cos2phi}} \]
    2. associate-/l*21.6%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{{alphax}^{2} \cdot u0}{cos2phi}} \]
  9. Step-by-step derivation
    1. associate-/l*23.0%

      \[\leadsto \color{blue}{{alphax}^{2} \cdot \frac{u0}{cos2phi}} \]
  10. Simplified23.0%

    \[\leadsto \color{blue}{{alphax}^{2} \cdot \frac{u0}{cos2phi}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024096 
(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)))))