GTR1 distribution

Percentage Accurate: 98.6% → 98.6%
Time: 8.5s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\left(0 \leq cosTheta \land cosTheta \leq 1\right) \land \left(0.0001 \leq \alpha \land \alpha \leq 1\right)\]
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha - 1\\ \frac{t\_0}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (- (* alpha alpha) 1.0)))
   (/
    t_0
    (* (* PI (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))
float code(float cosTheta, float alpha) {
	float t_0 = (alpha * alpha) - 1.0f;
	return t_0 / ((((float) M_PI) * logf((alpha * alpha))) * (1.0f + ((t_0 * cosTheta) * cosTheta)));
}
function code(cosTheta, alpha)
	t_0 = Float32(Float32(alpha * alpha) - Float32(1.0))
	return Float32(t_0 / Float32(Float32(Float32(pi) * log(Float32(alpha * alpha))) * Float32(Float32(1.0) + Float32(Float32(t_0 * cosTheta) * cosTheta))))
end
function tmp = code(cosTheta, alpha)
	t_0 = (alpha * alpha) - single(1.0);
	tmp = t_0 / ((single(pi) * log((alpha * alpha))) * (single(1.0) + ((t_0 * cosTheta) * cosTheta)));
end
\begin{array}{l}

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

Sampling outcomes in binary32 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha - 1\\ \frac{t\_0}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (- (* alpha alpha) 1.0)))
   (/
    t_0
    (* (* PI (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))
float code(float cosTheta, float alpha) {
	float t_0 = (alpha * alpha) - 1.0f;
	return t_0 / ((((float) M_PI) * logf((alpha * alpha))) * (1.0f + ((t_0 * cosTheta) * cosTheta)));
}
function code(cosTheta, alpha)
	t_0 = Float32(Float32(alpha * alpha) - Float32(1.0))
	return Float32(t_0 / Float32(Float32(Float32(pi) * log(Float32(alpha * alpha))) * Float32(Float32(1.0) + Float32(Float32(t_0 * cosTheta) * cosTheta))))
end
function tmp = code(cosTheta, alpha)
	t_0 = (alpha * alpha) - single(1.0);
	tmp = t_0 / ((single(pi) * log((alpha * alpha))) * (single(1.0) + ((t_0 * cosTheta) * cosTheta)));
end
\begin{array}{l}

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

Alternative 1: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha + -1\\ \frac{t\_0}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + t\_0 \cdot \left(cosTheta \cdot cosTheta\right)\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (+ (* alpha alpha) -1.0)))
   (/
    t_0
    (* (* PI (log (* alpha alpha))) (+ 1.0 (* t_0 (* cosTheta cosTheta)))))))
float code(float cosTheta, float alpha) {
	float t_0 = (alpha * alpha) + -1.0f;
	return t_0 / ((((float) M_PI) * logf((alpha * alpha))) * (1.0f + (t_0 * (cosTheta * cosTheta))));
}
function code(cosTheta, alpha)
	t_0 = Float32(Float32(alpha * alpha) + Float32(-1.0))
	return Float32(t_0 / Float32(Float32(Float32(pi) * log(Float32(alpha * alpha))) * Float32(Float32(1.0) + Float32(t_0 * Float32(cosTheta * cosTheta)))))
end
function tmp = code(cosTheta, alpha)
	t_0 = (alpha * alpha) + single(-1.0);
	tmp = t_0 / ((single(pi) * log((alpha * alpha))) * (single(1.0) + (t_0 * (cosTheta * cosTheta))));
end
\begin{array}{l}

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

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \left(\left(\alpha \cdot \alpha - 1\right) \cdot \color{blue}{\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left(\alpha \cdot \alpha - 1\right), \color{blue}{\left(cosTheta \cdot cosTheta\right)}\right)\right)\right)\right) \]
    3. sub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left(\alpha \cdot \alpha + \left(\mathsf{neg}\left(1\right)\right)\right), \left(\color{blue}{cosTheta} \cdot cosTheta\right)\right)\right)\right)\right) \]
    4. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\left(\alpha \cdot \alpha\right), \left(\mathsf{neg}\left(1\right)\right)\right), \left(\color{blue}{cosTheta} \cdot cosTheta\right)\right)\right)\right)\right) \]
    5. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(\mathsf{neg}\left(1\right)\right)\right), \left(cosTheta \cdot cosTheta\right)\right)\right)\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), -1\right), \left(cosTheta \cdot cosTheta\right)\right)\right)\right)\right) \]
    7. *-lowering-*.f3298.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), -1\right), \mathsf{*.f32}\left(cosTheta, \color{blue}{cosTheta}\right)\right)\right)\right)\right) \]
  4. Applied egg-rr98.5%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \color{blue}{\left(\alpha \cdot \alpha + -1\right) \cdot \left(cosTheta \cdot cosTheta\right)}\right)} \]
  5. Final simplification98.5%

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

Alternative 2: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \alpha \cdot \alpha + -1\\ \frac{t\_0}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + cosTheta \cdot \left(t\_0 \cdot cosTheta\right)\right)} \end{array} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (let* ((t_0 (+ (* alpha alpha) -1.0)))
   (/
    t_0
    (* (* PI (log (* alpha alpha))) (+ 1.0 (* cosTheta (* t_0 cosTheta)))))))
float code(float cosTheta, float alpha) {
	float t_0 = (alpha * alpha) + -1.0f;
	return t_0 / ((((float) M_PI) * logf((alpha * alpha))) * (1.0f + (cosTheta * (t_0 * cosTheta))));
}
function code(cosTheta, alpha)
	t_0 = Float32(Float32(alpha * alpha) + Float32(-1.0))
	return Float32(t_0 / Float32(Float32(Float32(pi) * log(Float32(alpha * alpha))) * Float32(Float32(1.0) + Float32(cosTheta * Float32(t_0 * cosTheta)))))
end
function tmp = code(cosTheta, alpha)
	t_0 = (alpha * alpha) + single(-1.0);
	tmp = t_0 / ((single(pi) * log((alpha * alpha))) * (single(1.0) + (cosTheta * (t_0 * cosTheta))));
end
\begin{array}{l}

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

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

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

Alternative 3: 97.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\alpha \cdot \alpha + -1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 - cosTheta \cdot cosTheta\right)} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (/
  (+ (* alpha alpha) -1.0)
  (* (* PI (log (* alpha alpha))) (- 1.0 (* cosTheta cosTheta)))))
float code(float cosTheta, float alpha) {
	return ((alpha * alpha) + -1.0f) / ((((float) M_PI) * logf((alpha * alpha))) * (1.0f - (cosTheta * cosTheta)));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(alpha * alpha) + Float32(-1.0)) / Float32(Float32(Float32(pi) * log(Float32(alpha * alpha))) * Float32(Float32(1.0) - Float32(cosTheta * cosTheta))))
end
function tmp = code(cosTheta, alpha)
	tmp = ((alpha * alpha) + single(-1.0)) / ((single(pi) * log((alpha * alpha))) * (single(1.0) - (cosTheta * cosTheta)));
end
\begin{array}{l}

\\
\frac{\alpha \cdot \alpha + -1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 - cosTheta \cdot cosTheta\right)}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\color{blue}{\left(-1 \cdot cosTheta\right)}, cosTheta\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left(\mathsf{neg}\left(cosTheta\right)\right), cosTheta\right)\right)\right)\right) \]
    2. neg-lowering-neg.f3297.9%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{neg.f32}\left(cosTheta\right), cosTheta\right)\right)\right)\right) \]
  5. Simplified97.9%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \color{blue}{\left(-cosTheta\right)} \cdot cosTheta\right)} \]
  6. Taylor expanded in cosTheta around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \color{blue}{\left(-1 \cdot \left({cosTheta}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)\right) + \mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)}\right) \]
  7. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(\left(-1 \cdot {cosTheta}^{2}\right) \cdot \left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right) + \color{blue}{\mathsf{PI}\left(\right)} \cdot \log \left({\alpha}^{2}\right)\right)\right) \]
    2. distribute-lft1-inN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(\left(-1 \cdot {cosTheta}^{2} + 1\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(\left(1 + -1 \cdot {cosTheta}^{2}\right) \cdot \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\left(1 + -1 \cdot {cosTheta}^{2}\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)}\right)\right) \]
    5. mul-1-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\left(1 + \left(\mathsf{neg}\left({cosTheta}^{2}\right)\right)\right), \left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    6. unsub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\left(1 - {cosTheta}^{2}\right), \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    7. --lowering--.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \left({cosTheta}^{2}\right)\right), \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    8. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \left(cosTheta \cdot cosTheta\right)\right), \left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\log \left({\alpha}^{2}\right)}\right)\right)\right) \]
    11. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \log \color{blue}{\left({\alpha}^{2}\right)}\right)\right)\right) \]
    12. log-lowering-log.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\left({\alpha}^{2}\right)\right)\right)\right)\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\left(\alpha \cdot \alpha\right)\right)\right)\right)\right) \]
    14. *-lowering-*.f3297.9%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right)\right) \]
  8. Simplified97.9%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\color{blue}{\left(1 - cosTheta \cdot cosTheta\right) \cdot \left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right)}} \]
  9. Final simplification97.9%

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

Alternative 4: 97.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\alpha \cdot \alpha + -1}{\left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \log \alpha\right) \cdot \left(\pi \cdot 2\right)} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (/
  (+ (* alpha alpha) -1.0)
  (* (* (- 1.0 (* cosTheta cosTheta)) (log alpha)) (* PI 2.0))))
float code(float cosTheta, float alpha) {
	return ((alpha * alpha) + -1.0f) / (((1.0f - (cosTheta * cosTheta)) * logf(alpha)) * (((float) M_PI) * 2.0f));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(alpha * alpha) + Float32(-1.0)) / Float32(Float32(Float32(Float32(1.0) - Float32(cosTheta * cosTheta)) * log(alpha)) * Float32(Float32(pi) * Float32(2.0))))
end
function tmp = code(cosTheta, alpha)
	tmp = ((alpha * alpha) + single(-1.0)) / (((single(1.0) - (cosTheta * cosTheta)) * log(alpha)) * (single(pi) * single(2.0)));
end
\begin{array}{l}

\\
\frac{\alpha \cdot \alpha + -1}{\left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \log \alpha\right) \cdot \left(\pi \cdot 2\right)}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right)\right)\right)}\right) \]
  4. Step-by-step derivation
    1. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot \color{blue}{\left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right)}\right)\right) \]
    2. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(\left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right) \cdot \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right), \color{blue}{\left(2 \cdot \mathsf{PI}\left(\right)\right)}\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\log \alpha, \left(1 + -1 \cdot {cosTheta}^{2}\right)\right), \left(\color{blue}{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    5. log-lowering-log.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \left(1 + -1 \cdot {cosTheta}^{2}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    6. mul-1-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \left(1 + \left(\mathsf{neg}\left({cosTheta}^{2}\right)\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    7. unsub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \left(1 - {cosTheta}^{2}\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    8. --lowering--.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \left({cosTheta}^{2}\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \left(cosTheta \cdot cosTheta\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    10. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \left(\mathsf{PI}\left(\right) \cdot \color{blue}{2}\right)\right)\right) \]
    12. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{2}\right)\right)\right) \]
    13. PI-lowering-PI.f3297.8%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{log.f32}\left(\alpha\right), \mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(cosTheta, cosTheta\right)\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), 2\right)\right)\right) \]
  5. Simplified97.8%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\color{blue}{\left(\log \alpha \cdot \left(1 - cosTheta \cdot cosTheta\right)\right) \cdot \left(\pi \cdot 2\right)}} \]
  6. Final simplification97.8%

    \[\leadsto \frac{\alpha \cdot \alpha + -1}{\left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \log \alpha\right) \cdot \left(\pi \cdot 2\right)} \]
  7. Add Preprocessing

Alternative 5: 96.7% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\alpha \cdot \alpha + -1}{\pi \cdot \log \left(\alpha \cdot \alpha\right)} \cdot \left(1 + cosTheta \cdot cosTheta\right) \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (*
  (/ (+ (* alpha alpha) -1.0) (* PI (log (* alpha alpha))))
  (+ 1.0 (* cosTheta cosTheta))))
float code(float cosTheta, float alpha) {
	return (((alpha * alpha) + -1.0f) / (((float) M_PI) * logf((alpha * alpha)))) * (1.0f + (cosTheta * cosTheta));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(Float32(alpha * alpha) + Float32(-1.0)) / Float32(Float32(pi) * log(Float32(alpha * alpha)))) * Float32(Float32(1.0) + Float32(cosTheta * cosTheta)))
end
function tmp = code(cosTheta, alpha)
	tmp = (((alpha * alpha) + single(-1.0)) / (single(pi) * log((alpha * alpha)))) * (single(1.0) + (cosTheta * cosTheta));
end
\begin{array}{l}

\\
\frac{\alpha \cdot \alpha + -1}{\pi \cdot \log \left(\alpha \cdot \alpha\right)} \cdot \left(1 + cosTheta \cdot cosTheta\right)
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\color{blue}{\left(-1 \cdot cosTheta\right)}, cosTheta\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\left(\mathsf{neg}\left(cosTheta\right)\right), cosTheta\right)\right)\right)\right) \]
    2. neg-lowering-neg.f3297.9%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{neg.f32}\left(cosTheta\right), cosTheta\right)\right)\right)\right) \]
  5. Simplified97.9%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \color{blue}{\left(-cosTheta\right)} \cdot cosTheta\right)} \]
  6. Taylor expanded in cosTheta around 0

    \[\leadsto \color{blue}{\left(\frac{{cosTheta}^{2} \cdot \left({\alpha}^{2} - 1\right)}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} + \frac{{\alpha}^{2}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right) - \frac{1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
  7. Step-by-step derivation
    1. associate--l+N/A

      \[\leadsto \frac{{cosTheta}^{2} \cdot \left({\alpha}^{2} - 1\right)}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} + \color{blue}{\left(\frac{{\alpha}^{2}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} - \frac{1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)} \]
    2. associate-/l*N/A

      \[\leadsto {cosTheta}^{2} \cdot \frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} + \left(\color{blue}{\frac{{\alpha}^{2}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} - \frac{1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right) \]
    3. div-subN/A

      \[\leadsto {cosTheta}^{2} \cdot \frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} + \frac{{\alpha}^{2} - 1}{\color{blue}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
    4. *-lft-identityN/A

      \[\leadsto {cosTheta}^{2} \cdot \frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} + 1 \cdot \color{blue}{\frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
    5. distribute-rgt-outN/A

      \[\leadsto \frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)} \cdot \color{blue}{\left({cosTheta}^{2} + 1\right)} \]
    6. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\frac{{\alpha}^{2} - 1}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right), \color{blue}{\left({cosTheta}^{2} + 1\right)}\right) \]
  8. Simplified97.1%

    \[\leadsto \color{blue}{\frac{-1 + \alpha \cdot \alpha}{\pi \cdot \log \left(\alpha \cdot \alpha\right)} \cdot \left(cosTheta \cdot cosTheta + 1\right)} \]
  9. Final simplification97.1%

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

Alternative 6: 95.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\alpha \cdot \alpha + -1}{\pi \cdot \log \left(\alpha \cdot \alpha\right)} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (/ (+ (* alpha alpha) -1.0) (* PI (log (* alpha alpha)))))
float code(float cosTheta, float alpha) {
	return ((alpha * alpha) + -1.0f) / (((float) M_PI) * logf((alpha * alpha)));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(alpha * alpha) + Float32(-1.0)) / Float32(Float32(pi) * log(Float32(alpha * alpha))))
end
function tmp = code(cosTheta, alpha)
	tmp = ((alpha * alpha) + single(-1.0)) / (single(pi) * log((alpha * alpha)));
end
\begin{array}{l}

\\
\frac{\alpha \cdot \alpha + -1}{\pi \cdot \log \left(\alpha \cdot \alpha\right)}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in cosTheta around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)\right)}\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\log \left({\alpha}^{2}\right)}\right)\right) \]
    2. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \log \color{blue}{\left({\alpha}^{2}\right)}\right)\right) \]
    3. log-lowering-log.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\left({\alpha}^{2}\right)\right)\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\left(\alpha \cdot \alpha\right)\right)\right)\right) \]
    5. *-lowering-*.f3295.6%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
  5. Simplified95.6%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\color{blue}{\pi \cdot \log \left(\alpha \cdot \alpha\right)}} \]
  6. Final simplification95.6%

    \[\leadsto \frac{\alpha \cdot \alpha + -1}{\pi \cdot \log \left(\alpha \cdot \alpha\right)} \]
  7. Add Preprocessing

Alternative 7: 95.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\alpha \cdot \alpha + -1}{2 \cdot \left(\pi \cdot \log \alpha\right)} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (/ (+ (* alpha alpha) -1.0) (* 2.0 (* PI (log alpha)))))
float code(float cosTheta, float alpha) {
	return ((alpha * alpha) + -1.0f) / (2.0f * (((float) M_PI) * logf(alpha)));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(alpha * alpha) + Float32(-1.0)) / Float32(Float32(2.0) * Float32(Float32(pi) * log(alpha))))
end
function tmp = code(cosTheta, alpha)
	tmp = ((alpha * alpha) + single(-1.0)) / (single(2.0) * (single(pi) * log(alpha)));
end
\begin{array}{l}

\\
\frac{\alpha \cdot \alpha + -1}{2 \cdot \left(\pi \cdot \log \alpha\right)}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right)\right) + 2 \cdot \left({\alpha}^{2} \cdot \left({cosTheta}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)\right)\right)\right)}\right) \]
  4. Step-by-step derivation
    1. distribute-lft-outN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \left(2 \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right) + {\alpha}^{2} \cdot \left({cosTheta}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)\right)\right)}\right)\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right)\right) + {\alpha}^{2} \cdot \left({cosTheta}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)\right)\right)}\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right) \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right) + \color{blue}{{\alpha}^{2}} \cdot \left({cosTheta}^{2} \cdot \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)\right)\right)\right)\right) \]
    4. associate-*r*N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right) \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right) + \left({\alpha}^{2} \cdot {cosTheta}^{2}\right) \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)}\right)\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right) \cdot \left(1 + -1 \cdot {cosTheta}^{2}\right) + \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right) \cdot \color{blue}{\left({\alpha}^{2} \cdot {cosTheta}^{2}\right)}\right)\right)\right) \]
    6. distribute-lft-outN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \left(\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right) \cdot \color{blue}{\left(\left(1 + -1 \cdot {cosTheta}^{2}\right) + {\alpha}^{2} \cdot {cosTheta}^{2}\right)}\right)\right)\right) \]
    7. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right), \color{blue}{\left(\left(1 + -1 \cdot {cosTheta}^{2}\right) + {\alpha}^{2} \cdot {cosTheta}^{2}\right)}\right)\right)\right) \]
    8. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI}\left(\right), \log \alpha\right), \left(\color{blue}{\left(1 + -1 \cdot {cosTheta}^{2}\right)} + {\alpha}^{2} \cdot {cosTheta}^{2}\right)\right)\right)\right) \]
    9. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \log \alpha\right), \left(\left(\color{blue}{1} + -1 \cdot {cosTheta}^{2}\right) + {\alpha}^{2} \cdot {cosTheta}^{2}\right)\right)\right)\right) \]
    10. log-lowering-log.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\alpha\right)\right), \left(\left(1 + \color{blue}{-1 \cdot {cosTheta}^{2}}\right) + {\alpha}^{2} \cdot {cosTheta}^{2}\right)\right)\right)\right) \]
    11. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\alpha\right)\right), \mathsf{+.f32}\left(\left(1 + -1 \cdot {cosTheta}^{2}\right), \color{blue}{\left({\alpha}^{2} \cdot {cosTheta}^{2}\right)}\right)\right)\right)\right) \]
  5. Simplified98.4%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\color{blue}{2 \cdot \left(\left(\pi \cdot \log \alpha\right) \cdot \left(\left(1 - cosTheta \cdot cosTheta\right) + \alpha \cdot \left(\alpha \cdot \left(cosTheta \cdot cosTheta\right)\right)\right)\right)}} \]
  6. Taylor expanded in cosTheta around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \color{blue}{\left(2 \cdot \left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)\right)}\right) \]
  7. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)}\right)\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\log \alpha}\right)\right)\right) \]
    3. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \log \color{blue}{\alpha}\right)\right)\right) \]
    4. log-lowering-log.f3295.5%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), \mathsf{*.f32}\left(2, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\alpha\right)\right)\right)\right) \]
  8. Simplified95.5%

    \[\leadsto \frac{\alpha \cdot \alpha - 1}{\color{blue}{2 \cdot \left(\pi \cdot \log \alpha\right)}} \]
  9. Final simplification95.5%

    \[\leadsto \frac{\alpha \cdot \alpha + -1}{2 \cdot \left(\pi \cdot \log \alpha\right)} \]
  10. Add Preprocessing

Alternative 8: 66.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{-0.5}{\pi}}{\log \alpha} \end{array} \]
(FPCore (cosTheta alpha) :precision binary32 (/ (/ -0.5 PI) (log alpha)))
float code(float cosTheta, float alpha) {
	return (-0.5f / ((float) M_PI)) / logf(alpha);
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(-0.5) / Float32(pi)) / log(alpha))
end
function tmp = code(cosTheta, alpha)
	tmp = (single(-0.5) / single(pi)) / log(alpha);
end
\begin{array}{l}

\\
\frac{\frac{-0.5}{\pi}}{\log \alpha}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around inf

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left({\alpha}^{2} \cdot \left(1 - \frac{1}{{\alpha}^{2}}\right)\right)}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\alpha}^{2}\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)}, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\alpha \cdot \alpha\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    4. sub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(1 + \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{\mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    5. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{\mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    6. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\frac{\mathsf{neg}\left(1\right)}{{\alpha}^{2}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\frac{-1}{{\alpha}^{2}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left({\alpha}^{2}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left(\alpha \cdot \alpha\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    10. *-lowering-*.f3298.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
  5. Simplified98.4%

    \[\leadsto \frac{\color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left(1 + \frac{-1}{\alpha \cdot \alpha}\right)}}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  6. Taylor expanded in cosTheta around 0

    \[\leadsto \color{blue}{\frac{{\alpha}^{2} \cdot \left(1 - \frac{1}{{\alpha}^{2}}\right)}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
  7. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto {\alpha}^{2} \cdot \color{blue}{\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left({\alpha}^{2}\right), \color{blue}{\left(\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)}\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\alpha \cdot \alpha\right), \left(\frac{\color{blue}{1 - \frac{1}{{\alpha}^{2}}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(\frac{\color{blue}{1 - \frac{1}{{\alpha}^{2}}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)\right) \]
    5. associate-/r*N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(\frac{\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right)}}{\color{blue}{\log \left({\alpha}^{2}\right)}}\right)\right) \]
    6. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\left(\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right)}\right), \color{blue}{\log \left({\alpha}^{2}\right)}\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 - \frac{1}{{\alpha}^{2}}\right), \mathsf{PI}\left(\right)\right), \log \color{blue}{\left({\alpha}^{2}\right)}\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 + \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\color{blue}{\alpha}}^{2}\right)\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\color{blue}{\alpha}}^{2}\right)\right)\right) \]
    10. distribute-neg-fracN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\frac{\mathsf{neg}\left(1\right)}{{\alpha}^{2}}\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\frac{-1}{{\alpha}^{2}}\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    12. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left({\alpha}^{2}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left(\alpha \cdot \alpha\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    15. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \log \left({\alpha}^{\color{blue}{2}}\right)\right)\right) \]
    16. log-lowering-log.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\left({\alpha}^{2}\right)\right)\right)\right) \]
    17. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\left(\alpha \cdot \alpha\right)\right)\right)\right) \]
    18. *-lowering-*.f3295.5%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
  8. Simplified95.5%

    \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot \frac{\frac{1 + \frac{-1}{\alpha \cdot \alpha}}{\pi}}{\log \left(\alpha \cdot \alpha\right)}} \]
  9. Taylor expanded in alpha around inf

    \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\color{blue}{\left(\frac{1}{\mathsf{PI}\left(\right)} - \frac{1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)}, \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
  10. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\left(\frac{1}{\mathsf{PI}\left(\right)} + \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right)\right), \mathsf{log.f32}\left(\color{blue}{\mathsf{*.f32}\left(\alpha, \alpha\right)}\right)\right)\right) \]
    2. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{1}{\mathsf{PI}\left(\right)}\right), \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right)\right), \mathsf{log.f32}\left(\color{blue}{\mathsf{*.f32}\left(\alpha, \alpha\right)}\right)\right)\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI}\left(\right)\right), \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\color{blue}{\alpha}, \alpha\right)\right)\right)\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    5. distribute-neg-fracN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \left(\frac{\mathsf{neg}\left(1\right)}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \color{blue}{\alpha}\right)\right)\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \left(\frac{-1}{{\alpha}^{2} \cdot \mathsf{PI}\left(\right)}\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \left({\alpha}^{2} \cdot \mathsf{PI}\left(\right)\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \color{blue}{\alpha}\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \left(\mathsf{PI}\left(\right) \cdot {\alpha}^{2}\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    9. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \left({\alpha}^{2}\right)\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    10. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left({\alpha}^{2}\right)\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    11. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \left(\alpha \cdot \alpha\right)\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
    12. *-lowering-*.f3295.3%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(1, \mathsf{PI.f32}\left(\right)\right), \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
  11. Simplified95.3%

    \[\leadsto \left(\alpha \cdot \alpha\right) \cdot \frac{\color{blue}{\frac{1}{\pi} + \frac{-1}{\pi \cdot \left(\alpha \cdot \alpha\right)}}}{\log \left(\alpha \cdot \alpha\right)} \]
  12. Taylor expanded in alpha around 0

    \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{\mathsf{PI}\left(\right) \cdot \log \alpha}} \]
  13. Step-by-step derivation
    1. associate-/r*N/A

      \[\leadsto \frac{\frac{\frac{-1}{2}}{\mathsf{PI}\left(\right)}}{\color{blue}{\log \alpha}} \]
    2. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\frac{\frac{-1}{2}}{\mathsf{PI}\left(\right)}\right), \color{blue}{\log \alpha}\right) \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{PI}\left(\right)\right), \log \color{blue}{\alpha}\right) \]
    4. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{PI.f32}\left(\right)\right), \log \alpha\right) \]
    5. log-lowering-log.f3264.3%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\alpha\right)\right) \]
  14. Simplified64.3%

    \[\leadsto \color{blue}{\frac{\frac{-0.5}{\pi}}{\log \alpha}} \]
  15. Add Preprocessing

Alternative 9: 66.2% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \frac{-0.5}{\pi \cdot \log \alpha} \end{array} \]
(FPCore (cosTheta alpha) :precision binary32 (/ -0.5 (* PI (log alpha))))
float code(float cosTheta, float alpha) {
	return -0.5f / (((float) M_PI) * logf(alpha));
}
function code(cosTheta, alpha)
	return Float32(Float32(-0.5) / Float32(Float32(pi) * log(alpha)))
end
function tmp = code(cosTheta, alpha)
	tmp = single(-0.5) / (single(pi) * log(alpha));
end
\begin{array}{l}

\\
\frac{-0.5}{\pi \cdot \log \alpha}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in alpha around inf

    \[\leadsto \mathsf{/.f32}\left(\color{blue}{\left({\alpha}^{2} \cdot \left(1 - \frac{1}{{\alpha}^{2}}\right)\right)}, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left({\alpha}^{2}\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\color{blue}{\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)}, \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\left(\alpha \cdot \alpha\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    3. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(1 - \frac{1}{{\alpha}^{2}}\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\color{blue}{\mathsf{PI.f32}\left(\right)}, \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    4. sub-negN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(1 + \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{\mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    5. +-lowering-+.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \color{blue}{\mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)}\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    6. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\frac{\mathsf{neg}\left(1\right)}{{\alpha}^{2}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    7. metadata-evalN/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \left(\frac{-1}{{\alpha}^{2}}\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    8. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left({\alpha}^{2}\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    9. unpow2N/A

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left(\alpha \cdot \alpha\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
    10. *-lowering-*.f3298.4%

      \[\leadsto \mathsf{/.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{+.f32}\left(1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), 1\right), cosTheta\right), cosTheta\right)\right)\right)\right) \]
  5. Simplified98.4%

    \[\leadsto \frac{\color{blue}{\left(\alpha \cdot \alpha\right) \cdot \left(1 + \frac{-1}{\alpha \cdot \alpha}\right)}}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  6. Taylor expanded in cosTheta around 0

    \[\leadsto \color{blue}{\frac{{\alpha}^{2} \cdot \left(1 - \frac{1}{{\alpha}^{2}}\right)}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
  7. Step-by-step derivation
    1. associate-/l*N/A

      \[\leadsto {\alpha}^{2} \cdot \color{blue}{\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}} \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\left({\alpha}^{2}\right), \color{blue}{\left(\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)}\right) \]
    3. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\left(\alpha \cdot \alpha\right), \left(\frac{\color{blue}{1 - \frac{1}{{\alpha}^{2}}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(\frac{\color{blue}{1 - \frac{1}{{\alpha}^{2}}}}{\mathsf{PI}\left(\right) \cdot \log \left({\alpha}^{2}\right)}\right)\right) \]
    5. associate-/r*N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \left(\frac{\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right)}}{\color{blue}{\log \left({\alpha}^{2}\right)}}\right)\right) \]
    6. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\left(\frac{1 - \frac{1}{{\alpha}^{2}}}{\mathsf{PI}\left(\right)}\right), \color{blue}{\log \left({\alpha}^{2}\right)}\right)\right) \]
    7. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 - \frac{1}{{\alpha}^{2}}\right), \mathsf{PI}\left(\right)\right), \log \color{blue}{\left({\alpha}^{2}\right)}\right)\right) \]
    8. sub-negN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\left(1 + \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\color{blue}{\alpha}}^{2}\right)\right)\right) \]
    9. +-lowering-+.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\mathsf{neg}\left(\frac{1}{{\alpha}^{2}}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\color{blue}{\alpha}}^{2}\right)\right)\right) \]
    10. distribute-neg-fracN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\frac{\mathsf{neg}\left(1\right)}{{\alpha}^{2}}\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \left(\frac{-1}{{\alpha}^{2}}\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    12. /-lowering-/.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left({\alpha}^{2}\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \left(\alpha \cdot \alpha\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    14. *-lowering-*.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI}\left(\right)\right), \log \left({\alpha}^{2}\right)\right)\right) \]
    15. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \log \left({\alpha}^{\color{blue}{2}}\right)\right)\right) \]
    16. log-lowering-log.f32N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\left({\alpha}^{2}\right)\right)\right)\right) \]
    17. unpow2N/A

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\left(\alpha \cdot \alpha\right)\right)\right)\right) \]
    18. *-lowering-*.f3295.5%

      \[\leadsto \mathsf{*.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right), \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(1, \mathsf{/.f32}\left(-1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right), \mathsf{PI.f32}\left(\right)\right), \mathsf{log.f32}\left(\mathsf{*.f32}\left(\alpha, \alpha\right)\right)\right)\right) \]
  8. Simplified95.5%

    \[\leadsto \color{blue}{\left(\alpha \cdot \alpha\right) \cdot \frac{\frac{1 + \frac{-1}{\alpha \cdot \alpha}}{\pi}}{\log \left(\alpha \cdot \alpha\right)}} \]
  9. Taylor expanded in alpha around 0

    \[\leadsto \color{blue}{\frac{\frac{-1}{2}}{\mathsf{PI}\left(\right) \cdot \log \alpha}} \]
  10. Step-by-step derivation
    1. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{-1}{2}, \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \log \alpha\right)}\right) \]
    2. *-lowering-*.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(\mathsf{PI}\left(\right), \color{blue}{\log \alpha}\right)\right) \]
    3. PI-lowering-PI.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \log \color{blue}{\alpha}\right)\right) \]
    4. log-lowering-log.f3264.2%

      \[\leadsto \mathsf{/.f32}\left(\frac{-1}{2}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{log.f32}\left(\alpha\right)\right)\right) \]
  11. Simplified64.2%

    \[\leadsto \color{blue}{\frac{-0.5}{\pi \cdot \log \alpha}} \]
  12. Add Preprocessing

Alternative 10: -0.0% accurate, 9.5× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{\pi \cdot \frac{0}{0}}}{-1 + cosTheta \cdot cosTheta} \end{array} \]
(FPCore (cosTheta alpha)
 :precision binary32
 (/ (/ 1.0 (* PI (/ 0.0 0.0))) (+ -1.0 (* cosTheta cosTheta))))
float code(float cosTheta, float alpha) {
	return (1.0f / (((float) M_PI) * (0.0f / 0.0f))) / (-1.0f + (cosTheta * cosTheta));
}
function code(cosTheta, alpha)
	return Float32(Float32(Float32(1.0) / Float32(Float32(pi) * Float32(Float32(0.0) / Float32(0.0)))) / Float32(Float32(-1.0) + Float32(cosTheta * cosTheta)))
end
function tmp = code(cosTheta, alpha)
	tmp = (single(1.0) / (single(pi) * (single(0.0) / single(0.0)))) / (single(-1.0) + (cosTheta * cosTheta));
end
\begin{array}{l}

\\
\frac{\frac{1}{\pi \cdot \frac{0}{0}}}{-1 + cosTheta \cdot cosTheta}
\end{array}
Derivation
  1. Initial program 98.5%

    \[\frac{\alpha \cdot \alpha - 1}{\left(\pi \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/r*N/A

      \[\leadsto \frac{\frac{\alpha \cdot \alpha - 1}{\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)}}{\color{blue}{1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta}} \]
    2. frac-2negN/A

      \[\leadsto \frac{\mathsf{neg}\left(\frac{\alpha \cdot \alpha - 1}{\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)}\right)}{\color{blue}{\mathsf{neg}\left(\left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)\right)}} \]
    3. /-lowering-/.f32N/A

      \[\leadsto \mathsf{/.f32}\left(\left(\mathsf{neg}\left(\frac{\alpha \cdot \alpha - 1}{\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)}\right)\right), \color{blue}{\left(\mathsf{neg}\left(\left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)\right)\right)}\right) \]
  4. Applied egg-rr-0.0%

    \[\leadsto \color{blue}{\frac{\frac{1 - \alpha \cdot \alpha}{\pi \cdot \frac{0}{0}}}{-1 + \left(cosTheta \cdot cosTheta\right) \cdot \left(1 - \alpha \cdot \alpha\right)}} \]
  5. Taylor expanded in alpha around 0

    \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, \mathsf{*.f32}\left(\alpha, \alpha\right)\right), \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{/.f32}\left(0, 0\right)\right)\right), \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), \color{blue}{1}\right)\right)\right) \]
  6. Step-by-step derivation
    1. Simplified-0.0%

      \[\leadsto \frac{\frac{1 - \alpha \cdot \alpha}{\pi \cdot \frac{0}{0}}}{-1 + \left(cosTheta \cdot cosTheta\right) \cdot \color{blue}{1}} \]
    2. Taylor expanded in alpha around 0

      \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(\color{blue}{1}, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{/.f32}\left(0, 0\right)\right)\right), \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(\mathsf{*.f32}\left(cosTheta, cosTheta\right), 1\right)\right)\right) \]
    3. Step-by-step derivation
      1. Simplified-0.0%

        \[\leadsto \frac{\frac{\color{blue}{1}}{\pi \cdot \frac{0}{0}}}{-1 + \left(cosTheta \cdot cosTheta\right) \cdot 1} \]
      2. Taylor expanded in cosTheta around 0

        \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{/.f32}\left(0, 0\right)\right)\right), \mathsf{+.f32}\left(-1, \color{blue}{\left({cosTheta}^{2}\right)}\right)\right) \]
      3. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{/.f32}\left(0, 0\right)\right)\right), \mathsf{+.f32}\left(-1, \left(cosTheta \cdot \color{blue}{cosTheta}\right)\right)\right) \]
        2. *-lowering-*.f32-0.0%

          \[\leadsto \mathsf{/.f32}\left(\mathsf{/.f32}\left(1, \mathsf{*.f32}\left(\mathsf{PI.f32}\left(\right), \mathsf{/.f32}\left(0, 0\right)\right)\right), \mathsf{+.f32}\left(-1, \mathsf{*.f32}\left(cosTheta, \color{blue}{cosTheta}\right)\right)\right) \]
      4. Simplified-0.0%

        \[\leadsto \frac{\frac{1}{\pi \cdot \frac{0}{0}}}{-1 + \color{blue}{cosTheta \cdot cosTheta}} \]
      5. Add Preprocessing

      Reproduce

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