HairBSDF, sample_f, cosTheta

Percentage Accurate: 99.5% → 99.5%
Time: 11.8s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\left(10^{-5} \leq u \land u \leq 1\right) \land \left(0 \leq v \land v \leq 109.746574\right)\]
\[\begin{array}{l} \\ 1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \end{array} \]
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
float code(float u, float v) {
	return 1.0f + (v * logf((u + ((1.0f - u) * expf((-2.0f / v))))));
}
real(4) function code(u, v)
    real(4), intent (in) :: u
    real(4), intent (in) :: v
    code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))
end function
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))))
end
function tmp = code(u, v)
	tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v))))));
end
\begin{array}{l}

\\
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\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 8 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: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \end{array} \]
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
float code(float u, float v) {
	return 1.0f + (v * logf((u + ((1.0f - u) * expf((-2.0f / v))))));
}
real(4) function code(u, v)
    real(4), intent (in) :: u
    real(4), intent (in) :: v
    code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))
end function
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))))
end
function tmp = code(u, v)
	tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v))))));
end
\begin{array}{l}

\\
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
\end{array}

Alternative 1: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \end{array} \]
(FPCore (u v)
 :precision binary32
 (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))
float code(float u, float v) {
	return 1.0f + (v * logf((u + ((1.0f - u) * expf((-2.0f / v))))));
}
real(4) function code(u, v)
    real(4), intent (in) :: u
    real(4), intent (in) :: v
    code = 1.0e0 + (v * log((u + ((1.0e0 - u) * exp(((-2.0e0) / v))))))
end function
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(Float32(u + Float32(Float32(Float32(1.0) - u) * exp(Float32(Float32(-2.0) / v)))))))
end
function tmp = code(u, v)
	tmp = single(1.0) + (v * log((u + ((single(1.0) - u) * exp((single(-2.0) / v))))));
end
\begin{array}{l}

\\
1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 95.2% accurate, 1.7× speedup?

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

\\
1 + v \cdot \log \left(u + \frac{1 - u}{1 + \frac{\frac{2 + \frac{1.3333333333333333}{v}}{v} - -2}{v}}\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) + \color{blue}{1} \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right), 1\right) \]
    4. log-lowering-log.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right)\right), 1\right) \]
    5. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right)\right)\right), 1\right) \]
    6. frac-2negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(v\right)}}\right)\right)\right)\right), 1\right) \]
    7. distribute-frac-neg2N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(-2\right)}{v}\right)}\right)\right)\right)\right), 1\right) \]
    8. exp-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot \frac{1}{e^{\frac{\mathsf{neg}\left(-2\right)}{v}}}\right)\right)\right)\right), 1\right) \]
    9. un-div-invN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\frac{1 - u}{e^{\frac{\mathsf{neg}\left(-2\right)}{v}}}\right)\right)\right)\right), 1\right) \]
    10. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\left(1 - u\right), \left(e^{\frac{\mathsf{neg}\left(-2\right)}{v}}\right)\right)\right)\right)\right), 1\right) \]
    11. --lowering--.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(e^{\frac{\mathsf{neg}\left(-2\right)}{v}}\right)\right)\right)\right)\right), 1\right) \]
    12. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(-2\right)}{v}\right)\right)\right)\right)\right)\right), 1\right) \]
    13. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\mathsf{neg}\left(-2\right)\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    14. metadata-eval99.4%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(2, v\right)\right)\right)\right)\right)\right), 1\right) \]
  4. Applied egg-rr99.4%

    \[\leadsto \color{blue}{v \cdot \log \left(u + \frac{1 - u}{e^{\frac{2}{v}}}\right) + 1} \]
  5. Taylor expanded in v around -inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)}\right)\right)\right)\right), 1\right) \]
  6. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right)\right)\right), 1\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(1 - \frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right), 1\right) \]
    3. --lowering--.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right)\right), 1\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} + \left(\mathsf{neg}\left(2\right)\right)\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} + -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    7. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    8. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\mathsf{neg}\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v}\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    9. distribute-neg-frac2N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{\mathsf{neg}\left(v\right)}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    10. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{-1 \cdot v}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    11. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(2 + \frac{4}{3} \cdot \frac{1}{v}\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    12. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{4}{3} \cdot \frac{1}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    13. associate-*r/N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{\frac{4}{3} \cdot 1}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{\frac{4}{3}}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    15. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    16. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \left(\mathsf{neg}\left(v\right)\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    17. neg-lowering-neg.f3295.5%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \mathsf{neg.f32}\left(v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
  7. Simplified95.5%

    \[\leadsto v \cdot \log \left(u + \frac{1 - u}{\color{blue}{1 - \frac{\frac{2 + \frac{1.3333333333333333}{v}}{-v} + -2}{v}}}\right) + 1 \]
  8. Final simplification95.5%

    \[\leadsto 1 + v \cdot \log \left(u + \frac{1 - u}{1 + \frac{\frac{2 + \frac{1.3333333333333333}{v}}{v} - -2}{v}}\right) \]
  9. Add Preprocessing

Alternative 3: 94.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ 1 + v \cdot \log u \end{array} \]
(FPCore (u v) :precision binary32 (+ 1.0 (* v (log u))))
float code(float u, float v) {
	return 1.0f + (v * logf(u));
}
real(4) function code(u, v)
    real(4), intent (in) :: u
    real(4), intent (in) :: v
    code = 1.0e0 + (v * log(u))
end function
function code(u, v)
	return Float32(Float32(1.0) + Float32(v * log(u)))
end
function tmp = code(u, v)
	tmp = single(1.0) + (v * log(u));
end
\begin{array}{l}

\\
1 + v \cdot \log u
\end{array}
Derivation
  1. Initial program 99.4%

    \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) + \color{blue}{1} \]
    2. +-lowering-+.f32N/A

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

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right), 1\right) \]
    4. log-lowering-log.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right)\right), 1\right) \]
    5. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\frac{-2}{v}}\right)\right)\right)\right), 1\right) \]
    6. frac-2negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(v\right)}}\right)\right)\right)\right), 1\right) \]
    7. distribute-frac-neg2N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(-2\right)}{v}\right)}\right)\right)\right)\right), 1\right) \]
    8. exp-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\left(1 - u\right) \cdot \frac{1}{e^{\frac{\mathsf{neg}\left(-2\right)}{v}}}\right)\right)\right)\right), 1\right) \]
    9. un-div-invN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \left(\frac{1 - u}{e^{\frac{\mathsf{neg}\left(-2\right)}{v}}}\right)\right)\right)\right), 1\right) \]
    10. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\left(1 - u\right), \left(e^{\frac{\mathsf{neg}\left(-2\right)}{v}}\right)\right)\right)\right)\right), 1\right) \]
    11. --lowering--.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(e^{\frac{\mathsf{neg}\left(-2\right)}{v}}\right)\right)\right)\right)\right), 1\right) \]
    12. exp-lowering-exp.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\left(\frac{\mathsf{neg}\left(-2\right)}{v}\right)\right)\right)\right)\right)\right), 1\right) \]
    13. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(\left(\mathsf{neg}\left(-2\right)\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    14. metadata-eval99.4%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{exp.f32}\left(\mathsf{/.f32}\left(2, v\right)\right)\right)\right)\right)\right), 1\right) \]
  4. Applied egg-rr99.4%

    \[\leadsto \color{blue}{v \cdot \log \left(u + \frac{1 - u}{e^{\frac{2}{v}}}\right) + 1} \]
  5. Taylor expanded in v around -inf

    \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \color{blue}{\left(1 + -1 \cdot \frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)}\right)\right)\right)\right), 1\right) \]
  6. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(1 + \left(\mathsf{neg}\left(\frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right)\right)\right), 1\right) \]
    2. unsub-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \left(1 - \frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right), 1\right) \]
    3. --lowering--.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \left(\frac{-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2}{v}\right)\right)\right)\right)\right)\right), 1\right) \]
    4. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} - 2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} + \left(\mathsf{neg}\left(2\right)\right)\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v} + -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    7. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(-1 \cdot \frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    8. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\mathsf{neg}\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{v}\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    9. distribute-neg-frac2N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{\mathsf{neg}\left(v\right)}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    10. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\left(\frac{2 + \frac{4}{3} \cdot \frac{1}{v}}{-1 \cdot v}\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    11. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\left(2 + \frac{4}{3} \cdot \frac{1}{v}\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    12. +-lowering-+.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{4}{3} \cdot \frac{1}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    13. associate-*r/N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{\frac{4}{3} \cdot 1}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    14. metadata-evalN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \left(\frac{\frac{4}{3}}{v}\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    15. /-lowering-/.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \left(-1 \cdot v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    16. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \left(\mathsf{neg}\left(v\right)\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
    17. neg-lowering-neg.f3295.5%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(\mathsf{+.f32}\left(u, \mathsf{/.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{/.f32}\left(\mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\frac{4}{3}, v\right)\right), \mathsf{neg.f32}\left(v\right)\right), -2\right), v\right)\right)\right)\right)\right)\right), 1\right) \]
  7. Simplified95.5%

    \[\leadsto v \cdot \log \left(u + \frac{1 - u}{\color{blue}{1 - \frac{\frac{2 + \frac{1.3333333333333333}{v}}{-v} + -2}{v}}}\right) + 1 \]
  8. Taylor expanded in v around 0

    \[\leadsto \mathsf{+.f32}\left(\color{blue}{\left(v \cdot \log u\right)}, 1\right) \]
  9. Step-by-step derivation
    1. remove-double-negN/A

      \[\leadsto \mathsf{+.f32}\left(\left(v \cdot \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log u\right)\right)\right)\right)\right), 1\right) \]
    2. log-recN/A

      \[\leadsto \mathsf{+.f32}\left(\left(v \cdot \left(\mathsf{neg}\left(\log \left(\frac{1}{u}\right)\right)\right)\right), 1\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\left(v \cdot \left(-1 \cdot \log \left(\frac{1}{u}\right)\right)\right), 1\right) \]
    4. *-lowering-*.f32N/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \left(-1 \cdot \log \left(\frac{1}{u}\right)\right)\right), 1\right) \]
    5. mul-1-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \left(\mathsf{neg}\left(\log \left(\frac{1}{u}\right)\right)\right)\right), 1\right) \]
    6. log-recN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\log u\right)\right)\right)\right)\right), 1\right) \]
    7. remove-double-negN/A

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \log u\right), 1\right) \]
    8. log-lowering-log.f3295.0%

      \[\leadsto \mathsf{+.f32}\left(\mathsf{*.f32}\left(v, \mathsf{log.f32}\left(u\right)\right), 1\right) \]
  10. Simplified95.0%

    \[\leadsto \color{blue}{v \cdot \log u} + 1 \]
  11. Final simplification95.0%

    \[\leadsto 1 + v \cdot \log u \]
  12. Add Preprocessing

Alternative 4: 91.3% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\left(1 - u\right) \cdot -2 + \frac{\frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(u \cdot \left(16 + u \cdot \left(u \cdot \left(192 + u \cdot -96\right) + -112\right)\right)\right)}{v}}{v} + -0.5 \cdot \left(\left(1 - u\right) \cdot \left(-4 \cdot \left(u + -1\right) - 4\right)\right)}{v}\right)\\ \end{array} \end{array} \]
(FPCore (u v)
 :precision binary32
 (if (<= v 0.10000000149011612)
   1.0
   (+
    1.0
    (+
     (* (- 1.0 u) -2.0)
     (/
      (+
       (/
        (+
         (*
          (+
           (* (- 1.0 u) 8.0)
           (* (* (- 1.0 u) (- 1.0 u)) (+ (* (- 1.0 u) 16.0) -24.0)))
          -0.16666666666666666)
         (/
          (*
           0.041666666666666664
           (* u (+ 16.0 (* u (+ (* u (+ 192.0 (* u -96.0))) -112.0)))))
          v))
        v)
       (* -0.5 (* (- 1.0 u) (- (* -4.0 (+ u -1.0)) 4.0))))
      v)))))
float code(float u, float v) {
	float tmp;
	if (v <= 0.10000000149011612f) {
		tmp = 1.0f;
	} else {
		tmp = 1.0f + (((1.0f - u) * -2.0f) + ((((((((1.0f - u) * 8.0f) + (((1.0f - u) * (1.0f - u)) * (((1.0f - u) * 16.0f) + -24.0f))) * -0.16666666666666666f) + ((0.041666666666666664f * (u * (16.0f + (u * ((u * (192.0f + (u * -96.0f))) + -112.0f))))) / v)) / v) + (-0.5f * ((1.0f - u) * ((-4.0f * (u + -1.0f)) - 4.0f)))) / v));
	}
	return tmp;
}
real(4) function code(u, v)
    real(4), intent (in) :: u
    real(4), intent (in) :: v
    real(4) :: tmp
    if (v <= 0.10000000149011612e0) then
        tmp = 1.0e0
    else
        tmp = 1.0e0 + (((1.0e0 - u) * (-2.0e0)) + ((((((((1.0e0 - u) * 8.0e0) + (((1.0e0 - u) * (1.0e0 - u)) * (((1.0e0 - u) * 16.0e0) + (-24.0e0)))) * (-0.16666666666666666e0)) + ((0.041666666666666664e0 * (u * (16.0e0 + (u * ((u * (192.0e0 + (u * (-96.0e0)))) + (-112.0e0)))))) / v)) / v) + ((-0.5e0) * ((1.0e0 - u) * (((-4.0e0) * (u + (-1.0e0))) - 4.0e0)))) / v))
    end if
    code = tmp
end function
function code(u, v)
	tmp = Float32(0.0)
	if (v <= Float32(0.10000000149011612))
		tmp = Float32(1.0);
	else
		tmp = Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) - u) * Float32(-2.0)) + Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(1.0) - u) * Float32(8.0)) + Float32(Float32(Float32(Float32(1.0) - u) * Float32(Float32(1.0) - u)) * Float32(Float32(Float32(Float32(1.0) - u) * Float32(16.0)) + Float32(-24.0)))) * Float32(-0.16666666666666666)) + Float32(Float32(Float32(0.041666666666666664) * Float32(u * Float32(Float32(16.0) + Float32(u * Float32(Float32(u * Float32(Float32(192.0) + Float32(u * Float32(-96.0)))) + Float32(-112.0)))))) / v)) / v) + Float32(Float32(-0.5) * Float32(Float32(Float32(1.0) - u) * Float32(Float32(Float32(-4.0) * Float32(u + Float32(-1.0))) - Float32(4.0))))) / v)));
	end
	return tmp
end
function tmp_2 = code(u, v)
	tmp = single(0.0);
	if (v <= single(0.10000000149011612))
		tmp = single(1.0);
	else
		tmp = single(1.0) + (((single(1.0) - u) * single(-2.0)) + ((((((((single(1.0) - u) * single(8.0)) + (((single(1.0) - u) * (single(1.0) - u)) * (((single(1.0) - u) * single(16.0)) + single(-24.0)))) * single(-0.16666666666666666)) + ((single(0.041666666666666664) * (u * (single(16.0) + (u * ((u * (single(192.0) + (u * single(-96.0)))) + single(-112.0)))))) / v)) / v) + (single(-0.5) * ((single(1.0) - u) * ((single(-4.0) * (u + single(-1.0))) - single(4.0))))) / v));
	end
	tmp_2 = tmp;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;v \leq 0.10000000149011612:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;1 + \left(\left(1 - u\right) \cdot -2 + \frac{\frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(u \cdot \left(16 + u \cdot \left(u \cdot \left(192 + u \cdot -96\right) + -112\right)\right)\right)}{v}}{v} + -0.5 \cdot \left(\left(1 - u\right) \cdot \left(-4 \cdot \left(u + -1\right) - 4\right)\right)}{v}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if v < 0.100000001

    1. Initial program 100.0%

      \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in v around 0

      \[\leadsto \color{blue}{1} \]
    4. Step-by-step derivation
      1. Simplified93.0%

        \[\leadsto \color{blue}{1} \]

      if 0.100000001 < v

      1. Initial program 91.9%

        \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in v around -inf

        \[\leadsto \mathsf{+.f32}\left(1, \color{blue}{\left(-2 \cdot \left(1 - u\right) + -1 \cdot \frac{-1 \cdot \frac{\frac{-1}{6} \cdot \left(-24 \cdot {\left(1 - u\right)}^{2} + \left(8 \cdot \left(1 - u\right) + 16 \cdot {\left(1 - u\right)}^{3}\right)\right) + \frac{1}{24} \cdot \frac{-96 \cdot {\left(1 - u\right)}^{4} + \left(-64 \cdot {\left(1 - u\right)}^{2} + \left(-48 \cdot {\left(1 - u\right)}^{2} + \left(16 \cdot \left(1 - u\right) + 192 \cdot {\left(1 - u\right)}^{3}\right)\right)\right)}{v}}{v} + \frac{-1}{2} \cdot \left(-4 \cdot {\left(1 - u\right)}^{2} + 4 \cdot \left(1 - u\right)\right)}{v}\right)}\right) \]
      4. Simplified65.4%

        \[\leadsto 1 + \color{blue}{\left(-2 \cdot \left(1 - u\right) - \frac{\left(\left(1 - u\right) \cdot \left(\left(1 - u\right) \cdot -4 + 4\right)\right) \cdot -0.5 - \frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(\left(-96 \cdot {\left(1 - u\right)}^{4} + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(-112 + \left(1 - u\right) \cdot 192\right)\right) + \left(1 - u\right) \cdot 16\right)}{v}}{v}}{v}\right)} \]
      5. Taylor expanded in u around 0

        \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \color{blue}{\left(u \cdot \left(16 + u \cdot \left(u \cdot \left(192 + -96 \cdot u\right) - 112\right)\right)\right)}\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
      6. Step-by-step derivation
        1. *-lowering-*.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \left(16 + u \cdot \left(u \cdot \left(192 + -96 \cdot u\right) - 112\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        2. +-lowering-+.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \left(u \cdot \left(u \cdot \left(192 + -96 \cdot u\right) - 112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        3. *-lowering-*.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \left(u \cdot \left(192 + -96 \cdot u\right) - 112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        4. sub-negN/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \left(u \cdot \left(192 + -96 \cdot u\right) + \left(\mathsf{neg}\left(112\right)\right)\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \left(u \cdot \left(192 + -96 \cdot u\right) + -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        6. +-lowering-+.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\left(u \cdot \left(192 + -96 \cdot u\right)\right), -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        7. *-lowering-*.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \left(192 + -96 \cdot u\right)\right), -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        8. +-lowering-+.f32N/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(192, \left(-96 \cdot u\right)\right)\right), -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        9. *-commutativeN/A

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(192, \left(u \cdot -96\right)\right)\right), -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
        10. *-lowering-*.f3265.4%

          \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(16, \mathsf{*.f32}\left(u, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(192, \mathsf{*.f32}\left(u, -96\right)\right)\right), -112\right)\right)\right)\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
      7. Simplified65.4%

        \[\leadsto 1 + \left(-2 \cdot \left(1 - u\right) - \frac{\left(\left(1 - u\right) \cdot \left(\left(1 - u\right) \cdot -4 + 4\right)\right) \cdot -0.5 - \frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \color{blue}{\left(u \cdot \left(16 + u \cdot \left(u \cdot \left(192 + u \cdot -96\right) + -112\right)\right)\right)}}{v}}{v}}{v}\right) \]
    5. Recombined 2 regimes into one program.
    6. Final simplification91.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(\left(1 - u\right) \cdot -2 + \frac{\frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(u \cdot \left(16 + u \cdot \left(u \cdot \left(192 + u \cdot -96\right) + -112\right)\right)\right)}{v}}{v} + -0.5 \cdot \left(\left(1 - u\right) \cdot \left(-4 \cdot \left(u + -1\right) - 4\right)\right)}{v}\right)\\ \end{array} \]
    7. Add Preprocessing

    Alternative 5: 91.2% accurate, 3.2× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := v \cdot \left(v \cdot v\right)\\ \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(-2 + u \cdot \left(\left(2 + \left(\frac{0.6666666666666666}{t\_0} + \left(\frac{2}{v} + \frac{1.3333333333333333}{v \cdot v}\right)\right)\right) + u \cdot \left(u \cdot \left(\frac{2.6666666666666665}{v \cdot v} + \frac{8}{t\_0}\right) - \left(\frac{2}{v} + \left(\frac{4}{v \cdot v} + \frac{4.666666666666667}{t\_0}\right)\right)\right)\right)\right)\\ \end{array} \end{array} \]
    (FPCore (u v)
     :precision binary32
     (let* ((t_0 (* v (* v v))))
       (if (<= v 0.10000000149011612)
         1.0
         (+
          1.0
          (+
           -2.0
           (*
            u
            (+
             (+
              2.0
              (+
               (/ 0.6666666666666666 t_0)
               (+ (/ 2.0 v) (/ 1.3333333333333333 (* v v)))))
             (*
              u
              (-
               (* u (+ (/ 2.6666666666666665 (* v v)) (/ 8.0 t_0)))
               (+ (/ 2.0 v) (+ (/ 4.0 (* v v)) (/ 4.666666666666667 t_0))))))))))))
    float code(float u, float v) {
    	float t_0 = v * (v * v);
    	float tmp;
    	if (v <= 0.10000000149011612f) {
    		tmp = 1.0f;
    	} else {
    		tmp = 1.0f + (-2.0f + (u * ((2.0f + ((0.6666666666666666f / t_0) + ((2.0f / v) + (1.3333333333333333f / (v * v))))) + (u * ((u * ((2.6666666666666665f / (v * v)) + (8.0f / t_0))) - ((2.0f / v) + ((4.0f / (v * v)) + (4.666666666666667f / t_0))))))));
    	}
    	return tmp;
    }
    
    real(4) function code(u, v)
        real(4), intent (in) :: u
        real(4), intent (in) :: v
        real(4) :: t_0
        real(4) :: tmp
        t_0 = v * (v * v)
        if (v <= 0.10000000149011612e0) then
            tmp = 1.0e0
        else
            tmp = 1.0e0 + ((-2.0e0) + (u * ((2.0e0 + ((0.6666666666666666e0 / t_0) + ((2.0e0 / v) + (1.3333333333333333e0 / (v * v))))) + (u * ((u * ((2.6666666666666665e0 / (v * v)) + (8.0e0 / t_0))) - ((2.0e0 / v) + ((4.0e0 / (v * v)) + (4.666666666666667e0 / t_0))))))))
        end if
        code = tmp
    end function
    
    function code(u, v)
    	t_0 = Float32(v * Float32(v * v))
    	tmp = Float32(0.0)
    	if (v <= Float32(0.10000000149011612))
    		tmp = Float32(1.0);
    	else
    		tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) + Float32(u * Float32(Float32(Float32(2.0) + Float32(Float32(Float32(0.6666666666666666) / t_0) + Float32(Float32(Float32(2.0) / v) + Float32(Float32(1.3333333333333333) / Float32(v * v))))) + Float32(u * Float32(Float32(u * Float32(Float32(Float32(2.6666666666666665) / Float32(v * v)) + Float32(Float32(8.0) / t_0))) - Float32(Float32(Float32(2.0) / v) + Float32(Float32(Float32(4.0) / Float32(v * v)) + Float32(Float32(4.666666666666667) / t_0)))))))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(u, v)
    	t_0 = v * (v * v);
    	tmp = single(0.0);
    	if (v <= single(0.10000000149011612))
    		tmp = single(1.0);
    	else
    		tmp = single(1.0) + (single(-2.0) + (u * ((single(2.0) + ((single(0.6666666666666666) / t_0) + ((single(2.0) / v) + (single(1.3333333333333333) / (v * v))))) + (u * ((u * ((single(2.6666666666666665) / (v * v)) + (single(8.0) / t_0))) - ((single(2.0) / v) + ((single(4.0) / (v * v)) + (single(4.666666666666667) / t_0))))))));
    	end
    	tmp_2 = tmp;
    end
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := v \cdot \left(v \cdot v\right)\\
    \mathbf{if}\;v \leq 0.10000000149011612:\\
    \;\;\;\;1\\
    
    \mathbf{else}:\\
    \;\;\;\;1 + \left(-2 + u \cdot \left(\left(2 + \left(\frac{0.6666666666666666}{t\_0} + \left(\frac{2}{v} + \frac{1.3333333333333333}{v \cdot v}\right)\right)\right) + u \cdot \left(u \cdot \left(\frac{2.6666666666666665}{v \cdot v} + \frac{8}{t\_0}\right) - \left(\frac{2}{v} + \left(\frac{4}{v \cdot v} + \frac{4.666666666666667}{t\_0}\right)\right)\right)\right)\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if v < 0.100000001

      1. Initial program 100.0%

        \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
      2. Add Preprocessing
      3. Taylor expanded in v around 0

        \[\leadsto \color{blue}{1} \]
      4. Step-by-step derivation
        1. Simplified93.0%

          \[\leadsto \color{blue}{1} \]

        if 0.100000001 < v

        1. Initial program 91.9%

          \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in v around -inf

          \[\leadsto \mathsf{+.f32}\left(1, \color{blue}{\left(-2 \cdot \left(1 - u\right) + -1 \cdot \frac{-1 \cdot \frac{\frac{-1}{6} \cdot \left(-24 \cdot {\left(1 - u\right)}^{2} + \left(8 \cdot \left(1 - u\right) + 16 \cdot {\left(1 - u\right)}^{3}\right)\right) + \frac{1}{24} \cdot \frac{-96 \cdot {\left(1 - u\right)}^{4} + \left(-64 \cdot {\left(1 - u\right)}^{2} + \left(-48 \cdot {\left(1 - u\right)}^{2} + \left(16 \cdot \left(1 - u\right) + 192 \cdot {\left(1 - u\right)}^{3}\right)\right)\right)}{v}}{v} + \frac{-1}{2} \cdot \left(-4 \cdot {\left(1 - u\right)}^{2} + 4 \cdot \left(1 - u\right)\right)}{v}\right)}\right) \]
        4. Simplified65.4%

          \[\leadsto 1 + \color{blue}{\left(-2 \cdot \left(1 - u\right) - \frac{\left(\left(1 - u\right) \cdot \left(\left(1 - u\right) \cdot -4 + 4\right)\right) \cdot -0.5 - \frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(\left(-96 \cdot {\left(1 - u\right)}^{4} + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(-112 + \left(1 - u\right) \cdot 192\right)\right) + \left(1 - u\right) \cdot 16\right)}{v}}{v}}{v}\right)} \]
        5. Taylor expanded in u around 0

          \[\leadsto \mathsf{+.f32}\left(1, \color{blue}{\left(u \cdot \left(2 + \left(\frac{2}{3} \cdot \frac{1}{{v}^{3}} + \left(\frac{4}{3} \cdot \frac{1}{{v}^{2}} + \left(2 \cdot \frac{1}{v} + u \cdot \left(u \cdot \left(\frac{8}{3} \cdot \frac{1}{{v}^{2}} + 8 \cdot \frac{1}{{v}^{3}}\right) - \left(2 \cdot \frac{1}{v} + \left(4 \cdot \frac{1}{{v}^{2}} + \frac{14}{3} \cdot \frac{1}{{v}^{3}}\right)\right)\right)\right)\right)\right)\right) - 2\right)}\right) \]
        6. Simplified63.5%

          \[\leadsto 1 + \color{blue}{\left(u \cdot \left(\left(2 + \left(\frac{0.6666666666666666}{v \cdot \left(v \cdot v\right)} + \left(\frac{2}{v} + \frac{1.3333333333333333}{v \cdot v}\right)\right)\right) + u \cdot \left(u \cdot \left(\frac{2.6666666666666665}{v \cdot v} + \frac{8}{v \cdot \left(v \cdot v\right)}\right) - \left(\frac{2}{v} + \left(\frac{4}{v \cdot v} + \frac{4.666666666666667}{v \cdot \left(v \cdot v\right)}\right)\right)\right)\right) + -2\right)} \]
      5. Recombined 2 regimes into one program.
      6. Final simplification91.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(-2 + u \cdot \left(\left(2 + \left(\frac{0.6666666666666666}{v \cdot \left(v \cdot v\right)} + \left(\frac{2}{v} + \frac{1.3333333333333333}{v \cdot v}\right)\right)\right) + u \cdot \left(u \cdot \left(\frac{2.6666666666666665}{v \cdot v} + \frac{8}{v \cdot \left(v \cdot v\right)}\right) - \left(\frac{2}{v} + \left(\frac{4}{v \cdot v} + \frac{4.666666666666667}{v \cdot \left(v \cdot v\right)}\right)\right)\right)\right)\right)\\ \end{array} \]
      7. Add Preprocessing

      Alternative 6: 91.1% accurate, 6.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(-2 + u \cdot \left(2 + \frac{\left(2 + u \cdot -2\right) + \frac{\left(1.3333333333333333 + \frac{0.6666666666666666}{v}\right) + u \cdot -4}{v}}{v}\right)\right)\\ \end{array} \end{array} \]
      (FPCore (u v)
       :precision binary32
       (if (<= v 0.10000000149011612)
         1.0
         (+
          1.0
          (+
           -2.0
           (*
            u
            (+
             2.0
             (/
              (+
               (+ 2.0 (* u -2.0))
               (/ (+ (+ 1.3333333333333333 (/ 0.6666666666666666 v)) (* u -4.0)) v))
              v)))))))
      float code(float u, float v) {
      	float tmp;
      	if (v <= 0.10000000149011612f) {
      		tmp = 1.0f;
      	} else {
      		tmp = 1.0f + (-2.0f + (u * (2.0f + (((2.0f + (u * -2.0f)) + (((1.3333333333333333f + (0.6666666666666666f / v)) + (u * -4.0f)) / v)) / v))));
      	}
      	return tmp;
      }
      
      real(4) function code(u, v)
          real(4), intent (in) :: u
          real(4), intent (in) :: v
          real(4) :: tmp
          if (v <= 0.10000000149011612e0) then
              tmp = 1.0e0
          else
              tmp = 1.0e0 + ((-2.0e0) + (u * (2.0e0 + (((2.0e0 + (u * (-2.0e0))) + (((1.3333333333333333e0 + (0.6666666666666666e0 / v)) + (u * (-4.0e0))) / v)) / v))))
          end if
          code = tmp
      end function
      
      function code(u, v)
      	tmp = Float32(0.0)
      	if (v <= Float32(0.10000000149011612))
      		tmp = Float32(1.0);
      	else
      		tmp = Float32(Float32(1.0) + Float32(Float32(-2.0) + Float32(u * Float32(Float32(2.0) + Float32(Float32(Float32(Float32(2.0) + Float32(u * Float32(-2.0))) + Float32(Float32(Float32(Float32(1.3333333333333333) + Float32(Float32(0.6666666666666666) / v)) + Float32(u * Float32(-4.0))) / v)) / v)))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(u, v)
      	tmp = single(0.0);
      	if (v <= single(0.10000000149011612))
      		tmp = single(1.0);
      	else
      		tmp = single(1.0) + (single(-2.0) + (u * (single(2.0) + (((single(2.0) + (u * single(-2.0))) + (((single(1.3333333333333333) + (single(0.6666666666666666) / v)) + (u * single(-4.0))) / v)) / v))));
      	end
      	tmp_2 = tmp;
      end
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;v \leq 0.10000000149011612:\\
      \;\;\;\;1\\
      
      \mathbf{else}:\\
      \;\;\;\;1 + \left(-2 + u \cdot \left(2 + \frac{\left(2 + u \cdot -2\right) + \frac{\left(1.3333333333333333 + \frac{0.6666666666666666}{v}\right) + u \cdot -4}{v}}{v}\right)\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if v < 0.100000001

        1. Initial program 100.0%

          \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in v around 0

          \[\leadsto \color{blue}{1} \]
        4. Step-by-step derivation
          1. Simplified93.0%

            \[\leadsto \color{blue}{1} \]

          if 0.100000001 < v

          1. Initial program 91.9%

            \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
          2. Add Preprocessing
          3. Taylor expanded in v around -inf

            \[\leadsto \mathsf{+.f32}\left(1, \color{blue}{\left(-2 \cdot \left(1 - u\right) + -1 \cdot \frac{-1 \cdot \frac{\frac{-1}{6} \cdot \left(-24 \cdot {\left(1 - u\right)}^{2} + \left(8 \cdot \left(1 - u\right) + 16 \cdot {\left(1 - u\right)}^{3}\right)\right) + \frac{1}{24} \cdot \frac{-96 \cdot {\left(1 - u\right)}^{4} + \left(-64 \cdot {\left(1 - u\right)}^{2} + \left(-48 \cdot {\left(1 - u\right)}^{2} + \left(16 \cdot \left(1 - u\right) + 192 \cdot {\left(1 - u\right)}^{3}\right)\right)\right)}{v}}{v} + \frac{-1}{2} \cdot \left(-4 \cdot {\left(1 - u\right)}^{2} + 4 \cdot \left(1 - u\right)\right)}{v}\right)}\right) \]
          4. Simplified65.4%

            \[\leadsto 1 + \color{blue}{\left(-2 \cdot \left(1 - u\right) - \frac{\left(\left(1 - u\right) \cdot \left(\left(1 - u\right) \cdot -4 + 4\right)\right) \cdot -0.5 - \frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \left(\left(-96 \cdot {\left(1 - u\right)}^{4} + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(-112 + \left(1 - u\right) \cdot 192\right)\right) + \left(1 - u\right) \cdot 16\right)}{v}}{v}}{v}\right)} \]
          5. Taylor expanded in u around 0

            \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \color{blue}{\left(16 \cdot u\right)}\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
          6. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \left(u \cdot 16\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
            2. *-lowering-*.f3260.7%

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{\_.f32}\left(\mathsf{*.f32}\left(-2, \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{/.f32}\left(\mathsf{\_.f32}\left(\mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), -4\right), 4\right)\right), \frac{-1}{2}\right), \mathsf{/.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 8\right), \mathsf{*.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), \mathsf{\_.f32}\left(1, u\right)\right), \mathsf{+.f32}\left(\mathsf{*.f32}\left(\mathsf{\_.f32}\left(1, u\right), 16\right), -24\right)\right)\right), \frac{-1}{6}\right), \mathsf{/.f32}\left(\mathsf{*.f32}\left(\frac{1}{24}, \mathsf{*.f32}\left(u, 16\right)\right), v\right)\right), v\right)\right), v\right)\right)\right) \]
          7. Simplified60.7%

            \[\leadsto 1 + \left(-2 \cdot \left(1 - u\right) - \frac{\left(\left(1 - u\right) \cdot \left(\left(1 - u\right) \cdot -4 + 4\right)\right) \cdot -0.5 - \frac{\left(\left(1 - u\right) \cdot 8 + \left(\left(1 - u\right) \cdot \left(1 - u\right)\right) \cdot \left(\left(1 - u\right) \cdot 16 + -24\right)\right) \cdot -0.16666666666666666 + \frac{0.041666666666666664 \cdot \color{blue}{\left(u \cdot 16\right)}}{v}}{v}}{v}\right) \]
          8. Taylor expanded in u around 0

            \[\leadsto \mathsf{+.f32}\left(1, \color{blue}{\left(u \cdot \left(2 + \left(-1 \cdot \left(u \cdot \left(2 \cdot \frac{1}{v} + 4 \cdot \frac{1}{{v}^{2}}\right)\right) + \left(\frac{2}{3} \cdot \frac{1}{{v}^{3}} + \left(\frac{4}{3} \cdot \frac{1}{{v}^{2}} + 2 \cdot \frac{1}{v}\right)\right)\right)\right) - 2\right)}\right) \]
          9. Step-by-step derivation
            1. sub-negN/A

              \[\leadsto \mathsf{+.f32}\left(1, \left(u \cdot \left(2 + \left(-1 \cdot \left(u \cdot \left(2 \cdot \frac{1}{v} + 4 \cdot \frac{1}{{v}^{2}}\right)\right) + \left(\frac{2}{3} \cdot \frac{1}{{v}^{3}} + \left(\frac{4}{3} \cdot \frac{1}{{v}^{2}} + 2 \cdot \frac{1}{v}\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(2\right)\right)}\right)\right) \]
            2. metadata-evalN/A

              \[\leadsto \mathsf{+.f32}\left(1, \left(u \cdot \left(2 + \left(-1 \cdot \left(u \cdot \left(2 \cdot \frac{1}{v} + 4 \cdot \frac{1}{{v}^{2}}\right)\right) + \left(\frac{2}{3} \cdot \frac{1}{{v}^{3}} + \left(\frac{4}{3} \cdot \frac{1}{{v}^{2}} + 2 \cdot \frac{1}{v}\right)\right)\right)\right) + -2\right)\right) \]
            3. +-lowering-+.f32N/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\left(u \cdot \left(2 + \left(-1 \cdot \left(u \cdot \left(2 \cdot \frac{1}{v} + 4 \cdot \frac{1}{{v}^{2}}\right)\right) + \left(\frac{2}{3} \cdot \frac{1}{{v}^{3}} + \left(\frac{4}{3} \cdot \frac{1}{{v}^{2}} + 2 \cdot \frac{1}{v}\right)\right)\right)\right)\right), \color{blue}{-2}\right)\right) \]
          10. Simplified61.5%

            \[\leadsto 1 + \color{blue}{\left(u \cdot \left(2 + \left(\left(\frac{0.6666666666666666}{v \cdot \left(v \cdot v\right)} + \left(\frac{2}{v} + \frac{1.3333333333333333}{v \cdot v}\right)\right) - u \cdot \left(\frac{2}{v} + \frac{4}{v \cdot v}\right)\right)\right) + -2\right)} \]
          11. Taylor expanded in v around -inf

            \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(2, \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{\left(\frac{4}{3} + \frac{2}{3} \cdot \frac{1}{v}\right) - 4 \cdot u}{v} - \left(2 + -2 \cdot u\right)}{v}\right)}\right)\right), -2\right)\right) \]
          12. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(2, \left(\mathsf{neg}\left(\frac{-1 \cdot \frac{\left(\frac{4}{3} + \frac{2}{3} \cdot \frac{1}{v}\right) - 4 \cdot u}{v} - \left(2 + -2 \cdot u\right)}{v}\right)\right)\right)\right), -2\right)\right) \]
            2. distribute-neg-frac2N/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(2, \left(\frac{-1 \cdot \frac{\left(\frac{4}{3} + \frac{2}{3} \cdot \frac{1}{v}\right) - 4 \cdot u}{v} - \left(2 + -2 \cdot u\right)}{\mathsf{neg}\left(v\right)}\right)\right)\right), -2\right)\right) \]
            3. mul-1-negN/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(2, \left(\frac{-1 \cdot \frac{\left(\frac{4}{3} + \frac{2}{3} \cdot \frac{1}{v}\right) - 4 \cdot u}{v} - \left(2 + -2 \cdot u\right)}{-1 \cdot v}\right)\right)\right), -2\right)\right) \]
            4. /-lowering-/.f32N/A

              \[\leadsto \mathsf{+.f32}\left(1, \mathsf{+.f32}\left(\mathsf{*.f32}\left(u, \mathsf{+.f32}\left(2, \mathsf{/.f32}\left(\left(-1 \cdot \frac{\left(\frac{4}{3} + \frac{2}{3} \cdot \frac{1}{v}\right) - 4 \cdot u}{v} - \left(2 + -2 \cdot u\right)\right), \left(-1 \cdot v\right)\right)\right)\right), -2\right)\right) \]
          13. Simplified61.5%

            \[\leadsto 1 + \left(u \cdot \left(2 + \color{blue}{\frac{\frac{\left(1.3333333333333333 + \frac{0.6666666666666666}{v}\right) + u \cdot -4}{-v} - \left(2 + u \cdot -2\right)}{-v}}\right) + -2\right) \]
        5. Recombined 2 regimes into one program.
        6. Final simplification91.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq 0.10000000149011612:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;1 + \left(-2 + u \cdot \left(2 + \frac{\left(2 + u \cdot -2\right) + \frac{\left(1.3333333333333333 + \frac{0.6666666666666666}{v}\right) + u \cdot -4}{v}}{v}\right)\right)\\ \end{array} \]
        7. Add Preprocessing

        Alternative 7: 86.7% accurate, 213.0× speedup?

        \[\begin{array}{l} \\ 1 \end{array} \]
        (FPCore (u v) :precision binary32 1.0)
        float code(float u, float v) {
        	return 1.0f;
        }
        
        real(4) function code(u, v)
            real(4), intent (in) :: u
            real(4), intent (in) :: v
            code = 1.0e0
        end function
        
        function code(u, v)
        	return Float32(1.0)
        end
        
        function tmp = code(u, v)
        	tmp = single(1.0);
        end
        
        \begin{array}{l}
        
        \\
        1
        \end{array}
        
        Derivation
        1. Initial program 99.4%

          \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
        2. Add Preprocessing
        3. Taylor expanded in v around 0

          \[\leadsto \color{blue}{1} \]
        4. Step-by-step derivation
          1. Simplified87.4%

            \[\leadsto \color{blue}{1} \]
          2. Add Preprocessing

          Alternative 8: 5.8% accurate, 213.0× speedup?

          \[\begin{array}{l} \\ -1 \end{array} \]
          (FPCore (u v) :precision binary32 -1.0)
          float code(float u, float v) {
          	return -1.0f;
          }
          
          real(4) function code(u, v)
              real(4), intent (in) :: u
              real(4), intent (in) :: v
              code = -1.0e0
          end function
          
          function code(u, v)
          	return Float32(-1.0)
          end
          
          function tmp = code(u, v)
          	tmp = single(-1.0);
          end
          
          \begin{array}{l}
          
          \\
          -1
          \end{array}
          
          Derivation
          1. Initial program 99.4%

            \[1 + v \cdot \log \left(u + \left(1 - u\right) \cdot e^{\frac{-2}{v}}\right) \]
          2. Add Preprocessing
          3. Taylor expanded in u around 0

            \[\leadsto \color{blue}{-1} \]
          4. Step-by-step derivation
            1. Simplified5.1%

              \[\leadsto \color{blue}{-1} \]
            2. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2024164 
            (FPCore (u v)
              :name "HairBSDF, sample_f, cosTheta"
              :precision binary32
              :pre (and (and (<= 1e-5 u) (<= u 1.0)) (and (<= 0.0 v) (<= v 109.746574)))
              (+ 1.0 (* v (log (+ u (* (- 1.0 u) (exp (/ -2.0 v))))))))