Trowbridge-Reitz Sample, near normal, slope_y

Percentage Accurate: 98.4% → 98.4%
Time: 10.3s
Alternatives: 13
Speedup: 1.0×

Specification

?
\[\left(\left(cosTheta\_i > 0.9999 \land cosTheta\_i \leq 1\right) \land \left(2.328306437 \cdot 10^{-10} \leq u1 \land u1 \leq 1\right)\right) \land \left(2.328306437 \cdot 10^{-10} \leq u2 \land u2 \leq 1\right)\]
\[\begin{array}{l} \\ \sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf((u1 / (1.0f - u1))) * sinf((6.28318530718f * u2));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = sqrt((u1 / (1.0e0 - u1))) * sin((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(Float32(6.28318530718) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt((u1 / (single(1.0) - u1))) * sin((single(6.28318530718) * u2));
end
\begin{array}{l}

\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right)
\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 13 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.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf((u1 / (1.0f - u1))) * sinf((6.28318530718f * u2));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = sqrt((u1 / (1.0e0 - u1))) * sin((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(Float32(6.28318530718) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt((u1 / (single(1.0) - u1))) * sin((single(6.28318530718) * u2));
end
\begin{array}{l}

\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right)
\end{array}

Alternative 1: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))
float code(float cosTheta_i, float u1, float u2) {
	return sqrtf((u1 / (1.0f - u1))) * sinf((6.28318530718f * u2));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = sqrt((u1 / (1.0e0 - u1))) * sin((6.28318530718e0 * u2))
end function
function code(cosTheta_i, u1, u2)
	return Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * sin(Float32(Float32(6.28318530718) * u2)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = sqrt((u1 / (single(1.0) - u1))) * sin((single(6.28318530718) * u2));
end
\begin{array}{l}

\\
\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 94.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;6.28318530718 \cdot u2 \leq 0.001500000013038516:\\ \;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (if (<= (* 6.28318530718 u2) 0.001500000013038516)
   (* u2 (sqrt (* (/ u1 (- 1.0 u1)) 39.47841760436263)))
   (* (sin (* 6.28318530718 u2)) (sqrt (* u1 (+ u1 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
	float tmp;
	if ((6.28318530718f * u2) <= 0.001500000013038516f) {
		tmp = u2 * sqrtf(((u1 / (1.0f - u1)) * 39.47841760436263f));
	} else {
		tmp = sinf((6.28318530718f * u2)) * sqrtf((u1 * (u1 + 1.0f)));
	}
	return tmp;
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    real(4) :: tmp
    if ((6.28318530718e0 * u2) <= 0.001500000013038516e0) then
        tmp = u2 * sqrt(((u1 / (1.0e0 - u1)) * 39.47841760436263e0))
    else
        tmp = sin((6.28318530718e0 * u2)) * sqrt((u1 * (u1 + 1.0e0)))
    end if
    code = tmp
end function
function code(cosTheta_i, u1, u2)
	tmp = Float32(0.0)
	if (Float32(Float32(6.28318530718) * u2) <= Float32(0.001500000013038516))
		tmp = Float32(u2 * sqrt(Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * Float32(39.47841760436263))));
	else
		tmp = Float32(sin(Float32(Float32(6.28318530718) * u2)) * sqrt(Float32(u1 * Float32(u1 + Float32(1.0)))));
	end
	return tmp
end
function tmp_2 = code(cosTheta_i, u1, u2)
	tmp = single(0.0);
	if ((single(6.28318530718) * u2) <= single(0.001500000013038516))
		tmp = u2 * sqrt(((u1 / (single(1.0) - u1)) * single(39.47841760436263)));
	else
		tmp = sin((single(6.28318530718) * u2)) * sqrt((u1 * (u1 + single(1.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;6.28318530718 \cdot u2 \leq 0.001500000013038516:\\
\;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\

\mathbf{else}:\\
\;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 #s(literal 314159265359/50000000000 binary32) u2) < 0.00150000001

    1. Initial program 98.6%

      \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    2. Add Preprocessing
    3. Taylor expanded in u2 around 0 98.1%

      \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
    4. Step-by-step derivation
      1. associate-*r*98.4%

        \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt97.9%

        \[\leadsto \color{blue}{\left(\sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}} \cdot \sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}}\right)} \cdot u2 \]
      2. sqrt-unprod98.4%

        \[\leadsto \color{blue}{\sqrt{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)}} \cdot u2 \]
      3. *-commutative98.4%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)} \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)} \cdot u2 \]
      4. *-commutative98.4%

        \[\leadsto \sqrt{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right) \cdot \color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)}} \cdot u2 \]
      5. swap-sqr98.1%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot 6.28318530718\right)}} \cdot u2 \]
      6. add-sqr-sqrt98.3%

        \[\leadsto \sqrt{\color{blue}{\frac{u1}{1 - u1}} \cdot \left(6.28318530718 \cdot 6.28318530718\right)} \cdot u2 \]
      7. metadata-eval98.8%

        \[\leadsto \sqrt{\frac{u1}{1 - u1} \cdot \color{blue}{39.47841760436263}} \cdot u2 \]
    7. Applied egg-rr98.8%

      \[\leadsto \color{blue}{\sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}} \cdot u2 \]

    if 0.00150000001 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2)

    1. Initial program 98.0%

      \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    2. Add Preprocessing
    3. Taylor expanded in u1 around 0 84.5%

      \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    4. Step-by-step derivation
      1. +-commutative84.5%

        \[\leadsto \sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    5. Simplified84.5%

      \[\leadsto \sqrt{\color{blue}{u1 \cdot \left(u1 + 1\right)}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;6.28318530718 \cdot u2 \leq 0.001500000013038516:\\ \;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 90.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;6.28318530718 \cdot u2 \leq 0.012000000104308128:\\ \;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}\\ \end{array} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (if (<= (* 6.28318530718 u2) 0.012000000104308128)
   (* u2 (sqrt (* (/ u1 (- 1.0 u1)) 39.47841760436263)))
   (* (sin (* 6.28318530718 u2)) (sqrt u1))))
float code(float cosTheta_i, float u1, float u2) {
	float tmp;
	if ((6.28318530718f * u2) <= 0.012000000104308128f) {
		tmp = u2 * sqrtf(((u1 / (1.0f - u1)) * 39.47841760436263f));
	} else {
		tmp = sinf((6.28318530718f * u2)) * sqrtf(u1);
	}
	return tmp;
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    real(4) :: tmp
    if ((6.28318530718e0 * u2) <= 0.012000000104308128e0) then
        tmp = u2 * sqrt(((u1 / (1.0e0 - u1)) * 39.47841760436263e0))
    else
        tmp = sin((6.28318530718e0 * u2)) * sqrt(u1)
    end if
    code = tmp
end function
function code(cosTheta_i, u1, u2)
	tmp = Float32(0.0)
	if (Float32(Float32(6.28318530718) * u2) <= Float32(0.012000000104308128))
		tmp = Float32(u2 * sqrt(Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * Float32(39.47841760436263))));
	else
		tmp = Float32(sin(Float32(Float32(6.28318530718) * u2)) * sqrt(u1));
	end
	return tmp
end
function tmp_2 = code(cosTheta_i, u1, u2)
	tmp = single(0.0);
	if ((single(6.28318530718) * u2) <= single(0.012000000104308128))
		tmp = u2 * sqrt(((u1 / (single(1.0) - u1)) * single(39.47841760436263)));
	else
		tmp = sin((single(6.28318530718) * u2)) * sqrt(u1);
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;6.28318530718 \cdot u2 \leq 0.012000000104308128:\\
\;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\

\mathbf{else}:\\
\;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f32 #s(literal 314159265359/50000000000 binary32) u2) < 0.0120000001

    1. Initial program 98.6%

      \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    2. Add Preprocessing
    3. Taylor expanded in u2 around 0 96.5%

      \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
    4. Step-by-step derivation
      1. associate-*r*96.7%

        \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
    5. Simplified96.7%

      \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt96.3%

        \[\leadsto \color{blue}{\left(\sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}} \cdot \sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}}\right)} \cdot u2 \]
      2. sqrt-unprod96.7%

        \[\leadsto \color{blue}{\sqrt{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)}} \cdot u2 \]
      3. *-commutative96.7%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)} \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)} \cdot u2 \]
      4. *-commutative96.7%

        \[\leadsto \sqrt{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right) \cdot \color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)}} \cdot u2 \]
      5. swap-sqr96.5%

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot 6.28318530718\right)}} \cdot u2 \]
      6. add-sqr-sqrt96.7%

        \[\leadsto \sqrt{\color{blue}{\frac{u1}{1 - u1}} \cdot \left(6.28318530718 \cdot 6.28318530718\right)} \cdot u2 \]
      7. metadata-eval97.1%

        \[\leadsto \sqrt{\frac{u1}{1 - u1} \cdot \color{blue}{39.47841760436263}} \cdot u2 \]
    7. Applied egg-rr97.1%

      \[\leadsto \color{blue}{\sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}} \cdot u2 \]

    if 0.0120000001 < (*.f32 #s(literal 314159265359/50000000000 binary32) u2)

    1. Initial program 97.7%

      \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
    2. Add Preprocessing
    3. Taylor expanded in u1 around 0 72.3%

      \[\leadsto \color{blue}{\sqrt{u1} \cdot \sin \left(6.28318530718 \cdot u2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;6.28318530718 \cdot u2 \leq 0.012000000104308128:\\ \;\;\;\;u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* u2 (sqrt (* (/ u1 (- 1.0 u1)) 39.47841760436263))))
float code(float cosTheta_i, float u1, float u2) {
	return u2 * sqrtf(((u1 / (1.0f - u1)) * 39.47841760436263f));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = u2 * sqrt(((u1 / (1.0e0 - u1)) * 39.47841760436263e0))
end function
function code(cosTheta_i, u1, u2)
	return Float32(u2 * sqrt(Float32(Float32(u1 / Float32(Float32(1.0) - u1)) * Float32(39.47841760436263))))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = u2 * sqrt(((u1 / (single(1.0) - u1)) * single(39.47841760436263)));
end
\begin{array}{l}

\\
u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Step-by-step derivation
    1. associate-*r*81.4%

      \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
  5. Simplified81.4%

    \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
  6. Step-by-step derivation
    1. add-sqr-sqrt81.1%

      \[\leadsto \color{blue}{\left(\sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}} \cdot \sqrt{6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}}\right)} \cdot u2 \]
    2. sqrt-unprod81.4%

      \[\leadsto \color{blue}{\sqrt{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)}} \cdot u2 \]
    3. *-commutative81.4%

      \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)} \cdot \left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right)} \cdot u2 \]
    4. *-commutative81.4%

      \[\leadsto \sqrt{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right) \cdot \color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot 6.28318530718\right)}} \cdot u2 \]
    5. swap-sqr81.2%

      \[\leadsto \sqrt{\color{blue}{\left(\sqrt{\frac{u1}{1 - u1}} \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot \left(6.28318530718 \cdot 6.28318530718\right)}} \cdot u2 \]
    6. add-sqr-sqrt81.4%

      \[\leadsto \sqrt{\color{blue}{\frac{u1}{1 - u1}} \cdot \left(6.28318530718 \cdot 6.28318530718\right)} \cdot u2 \]
    7. metadata-eval81.7%

      \[\leadsto \sqrt{\frac{u1}{1 - u1} \cdot \color{blue}{39.47841760436263}} \cdot u2 \]
  7. Applied egg-rr81.7%

    \[\leadsto \color{blue}{\sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263}} \cdot u2 \]
  8. Final simplification81.7%

    \[\leadsto u2 \cdot \sqrt{\frac{u1}{1 - u1} \cdot 39.47841760436263} \]
  9. Add Preprocessing

Alternative 5: 81.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* 6.28318530718 (* (sqrt (/ u1 (- 1.0 u1))) u2)))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (sqrtf((u1 / (1.0f - u1))) * u2);
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (sqrt((u1 / (1.0e0 - u1))) * u2)
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(sqrt(Float32(u1 / Float32(Float32(1.0) - u1))) * u2))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (sqrt((u1 / (single(1.0) - u1))) * u2);
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Add Preprocessing

Alternative 6: 73.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(u2 \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* 6.28318530718 (* u2 (sqrt (* u1 (+ u1 1.0))))))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (u2 * sqrtf((u1 * (u1 + 1.0f))));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (u2 * sqrt((u1 * (u1 + 1.0e0))))
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(u2 * sqrt(Float32(u1 * Float32(u1 + Float32(1.0))))))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (u2 * sqrt((u1 * (u1 + single(1.0)))));
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(u2 \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative86.3%

      \[\leadsto \sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(u1 + 1\right)}} \cdot u2\right) \]
  7. Final simplification73.6%

    \[\leadsto 6.28318530718 \cdot \left(u2 \cdot \sqrt{u1 \cdot \left(u1 + 1\right)}\right) \]
  8. Add Preprocessing

Alternative 7: 64.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ u2 \cdot \left(6.28318530718 \cdot \sqrt{u1}\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* u2 (* 6.28318530718 (sqrt u1))))
float code(float cosTheta_i, float u1, float u2) {
	return u2 * (6.28318530718f * sqrtf(u1));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = u2 * (6.28318530718e0 * sqrt(u1))
end function
function code(cosTheta_i, u1, u2)
	return Float32(u2 * Float32(Float32(6.28318530718) * sqrt(u1)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = u2 * (single(6.28318530718) * sqrt(u1));
end
\begin{array}{l}

\\
u2 \cdot \left(6.28318530718 \cdot \sqrt{u1}\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Step-by-step derivation
    1. associate-*r*81.4%

      \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
  5. Simplified81.4%

    \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{\frac{u1}{1 - u1}}\right) \cdot u2} \]
  6. Taylor expanded in u1 around 0 64.9%

    \[\leadsto \color{blue}{\left(6.28318530718 \cdot \sqrt{u1}\right)} \cdot u2 \]
  7. Step-by-step derivation
    1. *-commutative64.9%

      \[\leadsto \color{blue}{\left(\sqrt{u1} \cdot 6.28318530718\right)} \cdot u2 \]
  8. Simplified64.9%

    \[\leadsto \color{blue}{\left(\sqrt{u1} \cdot 6.28318530718\right)} \cdot u2 \]
  9. Final simplification64.9%

    \[\leadsto u2 \cdot \left(6.28318530718 \cdot \sqrt{u1}\right) \]
  10. Add Preprocessing

Alternative 8: 64.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1} \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* (* 6.28318530718 u2) (sqrt u1)))
float code(float cosTheta_i, float u1, float u2) {
	return (6.28318530718f * u2) * sqrtf(u1);
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = (6.28318530718e0 * u2) * sqrt(u1)
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(Float32(6.28318530718) * u2) * sqrt(u1))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = (single(6.28318530718) * u2) * sqrt(u1);
end
\begin{array}{l}

\\
\left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot u2\right) \]
    2. distribute-lft-in73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot u1 + u1 \cdot 1}} \cdot u2\right) \]
    3. *-rgt-identity73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot u1 + \color{blue}{u1}} \cdot u2\right) \]
    4. fma-define73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  7. Taylor expanded in u1 around 0 64.9%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{u1} \cdot u2\right)} \]
  8. Step-by-step derivation
    1. *-commutative64.9%

      \[\leadsto 6.28318530718 \cdot \color{blue}{\left(u2 \cdot \sqrt{u1}\right)} \]
    2. associate-*l*64.9%

      \[\leadsto \color{blue}{\left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1}} \]
    3. *-commutative64.9%

      \[\leadsto \color{blue}{\sqrt{u1} \cdot \left(6.28318530718 \cdot u2\right)} \]
  9. Simplified64.9%

    \[\leadsto \color{blue}{\sqrt{u1} \cdot \left(6.28318530718 \cdot u2\right)} \]
  10. Final simplification64.9%

    \[\leadsto \left(6.28318530718 \cdot u2\right) \cdot \sqrt{u1} \]
  11. Add Preprocessing

Alternative 9: 64.7% accurate, 2.0× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(u2 \cdot \sqrt{u1}\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* 6.28318530718 (* u2 (sqrt u1))))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (u2 * sqrtf(u1));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (u2 * sqrt(u1))
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(u2 * sqrt(u1)))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (u2 * sqrt(u1));
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(u2 \cdot \sqrt{u1}\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 64.9%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{u1} \cdot u2\right)} \]
  5. Final simplification64.9%

    \[\leadsto 6.28318530718 \cdot \left(u2 \cdot \sqrt{u1}\right) \]
  6. Add Preprocessing

Alternative 10: 20.6% accurate, 19.0× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(u2 \cdot \left(u1 \cdot \left(1 + \frac{0.5}{u1}\right)\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* 6.28318530718 (* u2 (* u1 (+ 1.0 (/ 0.5 u1))))))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (u2 * (u1 * (1.0f + (0.5f / u1))));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (u2 * (u1 * (1.0e0 + (0.5e0 / u1))))
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(u2 * Float32(u1 * Float32(Float32(1.0) + Float32(Float32(0.5) / u1)))))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (u2 * (u1 * (single(1.0) + (single(0.5) / u1))));
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(u2 \cdot \left(u1 \cdot \left(1 + \frac{0.5}{u1}\right)\right)\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot u2\right) \]
    2. distribute-lft-in73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot u1 + u1 \cdot 1}} \cdot u2\right) \]
    3. *-rgt-identity73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot u1 + \color{blue}{u1}} \cdot u2\right) \]
    4. fma-define73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  7. Taylor expanded in u1 around inf 20.2%

    \[\leadsto 6.28318530718 \cdot \left(\color{blue}{\left(u1 \cdot \left(1 + 0.5 \cdot \frac{1}{u1}\right)\right)} \cdot u2\right) \]
  8. Step-by-step derivation
    1. associate-*r/20.2%

      \[\leadsto 6.28318530718 \cdot \left(\left(u1 \cdot \left(1 + \color{blue}{\frac{0.5 \cdot 1}{u1}}\right)\right) \cdot u2\right) \]
    2. metadata-eval20.2%

      \[\leadsto 6.28318530718 \cdot \left(\left(u1 \cdot \left(1 + \frac{\color{blue}{0.5}}{u1}\right)\right) \cdot u2\right) \]
  9. Simplified20.2%

    \[\leadsto 6.28318530718 \cdot \left(\color{blue}{\left(u1 \cdot \left(1 + \frac{0.5}{u1}\right)\right)} \cdot u2\right) \]
  10. Final simplification20.2%

    \[\leadsto 6.28318530718 \cdot \left(u2 \cdot \left(u1 \cdot \left(1 + \frac{0.5}{u1}\right)\right)\right) \]
  11. Add Preprocessing

Alternative 11: 20.6% accurate, 19.0× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(u1 \cdot \left(u2 + 0.5 \cdot \frac{u2}{u1}\right)\right) \end{array} \]
(FPCore (cosTheta_i u1 u2)
 :precision binary32
 (* 6.28318530718 (* u1 (+ u2 (* 0.5 (/ u2 u1))))))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (u1 * (u2 + (0.5f * (u2 / u1))));
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (u1 * (u2 + (0.5e0 * (u2 / u1))))
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(u1 * Float32(u2 + Float32(Float32(0.5) * Float32(u2 / u1)))))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (u1 * (u2 + (single(0.5) * (u2 / u1))));
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(u1 \cdot \left(u2 + 0.5 \cdot \frac{u2}{u1}\right)\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot u2\right) \]
    2. distribute-lft-in73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot u1 + u1 \cdot 1}} \cdot u2\right) \]
    3. *-rgt-identity73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot u1 + \color{blue}{u1}} \cdot u2\right) \]
    4. fma-define73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  7. Taylor expanded in u1 around inf 20.2%

    \[\leadsto 6.28318530718 \cdot \color{blue}{\left(u1 \cdot \left(u2 + 0.5 \cdot \frac{u2}{u1}\right)\right)} \]
  8. Add Preprocessing

Alternative 12: 19.4% accurate, 41.8× speedup?

\[\begin{array}{l} \\ 6.28318530718 \cdot \left(u1 \cdot u2\right) \end{array} \]
(FPCore (cosTheta_i u1 u2) :precision binary32 (* 6.28318530718 (* u1 u2)))
float code(float cosTheta_i, float u1, float u2) {
	return 6.28318530718f * (u1 * u2);
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = 6.28318530718e0 * (u1 * u2)
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(6.28318530718) * Float32(u1 * u2))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = single(6.28318530718) * (u1 * u2);
end
\begin{array}{l}

\\
6.28318530718 \cdot \left(u1 \cdot u2\right)
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot u2\right) \]
    2. distribute-lft-in73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot u1 + u1 \cdot 1}} \cdot u2\right) \]
    3. *-rgt-identity73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot u1 + \color{blue}{u1}} \cdot u2\right) \]
    4. fma-define73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  7. Taylor expanded in u1 around inf 19.2%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(u1 \cdot u2\right)} \]
  8. Add Preprocessing

Alternative 13: 4.7% accurate, 41.8× speedup?

\[\begin{array}{l} \\ \left(u1 \cdot u2\right) \cdot -6.28318530718 \end{array} \]
(FPCore (cosTheta_i u1 u2) :precision binary32 (* (* u1 u2) -6.28318530718))
float code(float cosTheta_i, float u1, float u2) {
	return (u1 * u2) * -6.28318530718f;
}
real(4) function code(costheta_i, u1, u2)
    real(4), intent (in) :: costheta_i
    real(4), intent (in) :: u1
    real(4), intent (in) :: u2
    code = (u1 * u2) * (-6.28318530718e0)
end function
function code(cosTheta_i, u1, u2)
	return Float32(Float32(u1 * u2) * Float32(-6.28318530718))
end
function tmp = code(cosTheta_i, u1, u2)
	tmp = (u1 * u2) * single(-6.28318530718);
end
\begin{array}{l}

\\
\left(u1 \cdot u2\right) \cdot -6.28318530718
\end{array}
Derivation
  1. Initial program 98.4%

    \[\sqrt{\frac{u1}{1 - u1}} \cdot \sin \left(6.28318530718 \cdot u2\right) \]
  2. Add Preprocessing
  3. Taylor expanded in u2 around 0 81.3%

    \[\leadsto \color{blue}{6.28318530718 \cdot \left(\sqrt{\frac{u1}{1 - u1}} \cdot u2\right)} \]
  4. Taylor expanded in u1 around 0 73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot \left(1 + u1\right)}} \cdot u2\right) \]
  5. Step-by-step derivation
    1. +-commutative73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot \color{blue}{\left(u1 + 1\right)}} \cdot u2\right) \]
    2. distribute-lft-in73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{u1 \cdot u1 + u1 \cdot 1}} \cdot u2\right) \]
    3. *-rgt-identity73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{u1 \cdot u1 + \color{blue}{u1}} \cdot u2\right) \]
    4. fma-define73.6%

      \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  6. Simplified73.6%

    \[\leadsto 6.28318530718 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(u1, u1, u1\right)}} \cdot u2\right) \]
  7. Taylor expanded in u1 around -inf 4.9%

    \[\leadsto \color{blue}{-6.28318530718 \cdot \left(u1 \cdot u2\right)} \]
  8. Final simplification4.9%

    \[\leadsto \left(u1 \cdot u2\right) \cdot -6.28318530718 \]
  9. Add Preprocessing

Reproduce

?
herbie shell --seed 2024150 
(FPCore (cosTheta_i u1 u2)
  :name "Trowbridge-Reitz Sample, near normal, slope_y"
  :precision binary32
  :pre (and (and (and (> cosTheta_i 0.9999) (<= cosTheta_i 1.0)) (and (<= 2.328306437e-10 u1) (<= u1 1.0))) (and (<= 2.328306437e-10 u2) (<= u2 1.0)))
  (* (sqrt (/ u1 (- 1.0 u1))) (sin (* 6.28318530718 u2))))