Disney BSSRDF, sample scattering profile, lower

Percentage Accurate: 61.3% → 98.9%
Time: 4.7s
Alternatives: 18
Speedup: 11.4×

Specification

?
\[\left(0 \leq s \land s \leq 256\right) \land \left(2.328306437 \cdot 10^{-10} \leq u \land u \leq 0.25\right)\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(FPCore (s u)
  :precision binary32
  (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function tmp = code(s, u)
	tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u))));
end
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)

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 18 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 61.3% accurate, 1.0× speedup?

\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(FPCore (s u)
  :precision binary32
  (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))
float code(float s, float u) {
	return s * logf((1.0f / (1.0f - (4.0f * u))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * log((1.0e0 / (1.0e0 - (4.0e0 * u))))
end function
function code(s, u)
	return Float32(s * log(Float32(Float32(1.0) / Float32(Float32(1.0) - Float32(Float32(4.0) * u)))))
end
function tmp = code(s, u)
	tmp = s * log((single(1.0) / (single(1.0) - (single(4.0) * u))));
end
s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)

Alternative 1: 98.9% accurate, 0.3× speedup?

\[\begin{array}{l} t_0 := -\log \left(-8 \cdot u - -2\right)\\ \mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\ \;\;\;\;s \cdot \left(\left(1 + \frac{\log 2}{t\_0}\right) \cdot t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (let* ((t_0 (- (log (- (* -8.0 u) -2.0)))))
  (if (<= (- 1.0 (* 4.0 u)) 0.9599999785423279)
    (* s (* (+ 1.0 (/ (log 2.0) t_0)) t_0))
    (*
     s
     (+
      (* (* (- (* (- (* 64.0 u) -21.333333333333332) u) -8.0) u) u)
      (* u 4.0))))))
float code(float s, float u) {
	float t_0 = -logf(((-8.0f * u) - -2.0f));
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.9599999785423279f) {
		tmp = s * ((1.0f + (logf(2.0f) / t_0)) * t_0);
	} else {
		tmp = s * (((((((64.0f * u) - -21.333333333333332f) * u) - -8.0f) * u) * u) + (u * 4.0f));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: t_0
    real(4) :: tmp
    t_0 = -log((((-8.0e0) * u) - (-2.0e0)))
    if ((1.0e0 - (4.0e0 * u)) <= 0.9599999785423279e0) then
        tmp = s * ((1.0e0 + (log(2.0e0) / t_0)) * t_0)
    else
        tmp = s * (((((((64.0e0 * u) - (-21.333333333333332e0)) * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
    end if
    code = tmp
end function
function code(s, u)
	t_0 = Float32(-log(Float32(Float32(Float32(-8.0) * u) - Float32(-2.0))))
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.9599999785423279))
		tmp = Float32(s * Float32(Float32(Float32(1.0) + Float32(log(Float32(2.0)) / t_0)) * t_0));
	else
		tmp = Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332)) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))));
	end
	return tmp
end
function tmp_2 = code(s, u)
	t_0 = -log(((single(-8.0) * u) - single(-2.0)));
	tmp = single(0.0);
	if ((single(1.0) - (single(4.0) * u)) <= single(0.9599999785423279))
		tmp = s * ((single(1.0) + (log(single(2.0)) / t_0)) * t_0);
	else
		tmp = s * (((((((single(64.0) * u) - single(-21.333333333333332)) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}
t_0 := -\log \left(-8 \cdot u - -2\right)\\
\mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\
\;\;\;\;s \cdot \left(\left(1 + \frac{\log 2}{t\_0}\right) \cdot t\_0\right)\\

\mathbf{else}:\\
\;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) < 0.959999979

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Applied rewrites63.4%

      \[\leadsto s \cdot \color{blue}{\left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
    3. Step-by-step derivation
      1. lift--.f32N/A

        \[\leadsto s \cdot \color{blue}{\left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
      2. sub-flipN/A

        \[\leadsto s \cdot \color{blue}{\left(\log 2 + \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right)} \]
      3. +-commutativeN/A

        \[\leadsto s \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right) + \log 2\right)} \]
      4. sum-to-multN/A

        \[\leadsto s \cdot \color{blue}{\left(\left(1 + \frac{\log 2}{\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right)} \]
      5. lower-unsound-*.f32N/A

        \[\leadsto s \cdot \color{blue}{\left(\left(1 + \frac{\log 2}{\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right)} \]
      6. lower-unsound-+.f32N/A

        \[\leadsto s \cdot \left(\color{blue}{\left(1 + \frac{\log 2}{\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)}\right)} \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      7. lower-unsound-/.f32N/A

        \[\leadsto s \cdot \left(\left(1 + \color{blue}{\frac{\log 2}{\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)}}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      8. lower-neg.f32N/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{\color{blue}{-\log \left(u \cdot -8 - -2\right)}}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      9. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(\color{blue}{u \cdot -8} - -2\right)}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(\color{blue}{-8 \cdot u} - -2\right)}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      11. lower-*.f32N/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(\color{blue}{-8 \cdot u} - -2\right)}\right) \cdot \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right) \]
      12. lower-neg.f3262.2%

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(-8 \cdot u - -2\right)}\right) \cdot \color{blue}{\left(-\log \left(u \cdot -8 - -2\right)\right)}\right) \]
      13. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(-8 \cdot u - -2\right)}\right) \cdot \left(-\log \left(\color{blue}{u \cdot -8} - -2\right)\right)\right) \]
      14. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(-8 \cdot u - -2\right)}\right) \cdot \left(-\log \left(\color{blue}{-8 \cdot u} - -2\right)\right)\right) \]
      15. lower-*.f3262.2%

        \[\leadsto s \cdot \left(\left(1 + \frac{\log 2}{-\log \left(-8 \cdot u - -2\right)}\right) \cdot \left(-\log \left(\color{blue}{-8 \cdot u} - -2\right)\right)\right) \]
    4. Applied rewrites62.2%

      \[\leadsto s \cdot \color{blue}{\left(\left(1 + \frac{\log 2}{-\log \left(-8 \cdot u - -2\right)}\right) \cdot \left(-\log \left(-8 \cdot u - -2\right)\right)\right)} \]

    if 0.959999979 < (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u))

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      4. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      5. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      6. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
      7. lower-*.f3292.8%

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites92.8%

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lift-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
      5. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      6. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      7. lower-+.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
    6. Applied rewrites93.1%

      \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 98.8% accurate, 0.9× speedup?

\[\begin{array}{l} \mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\ \;\;\;\;0.6931471824645996 \cdot s + \left(-\log \left(-8 \cdot u - -2\right)\right) \cdot s\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= (- 1.0 (* 4.0 u)) 0.9599999785423279)
  (+ (* 0.6931471824645996 s) (* (- (log (- (* -8.0 u) -2.0))) s))
  (*
   s
   (+
    (* (* (- (* (- (* 64.0 u) -21.333333333333332) u) -8.0) u) u)
    (* u 4.0)))))
float code(float s, float u) {
	float tmp;
	if ((1.0f - (4.0f * u)) <= 0.9599999785423279f) {
		tmp = (0.6931471824645996f * s) + (-logf(((-8.0f * u) - -2.0f)) * s);
	} else {
		tmp = s * (((((((64.0f * u) - -21.333333333333332f) * u) - -8.0f) * u) * u) + (u * 4.0f));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: tmp
    if ((1.0e0 - (4.0e0 * u)) <= 0.9599999785423279e0) then
        tmp = (0.6931471824645996e0 * s) + (-log((((-8.0e0) * u) - (-2.0e0))) * s)
    else
        tmp = s * (((((((64.0e0 * u) - (-21.333333333333332e0)) * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
    end if
    code = tmp
end function
function code(s, u)
	tmp = Float32(0.0)
	if (Float32(Float32(1.0) - Float32(Float32(4.0) * u)) <= Float32(0.9599999785423279))
		tmp = Float32(Float32(Float32(0.6931471824645996) * s) + Float32(Float32(-log(Float32(Float32(Float32(-8.0) * u) - Float32(-2.0)))) * s));
	else
		tmp = Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332)) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))));
	end
	return tmp
end
function tmp_2 = code(s, u)
	tmp = single(0.0);
	if ((single(1.0) - (single(4.0) * u)) <= single(0.9599999785423279))
		tmp = (single(0.6931471824645996) * s) + (-log(((single(-8.0) * u) - single(-2.0))) * s);
	else
		tmp = s * (((((((single(64.0) * u) - single(-21.333333333333332)) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
	end
	tmp_2 = tmp;
end
\begin{array}{l}
\mathbf{if}\;1 - 4 \cdot u \leq 0.9599999785423279:\\
\;\;\;\;0.6931471824645996 \cdot s + \left(-\log \left(-8 \cdot u - -2\right)\right) \cdot s\\

\mathbf{else}:\\
\;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u)) < 0.959999979

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Applied rewrites63.4%

      \[\leadsto s \cdot \color{blue}{\left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
    3. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \color{blue}{s \cdot \left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
      2. lift--.f32N/A

        \[\leadsto s \cdot \color{blue}{\left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
      3. sub-flipN/A

        \[\leadsto s \cdot \color{blue}{\left(\log 2 + \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right)\right)} \]
      4. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\log 2 \cdot s + \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right) \cdot s} \]
      5. lower-+.f32N/A

        \[\leadsto \color{blue}{\log 2 \cdot s + \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right) \cdot s} \]
      6. lower-*.f32N/A

        \[\leadsto \color{blue}{\log 2 \cdot s} + \left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right) \cdot s \]
      7. lower-*.f32N/A

        \[\leadsto \log 2 \cdot s + \color{blue}{\left(\mathsf{neg}\left(\log \left(u \cdot -8 - -2\right)\right)\right) \cdot s} \]
      8. lower-neg.f3262.2%

        \[\leadsto \log 2 \cdot s + \color{blue}{\left(-\log \left(u \cdot -8 - -2\right)\right)} \cdot s \]
      9. lift-*.f32N/A

        \[\leadsto \log 2 \cdot s + \left(-\log \left(\color{blue}{u \cdot -8} - -2\right)\right) \cdot s \]
      10. *-commutativeN/A

        \[\leadsto \log 2 \cdot s + \left(-\log \left(\color{blue}{-8 \cdot u} - -2\right)\right) \cdot s \]
      11. lower-*.f3262.2%

        \[\leadsto \log 2 \cdot s + \left(-\log \left(\color{blue}{-8 \cdot u} - -2\right)\right) \cdot s \]
    4. Applied rewrites62.2%

      \[\leadsto \color{blue}{\log 2 \cdot s + \left(-\log \left(-8 \cdot u - -2\right)\right) \cdot s} \]
    5. Evaluated real constant62.2%

      \[\leadsto \color{blue}{0.6931471824645996} \cdot s + \left(-\log \left(-8 \cdot u - -2\right)\right) \cdot s \]

    if 0.959999979 < (-.f32 #s(literal 1 binary32) (*.f32 #s(literal 4 binary32) u))

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      4. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      5. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      6. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
      7. lower-*.f3292.8%

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites92.8%

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lift-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
      5. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      6. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      7. lower-+.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
    6. Applied rewrites93.1%

      \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.8% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;u \leq 0.009499999694526196:\\ \;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;s \cdot \left(0.6931471824645996 - \log \left(u \cdot -8 - -2\right)\right)\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= u 0.009499999694526196)
  (*
   s
   (+
    (* (* (- (* (- (* 64.0 u) -21.333333333333332) u) -8.0) u) u)
    (* u 4.0)))
  (* s (- 0.6931471824645996 (log (- (* u -8.0) -2.0))))))
float code(float s, float u) {
	float tmp;
	if (u <= 0.009499999694526196f) {
		tmp = s * (((((((64.0f * u) - -21.333333333333332f) * u) - -8.0f) * u) * u) + (u * 4.0f));
	} else {
		tmp = s * (0.6931471824645996f - logf(((u * -8.0f) - -2.0f)));
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: tmp
    if (u <= 0.009499999694526196e0) then
        tmp = s * (((((((64.0e0 * u) - (-21.333333333333332e0)) * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
    else
        tmp = s * (0.6931471824645996e0 - log(((u * (-8.0e0)) - (-2.0e0))))
    end if
    code = tmp
end function
function code(s, u)
	tmp = Float32(0.0)
	if (u <= Float32(0.009499999694526196))
		tmp = Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332)) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))));
	else
		tmp = Float32(s * Float32(Float32(0.6931471824645996) - log(Float32(Float32(u * Float32(-8.0)) - Float32(-2.0)))));
	end
	return tmp
end
function tmp_2 = code(s, u)
	tmp = single(0.0);
	if (u <= single(0.009499999694526196))
		tmp = s * (((((((single(64.0) * u) - single(-21.333333333333332)) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
	else
		tmp = s * (single(0.6931471824645996) - log(((u * single(-8.0)) - single(-2.0))));
	end
	tmp_2 = tmp;
end
\begin{array}{l}
\mathbf{if}\;u \leq 0.009499999694526196:\\
\;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;s \cdot \left(0.6931471824645996 - \log \left(u \cdot -8 - -2\right)\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if u < 0.00949999969

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      4. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      5. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      6. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
      7. lower-*.f3292.8%

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites92.8%

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lift-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
      5. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      6. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      7. lower-+.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
    6. Applied rewrites93.1%

      \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]

    if 0.00949999969 < u

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Applied rewrites63.4%

      \[\leadsto s \cdot \color{blue}{\left(\log 2 - \log \left(u \cdot -8 - -2\right)\right)} \]
    3. Evaluated real constant63.4%

      \[\leadsto s \cdot \left(\color{blue}{0.6931471824645996} - \log \left(u \cdot -8 - -2\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.7% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;u \leq 0.010400000028312206:\\ \;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(-\log \left(1 - u \cdot 4\right)\right) \cdot s\\ \end{array} \]
(FPCore (s u)
  :precision binary32
  (if (<= u 0.010400000028312206)
  (*
   s
   (+
    (* (* (- (* (- (* 64.0 u) -21.333333333333332) u) -8.0) u) u)
    (* u 4.0)))
  (* (- (log (- 1.0 (* u 4.0)))) s)))
float code(float s, float u) {
	float tmp;
	if (u <= 0.010400000028312206f) {
		tmp = s * (((((((64.0f * u) - -21.333333333333332f) * u) - -8.0f) * u) * u) + (u * 4.0f));
	} else {
		tmp = -logf((1.0f - (u * 4.0f))) * s;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    real(4) :: tmp
    if (u <= 0.010400000028312206e0) then
        tmp = s * (((((((64.0e0 * u) - (-21.333333333333332e0)) * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
    else
        tmp = -log((1.0e0 - (u * 4.0e0))) * s
    end if
    code = tmp
end function
function code(s, u)
	tmp = Float32(0.0)
	if (u <= Float32(0.010400000028312206))
		tmp = Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332)) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))));
	else
		tmp = Float32(Float32(-log(Float32(Float32(1.0) - Float32(u * Float32(4.0))))) * s);
	end
	return tmp
end
function tmp_2 = code(s, u)
	tmp = single(0.0);
	if (u <= single(0.010400000028312206))
		tmp = s * (((((((single(64.0) * u) - single(-21.333333333333332)) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
	else
		tmp = -log((single(1.0) - (u * single(4.0)))) * s;
	end
	tmp_2 = tmp;
end
\begin{array}{l}
\mathbf{if}\;u \leq 0.010400000028312206:\\
\;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;\left(-\log \left(1 - u \cdot 4\right)\right) \cdot s\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if u < 0.0104

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      4. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      5. lower-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      6. lower-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
      7. lower-*.f3292.8%

        \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites92.8%

      \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
    5. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
      2. lift-+.f32N/A

        \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
      4. distribute-rgt-inN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
      5. *-commutativeN/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      6. lift-*.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
      7. lower-+.f32N/A

        \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
    6. Applied rewrites93.1%

      \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]

    if 0.0104 < u

    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto \color{blue}{s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right) \cdot s} \]
      3. lower-*.f3261.3%

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right) \cdot s} \]
      4. lift-log.f32N/A

        \[\leadsto \color{blue}{\log \left(\frac{1}{1 - 4 \cdot u}\right)} \cdot s \]
      5. lift-/.f32N/A

        \[\leadsto \log \color{blue}{\left(\frac{1}{1 - 4 \cdot u}\right)} \cdot s \]
      6. log-recN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\log \left(1 - 4 \cdot u\right)\right)\right)} \cdot s \]
      7. lower-log.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\log \left(1 - 4 \cdot u\right)}\right)\right) \cdot s \]
      8. lower-unsound-log.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\color{blue}{\log \left(1 - 4 \cdot u\right)}\right)\right) \cdot s \]
      9. lower-neg.f32N/A

        \[\leadsto \color{blue}{\left(-\log \left(1 - 4 \cdot u\right)\right)} \cdot s \]
      10. lower-unsound-log.f3263.8%

        \[\leadsto \left(-\color{blue}{\log \left(1 - 4 \cdot u\right)}\right) \cdot s \]
      11. lift-*.f32N/A

        \[\leadsto \left(-\log \left(1 - \color{blue}{4 \cdot u}\right)\right) \cdot s \]
      12. *-commutativeN/A

        \[\leadsto \left(-\log \left(1 - \color{blue}{u \cdot 4}\right)\right) \cdot s \]
      13. lower-*.f3263.8%

        \[\leadsto \left(-\log \left(1 - \color{blue}{u \cdot 4}\right)\right) \cdot s \]
    3. Applied rewrites63.8%

      \[\leadsto \color{blue}{\left(-\log \left(1 - u \cdot 4\right)\right) \cdot s} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 94.4% accurate, 1.5× speedup?

\[u \cdot \left(\left(1 - \frac{u \cdot \left(1.3333333333333333 + u \cdot \left(0.4444444444444444 + -11.851851851851851 \cdot u\right)\right) - 0.5}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 u
 (*
  (-
   1.0
   (/
    (-
     (*
      u
      (+
       1.3333333333333333
       (* u (+ 0.4444444444444444 (* -11.851851851851851 u)))))
     0.5)
    u))
  (*
   (- (* (- (* (* u s) 64.0) (* -21.333333333333332 s)) u) (* -8.0 s))
   u))))
float code(float s, float u) {
	return u * ((1.0f - (((u * (1.3333333333333333f + (u * (0.4444444444444444f + (-11.851851851851851f * u))))) - 0.5f) / u)) * ((((((u * s) * 64.0f) - (-21.333333333333332f * s)) * u) - (-8.0f * s)) * u));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = u * ((1.0e0 - (((u * (1.3333333333333333e0 + (u * (0.4444444444444444e0 + ((-11.851851851851851e0) * u))))) - 0.5e0) / u)) * ((((((u * s) * 64.0e0) - ((-21.333333333333332e0) * s)) * u) - ((-8.0e0) * s)) * u))
end function
function code(s, u)
	return Float32(u * Float32(Float32(Float32(1.0) - Float32(Float32(Float32(u * Float32(Float32(1.3333333333333333) + Float32(u * Float32(Float32(0.4444444444444444) + Float32(Float32(-11.851851851851851) * u))))) - Float32(0.5)) / u)) * Float32(Float32(Float32(Float32(Float32(Float32(u * s) * Float32(64.0)) - Float32(Float32(-21.333333333333332) * s)) * u) - Float32(Float32(-8.0) * s)) * u)))
end
function tmp = code(s, u)
	tmp = u * ((single(1.0) - (((u * (single(1.3333333333333333) + (u * (single(0.4444444444444444) + (single(-11.851851851851851) * u))))) - single(0.5)) / u)) * ((((((u * s) * single(64.0)) - (single(-21.333333333333332) * s)) * u) - (single(-8.0) * s)) * u));
end
u \cdot \left(\left(1 - \frac{u \cdot \left(1.3333333333333333 + u \cdot \left(0.4444444444444444 + -11.851851851851851 \cdot u\right)\right) - 0.5}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u} \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \color{blue}{\left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    5. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    6. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u} \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    7. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \color{blue}{\left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    8. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64 \cdot \left(s \cdot u\right)}\right)\right)\right) \]
    9. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64} \cdot \left(s \cdot u\right)\right)\right)\right) \]
    10. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \color{blue}{\left(s \cdot u\right)}\right)\right)\right) \]
    11. lower-*.f3293.1%

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.1%

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    2. +-commutativeN/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) + \color{blue}{4 \cdot s}\right) \]
    3. lift-*.f32N/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) + 4 \cdot \color{blue}{s}\right) \]
    4. fp-cancel-sign-sub-invN/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) - \color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot s}\right) \]
    5. sub-to-multN/A

      \[\leadsto u \cdot \left(\left(1 - \frac{\left(\mathsf{neg}\left(4\right)\right) \cdot s}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \cdot \color{blue}{\left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)}\right) \]
    6. lower-unsound-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{\left(\mathsf{neg}\left(4\right)\right) \cdot s}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \cdot \color{blue}{\left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)}\right) \]
  6. Applied rewrites92.4%

    \[\leadsto u \cdot \left(\left(1 - \frac{-4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \cdot \color{blue}{\left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
  7. Taylor expanded in u around 0

    \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - \color{blue}{-8 \cdot s}\right) \cdot u\right)\right) \]
  8. Step-by-step derivation
    1. lower-/.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot \color{blue}{s}\right) \cdot u\right)\right) \]
    2. lower--.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    4. lower-+.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    6. lower-+.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(\frac{4}{3} + u \cdot \left(\frac{4}{9} + \frac{-320}{27} \cdot u\right)\right) - \frac{1}{2}}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    7. lower-*.f3294.4%

      \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(1.3333333333333333 + u \cdot \left(0.4444444444444444 + -11.851851851851851 \cdot u\right)\right) - 0.5}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
  9. Applied rewrites94.4%

    \[\leadsto u \cdot \left(\left(1 - \frac{u \cdot \left(1.3333333333333333 + u \cdot \left(0.4444444444444444 + -11.851851851851851 \cdot u\right)\right) - 0.5}{u}\right) \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - \color{blue}{-8 \cdot s}\right) \cdot u\right)\right) \]
  10. Add Preprocessing

Alternative 6: 94.4% accurate, 1.5× speedup?

\[u \cdot \left(\frac{0.5 + u \cdot \left(u \cdot \left(11.851851851851851 \cdot u - 0.4444444444444444\right) - 0.3333333333333333\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 u
 (*
  (/
   (+
    0.5
    (*
     u
     (-
      (* u (- (* 11.851851851851851 u) 0.4444444444444444))
      0.3333333333333333)))
   u)
  (*
   (- (* (- (* (* u s) 64.0) (* -21.333333333333332 s)) u) (* -8.0 s))
   u))))
float code(float s, float u) {
	return u * (((0.5f + (u * ((u * ((11.851851851851851f * u) - 0.4444444444444444f)) - 0.3333333333333333f))) / u) * ((((((u * s) * 64.0f) - (-21.333333333333332f * s)) * u) - (-8.0f * s)) * u));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = u * (((0.5e0 + (u * ((u * ((11.851851851851851e0 * u) - 0.4444444444444444e0)) - 0.3333333333333333e0))) / u) * ((((((u * s) * 64.0e0) - ((-21.333333333333332e0) * s)) * u) - ((-8.0e0) * s)) * u))
end function
function code(s, u)
	return Float32(u * Float32(Float32(Float32(Float32(0.5) + Float32(u * Float32(Float32(u * Float32(Float32(Float32(11.851851851851851) * u) - Float32(0.4444444444444444))) - Float32(0.3333333333333333)))) / u) * Float32(Float32(Float32(Float32(Float32(Float32(u * s) * Float32(64.0)) - Float32(Float32(-21.333333333333332) * s)) * u) - Float32(Float32(-8.0) * s)) * u)))
end
function tmp = code(s, u)
	tmp = u * (((single(0.5) + (u * ((u * ((single(11.851851851851851) * u) - single(0.4444444444444444))) - single(0.3333333333333333)))) / u) * ((((((u * s) * single(64.0)) - (single(-21.333333333333332) * s)) * u) - (single(-8.0) * s)) * u));
end
u \cdot \left(\frac{0.5 + u \cdot \left(u \cdot \left(11.851851851851851 \cdot u - 0.4444444444444444\right) - 0.3333333333333333\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u} \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \color{blue}{\left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    5. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    6. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u} \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    7. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \color{blue}{\left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    8. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64 \cdot \left(s \cdot u\right)}\right)\right)\right) \]
    9. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64} \cdot \left(s \cdot u\right)\right)\right)\right) \]
    10. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \color{blue}{\left(s \cdot u\right)}\right)\right)\right) \]
    11. lower-*.f3293.1%

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.1%

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. lift-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    2. +-commutativeN/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) + \color{blue}{4 \cdot s}\right) \]
    3. lift-*.f32N/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) + 4 \cdot \color{blue}{s}\right) \]
    4. fp-cancel-sign-sub-invN/A

      \[\leadsto u \cdot \left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right) - \color{blue}{\left(\mathsf{neg}\left(4\right)\right) \cdot s}\right) \]
    5. sub-to-multN/A

      \[\leadsto u \cdot \left(\left(1 - \frac{\left(\mathsf{neg}\left(4\right)\right) \cdot s}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \cdot \color{blue}{\left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)}\right) \]
    6. lower-unsound-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 - \frac{\left(\mathsf{neg}\left(4\right)\right) \cdot s}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \cdot \color{blue}{\left(u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)}\right) \]
  6. Applied rewrites92.4%

    \[\leadsto u \cdot \left(\left(1 - \frac{-4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \cdot \color{blue}{\left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
  7. Taylor expanded in u around 0

    \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\color{blue}{\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right)} \cdot u\right)\right) \]
  8. Step-by-step derivation
    1. lower-/.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - \color{blue}{-8 \cdot s}\right) \cdot u\right)\right) \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - \color{blue}{-8} \cdot s\right) \cdot u\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    4. lower--.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    6. lower--.f32N/A

      \[\leadsto u \cdot \left(\frac{\frac{1}{2} + u \cdot \left(u \cdot \left(\frac{320}{27} \cdot u - \frac{4}{9}\right) - \frac{1}{3}\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
    7. lower-*.f3294.4%

      \[\leadsto u \cdot \left(\frac{0.5 + u \cdot \left(u \cdot \left(11.851851851851851 \cdot u - 0.4444444444444444\right) - 0.3333333333333333\right)}{u} \cdot \left(\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)\right) \]
  9. Applied rewrites94.4%

    \[\leadsto u \cdot \left(\frac{0.5 + u \cdot \left(u \cdot \left(11.851851851851851 \cdot u - 0.4444444444444444\right) - 0.3333333333333333\right)}{u} \cdot \left(\color{blue}{\left(\left(\left(u \cdot s\right) \cdot 64 - -21.333333333333332 \cdot s\right) \cdot u - -8 \cdot s\right)} \cdot u\right)\right) \]
  10. Add Preprocessing

Alternative 7: 93.1% accurate, 3.1× speedup?

\[s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
(FPCore (s u)
  :precision binary32
  (*
 s
 (+
  (* (* (- (* (- (* 64.0 u) -21.333333333333332) u) -8.0) u) u)
  (* u 4.0))))
float code(float s, float u) {
	return s * (((((((64.0f * u) - -21.333333333333332f) * u) - -8.0f) * u) * u) + (u * 4.0f));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * (((((((64.0e0 * u) - (-21.333333333333332e0)) * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
end function
function code(s, u)
	return Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332)) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))))
end
function tmp = code(s, u)
	tmp = s * (((((((single(64.0) * u) - single(-21.333333333333332)) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
end
s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    2. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    4. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    6. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
    7. lower-*.f3292.8%

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites92.8%

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    2. lift-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
    4. distribute-rgt-inN/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
    5. *-commutativeN/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
    6. lift-*.f32N/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
    7. lower-+.f32N/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  6. Applied rewrites93.1%

    \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  7. Add Preprocessing

Alternative 8: 93.1% accurate, 3.1× speedup?

\[u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 u
 (+
  (* 4.0 s)
  (* s (* u (+ 8.0 (* u (+ 21.333333333333332 (* 64.0 u)))))))))
float code(float s, float u) {
	return u * ((4.0f * s) + (s * (u * (8.0f + (u * (21.333333333333332f + (64.0f * u)))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = u * ((4.0e0 * s) + (s * (u * (8.0e0 + (u * (21.333333333333332e0 + (64.0e0 * u)))))))
end function
function code(s, u)
	return Float32(u * Float32(Float32(Float32(4.0) * s) + Float32(s * Float32(u * Float32(Float32(8.0) + Float32(u * Float32(Float32(21.333333333333332) + Float32(Float32(64.0) * u))))))))
end
function tmp = code(s, u)
	tmp = u * ((single(4.0) * s) + (s * (u * (single(8.0) + (u * (single(21.333333333333332) + (single(64.0) * u)))))));
end
u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u} \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \color{blue}{\left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    5. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    6. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u} \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    7. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \color{blue}{\left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    8. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64 \cdot \left(s \cdot u\right)}\right)\right)\right) \]
    9. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64} \cdot \left(s \cdot u\right)\right)\right)\right) \]
    10. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \color{blue}{\left(s \cdot u\right)}\right)\right)\right) \]
    11. lower-*.f3293.1%

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.1%

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  5. Taylor expanded in s around 0

    \[\leadsto u \cdot \left(4 \cdot s + s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    2. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    3. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    4. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
    5. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    6. lower-*.f3293.1%

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
  7. Applied rewrites93.1%

    \[\leadsto u \cdot \left(4 \cdot s + s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)}\right) \]
  8. Add Preprocessing

Alternative 9: 92.8% accurate, 3.6× speedup?

\[s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 s
 (* u (+ 4.0 (* u (+ 8.0 (* u (+ 21.333333333333332 (* 64.0 u)))))))))
float code(float s, float u) {
	return s * (u * (4.0f + (u * (8.0f + (u * (21.333333333333332f + (64.0f * u)))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * (u * (4.0e0 + (u * (8.0e0 + (u * (21.333333333333332e0 + (64.0e0 * u)))))))
end function
function code(s, u)
	return Float32(s * Float32(u * Float32(Float32(4.0) + Float32(u * Float32(Float32(8.0) + Float32(u * Float32(Float32(21.333333333333332) + Float32(Float32(64.0) * u))))))))
end
function tmp = code(s, u)
	tmp = s * (u * (single(4.0) + (u * (single(8.0) + (u * (single(21.333333333333332) + (single(64.0) * u)))))));
end
s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    2. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    4. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    6. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
    7. lower-*.f3292.8%

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites92.8%

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
  5. Add Preprocessing

Alternative 10: 92.8% accurate, 3.6× speedup?

\[u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 u
 (* s (+ 4.0 (* u (+ 8.0 (* u (+ 21.333333333333332 (* 64.0 u)))))))))
float code(float s, float u) {
	return u * (s * (4.0f + (u * (8.0f + (u * (21.333333333333332f + (64.0f * u)))))));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = u * (s * (4.0e0 + (u * (8.0e0 + (u * (21.333333333333332e0 + (64.0e0 * u)))))))
end function
function code(s, u)
	return Float32(u * Float32(s * Float32(Float32(4.0) + Float32(u * Float32(Float32(8.0) + Float32(u * Float32(Float32(21.333333333333332) + Float32(Float32(64.0) * u))))))))
end
function tmp = code(s, u)
	tmp = u * (s * (single(4.0) + (u * (single(8.0) + (u * (single(21.333333333333332) + (single(64.0) * u)))))));
end
u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u} \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    4. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \color{blue}{\left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
    5. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    6. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u} \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
    7. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \color{blue}{\left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
    8. lower-+.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64 \cdot \left(s \cdot u\right)}\right)\right)\right) \]
    9. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64} \cdot \left(s \cdot u\right)\right)\right)\right) \]
    10. lower-*.f32N/A

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \color{blue}{\left(s \cdot u\right)}\right)\right)\right) \]
    11. lower-*.f3293.1%

      \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.1%

    \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
  5. Taylor expanded in s around 0

    \[\leadsto u \cdot \left(s \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
  6. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    2. lower-+.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    4. lower-+.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
    6. lower-+.f32N/A

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
    7. lower-*.f3292.8%

      \[\leadsto u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
  7. Applied rewrites92.8%

    \[\leadsto u \cdot \left(s \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)}\right) \]
  8. Add Preprocessing

Alternative 11: 90.9% accurate, 3.9× speedup?

\[s \cdot \left(\left(\left(21.333333333333332 \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
(FPCore (s u)
  :precision binary32
  (* s (+ (* (* (- (* 21.333333333333332 u) -8.0) u) u) (* u 4.0))))
float code(float s, float u) {
	return s * (((((21.333333333333332f * u) - -8.0f) * u) * u) + (u * 4.0f));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(4) function code(s, u)
use fmin_fmax_functions
    real(4), intent (in) :: s
    real(4), intent (in) :: u
    code = s * (((((21.333333333333332e0 * u) - (-8.0e0)) * u) * u) + (u * 4.0e0))
end function
function code(s, u)
	return Float32(s * Float32(Float32(Float32(Float32(Float32(Float32(21.333333333333332) * u) - Float32(-8.0)) * u) * u) + Float32(u * Float32(4.0))))
end
function tmp = code(s, u)
	tmp = s * (((((single(21.333333333333332) * u) - single(-8.0)) * u) * u) + (u * single(4.0)));
end
s \cdot \left(\left(\left(21.333333333333332 \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)
Derivation
  1. Initial program 61.3%

    \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
  2. Taylor expanded in u around 0

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
  3. Step-by-step derivation
    1. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    2. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    4. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    5. lower-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
    6. lower-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
    7. lower-*.f3292.8%

      \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites92.8%

    \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f32N/A

      \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    2. lift-+.f32N/A

      \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
    4. distribute-rgt-inN/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
    5. *-commutativeN/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
    6. lift-*.f32N/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
    7. lower-+.f32N/A

      \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  6. Applied rewrites93.1%

    \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
  7. Taylor expanded in u around 0

    \[\leadsto s \cdot \left(\left(\left(\frac{64}{3} \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
  8. Step-by-step derivation
    1. Applied rewrites90.9%

      \[\leadsto s \cdot \left(\left(\left(21.333333333333332 \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    2. Add Preprocessing

    Alternative 12: 90.9% accurate, 3.9× speedup?

    \[u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot 21.333333333333332\right)\right)\right) \]
    (FPCore (s u)
      :precision binary32
      (* u (+ (* 4.0 s) (* s (* u (+ 8.0 (* u 21.333333333333332)))))))
    float code(float s, float u) {
    	return u * ((4.0f * s) + (s * (u * (8.0f + (u * 21.333333333333332f)))));
    }
    
    module fmin_fmax_functions
        implicit none
        private
        public fmax
        public fmin
    
        interface fmax
            module procedure fmax88
            module procedure fmax44
            module procedure fmax84
            module procedure fmax48
        end interface
        interface fmin
            module procedure fmin88
            module procedure fmin44
            module procedure fmin84
            module procedure fmin48
        end interface
    contains
        real(8) function fmax88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(4) function fmax44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
        end function
        real(8) function fmax84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmax48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
        end function
        real(8) function fmin88(x, y) result (res)
            real(8), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(4) function fmin44(x, y) result (res)
            real(4), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
        end function
        real(8) function fmin84(x, y) result(res)
            real(8), intent (in) :: x
            real(4), intent (in) :: y
            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
        end function
        real(8) function fmin48(x, y) result(res)
            real(4), intent (in) :: x
            real(8), intent (in) :: y
            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
        end function
    end module
    
    real(4) function code(s, u)
    use fmin_fmax_functions
        real(4), intent (in) :: s
        real(4), intent (in) :: u
        code = u * ((4.0e0 * s) + (s * (u * (8.0e0 + (u * 21.333333333333332e0)))))
    end function
    
    function code(s, u)
    	return Float32(u * Float32(Float32(Float32(4.0) * s) + Float32(s * Float32(u * Float32(Float32(8.0) + Float32(u * Float32(21.333333333333332)))))))
    end
    
    function tmp = code(s, u)
    	tmp = u * ((single(4.0) * s) + (s * (u * (single(8.0) + (u * single(21.333333333333332))))));
    end
    
    u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot 21.333333333333332\right)\right)\right)
    
    Derivation
    1. Initial program 61.3%

      \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
    2. Taylor expanded in u around 0

      \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
      2. lower-+.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
      3. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{u} \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      4. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \color{blue}{\left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)}\right) \]
      5. lower-+.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
      6. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + \color{blue}{u} \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right) \]
      7. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \color{blue}{\left(\frac{64}{3} \cdot s + 64 \cdot \left(s \cdot u\right)\right)}\right)\right) \]
      8. lower-+.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64 \cdot \left(s \cdot u\right)}\right)\right)\right) \]
      9. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + \color{blue}{64} \cdot \left(s \cdot u\right)\right)\right)\right) \]
      10. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(\frac{64}{3} \cdot s + 64 \cdot \color{blue}{\left(s \cdot u\right)}\right)\right)\right) \]
      11. lower-*.f3293.1%

        \[\leadsto u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites93.1%

      \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + u \cdot \left(8 \cdot s + u \cdot \left(21.333333333333332 \cdot s + 64 \cdot \left(s \cdot u\right)\right)\right)\right)} \]
    5. Taylor expanded in s around 0

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
      2. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      3. lower-+.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
      4. lower-*.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
      5. lower-+.f32N/A

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
      6. lower-*.f3293.1%

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right) \]
    7. Applied rewrites93.1%

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)}\right) \]
    8. Taylor expanded in u around 0

      \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot \frac{64}{3}\right)\right)\right) \]
    9. Step-by-step derivation
      1. Applied rewrites90.9%

        \[\leadsto u \cdot \left(4 \cdot s + s \cdot \left(u \cdot \left(8 + u \cdot 21.333333333333332\right)\right)\right) \]
      2. Add Preprocessing

      Alternative 13: 90.7% accurate, 4.6× speedup?

      \[s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + 21.333333333333332 \cdot u\right)\right)\right) \]
      (FPCore (s u)
        :precision binary32
        (* s (* u (+ 4.0 (* u (+ 8.0 (* 21.333333333333332 u)))))))
      float code(float s, float u) {
      	return s * (u * (4.0f + (u * (8.0f + (21.333333333333332f * u)))));
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(4) function code(s, u)
      use fmin_fmax_functions
          real(4), intent (in) :: s
          real(4), intent (in) :: u
          code = s * (u * (4.0e0 + (u * (8.0e0 + (21.333333333333332e0 * u)))))
      end function
      
      function code(s, u)
      	return Float32(s * Float32(u * Float32(Float32(4.0) + Float32(u * Float32(Float32(8.0) + Float32(Float32(21.333333333333332) * u))))))
      end
      
      function tmp = code(s, u)
      	tmp = s * (u * (single(4.0) + (u * (single(8.0) + (single(21.333333333333332) * u)))));
      end
      
      s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + 21.333333333333332 \cdot u\right)\right)\right)
      
      Derivation
      1. Initial program 61.3%

        \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
      2. Taylor expanded in u around 0

        \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + \frac{64}{3} \cdot u\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + \frac{64}{3} \cdot u\right)\right)}\right) \]
        2. lower-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + \frac{64}{3} \cdot u\right)}\right)\right) \]
        3. lower-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + \frac{64}{3} \cdot u\right)}\right)\right) \]
        4. lower-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{\frac{64}{3} \cdot u}\right)\right)\right) \]
        5. lower-*.f3290.7%

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + 21.333333333333332 \cdot \color{blue}{u}\right)\right)\right) \]
      4. Applied rewrites90.7%

        \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + 21.333333333333332 \cdot u\right)\right)\right)} \]
      5. Add Preprocessing

      Alternative 14: 86.5% accurate, 5.2× speedup?

      \[s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right) \]
      (FPCore (s u)
        :precision binary32
        (* s (+ (* (* 8.0 u) u) (* u 4.0))))
      float code(float s, float u) {
      	return s * (((8.0f * u) * u) + (u * 4.0f));
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(4) function code(s, u)
      use fmin_fmax_functions
          real(4), intent (in) :: s
          real(4), intent (in) :: u
          code = s * (((8.0e0 * u) * u) + (u * 4.0e0))
      end function
      
      function code(s, u)
      	return Float32(s * Float32(Float32(Float32(Float32(8.0) * u) * u) + Float32(u * Float32(4.0))))
      end
      
      function tmp = code(s, u)
      	tmp = s * (((single(8.0) * u) * u) + (u * single(4.0)));
      end
      
      s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right)
      
      Derivation
      1. Initial program 61.3%

        \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
      2. Taylor expanded in u around 0

        \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
      3. Step-by-step derivation
        1. lower-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
        2. lower-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
        3. lower-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
        4. lower-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
        5. lower-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
        6. lower-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
        7. lower-*.f3292.8%

          \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
      4. Applied rewrites92.8%

        \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
      5. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
        2. lift-+.f32N/A

          \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
        3. +-commutativeN/A

          \[\leadsto s \cdot \left(u \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) + \color{blue}{4}\right)\right) \]
        4. distribute-rgt-inN/A

          \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{4 \cdot u}\right) \]
        5. *-commutativeN/A

          \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
        6. lift-*.f32N/A

          \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + u \cdot \color{blue}{4}\right) \]
        7. lower-+.f32N/A

          \[\leadsto s \cdot \left(\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
      6. Applied rewrites93.1%

        \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - -21.333333333333332\right) \cdot u - -8\right) \cdot u\right) \cdot u + \color{blue}{u \cdot 4}\right) \]
      7. Taylor expanded in u around 0

        \[\leadsto s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right) \]
      8. Step-by-step derivation
        1. Applied rewrites86.5%

          \[\leadsto s \cdot \left(\left(8 \cdot u\right) \cdot u + u \cdot 4\right) \]
        2. Add Preprocessing

        Alternative 15: 86.5% accurate, 5.2× speedup?

        \[u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right) \]
        (FPCore (s u)
          :precision binary32
          (* u (+ (* 4.0 s) (* 8.0 (* s u)))))
        float code(float s, float u) {
        	return u * ((4.0f * s) + (8.0f * (s * u)));
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(4) function code(s, u)
        use fmin_fmax_functions
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = u * ((4.0e0 * s) + (8.0e0 * (s * u)))
        end function
        
        function code(s, u)
        	return Float32(u * Float32(Float32(Float32(4.0) * s) + Float32(Float32(8.0) * Float32(s * u))))
        end
        
        function tmp = code(s, u)
        	tmp = u * ((single(4.0) * s) + (single(8.0) * (s * u)));
        end
        
        u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right)
        
        Derivation
        1. Initial program 61.3%

          \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
        2. Taylor expanded in u around 0

          \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right)} \]
        3. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto u \cdot \color{blue}{\left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right)} \]
          2. lower-+.f32N/A

            \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{8 \cdot \left(s \cdot u\right)}\right) \]
          3. lower-*.f32N/A

            \[\leadsto u \cdot \left(4 \cdot s + \color{blue}{8} \cdot \left(s \cdot u\right)\right) \]
          4. lower-*.f32N/A

            \[\leadsto u \cdot \left(4 \cdot s + 8 \cdot \color{blue}{\left(s \cdot u\right)}\right) \]
          5. lower-*.f3286.5%

            \[\leadsto u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot \color{blue}{u}\right)\right) \]
        4. Applied rewrites86.5%

          \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right)} \]
        5. Add Preprocessing

        Alternative 16: 86.3% accurate, 6.6× speedup?

        \[s \cdot \left(u \cdot \left(4 + 8 \cdot u\right)\right) \]
        (FPCore (s u)
          :precision binary32
          (* s (* u (+ 4.0 (* 8.0 u)))))
        float code(float s, float u) {
        	return s * (u * (4.0f + (8.0f * u)));
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(4) function code(s, u)
        use fmin_fmax_functions
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = s * (u * (4.0e0 + (8.0e0 * u)))
        end function
        
        function code(s, u)
        	return Float32(s * Float32(u * Float32(Float32(4.0) + Float32(Float32(8.0) * u))))
        end
        
        function tmp = code(s, u)
        	tmp = s * (u * (single(4.0) + (single(8.0) * u)));
        end
        
        s \cdot \left(u \cdot \left(4 + 8 \cdot u\right)\right)
        
        Derivation
        1. Initial program 61.3%

          \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
        2. Taylor expanded in u around 0

          \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + 8 \cdot u\right)\right)} \]
        3. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + 8 \cdot u\right)}\right) \]
          2. lower-+.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{8 \cdot u}\right)\right) \]
          3. lower-*.f3286.3%

            \[\leadsto s \cdot \left(u \cdot \left(4 + 8 \cdot \color{blue}{u}\right)\right) \]
        4. Applied rewrites86.3%

          \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + 8 \cdot u\right)\right)} \]
        5. Add Preprocessing

        Alternative 17: 73.6% accurate, 11.4× speedup?

        \[s \cdot \left(u \cdot 4\right) \]
        (FPCore (s u)
          :precision binary32
          (* s (* u 4.0)))
        float code(float s, float u) {
        	return s * (u * 4.0f);
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(4) function code(s, u)
        use fmin_fmax_functions
            real(4), intent (in) :: s
            real(4), intent (in) :: u
            code = s * (u * 4.0e0)
        end function
        
        function code(s, u)
        	return Float32(s * Float32(u * Float32(4.0)))
        end
        
        function tmp = code(s, u)
        	tmp = s * (u * single(4.0));
        end
        
        s \cdot \left(u \cdot 4\right)
        
        Derivation
        1. Initial program 61.3%

          \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
        2. Taylor expanded in u around 0

          \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)} \]
        3. Step-by-step derivation
          1. lower-*.f32N/A

            \[\leadsto s \cdot \left(u \cdot \color{blue}{\left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right) \]
          2. lower-+.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + \color{blue}{u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
          3. lower-*.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\right) \]
          4. lower-+.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
          5. lower-*.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\right) \]
          6. lower-+.f32N/A

            \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\right) \]
          7. lower-*.f3292.8%

            \[\leadsto s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot \color{blue}{u}\right)\right)\right)\right) \]
        4. Applied rewrites92.8%

          \[\leadsto s \cdot \color{blue}{\left(u \cdot \left(4 + u \cdot \left(8 + u \cdot \left(21.333333333333332 + 64 \cdot u\right)\right)\right)\right)} \]
        5. Taylor expanded in u around 0

          \[\leadsto s \cdot \left(u \cdot 4\right) \]
        6. Step-by-step derivation
          1. Applied rewrites73.6%

            \[\leadsto s \cdot \left(u \cdot 4\right) \]
          2. Add Preprocessing

          Alternative 18: 73.4% accurate, 11.4× speedup?

          \[4 \cdot \left(s \cdot u\right) \]
          (FPCore (s u)
            :precision binary32
            (* 4.0 (* s u)))
          float code(float s, float u) {
          	return 4.0f * (s * u);
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(4) function code(s, u)
          use fmin_fmax_functions
              real(4), intent (in) :: s
              real(4), intent (in) :: u
              code = 4.0e0 * (s * u)
          end function
          
          function code(s, u)
          	return Float32(Float32(4.0) * Float32(s * u))
          end
          
          function tmp = code(s, u)
          	tmp = single(4.0) * (s * u);
          end
          
          4 \cdot \left(s \cdot u\right)
          
          Derivation
          1. Initial program 61.3%

            \[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
          2. Taylor expanded in u around 0

            \[\leadsto \color{blue}{4 \cdot \left(s \cdot u\right)} \]
          3. Step-by-step derivation
            1. lower-*.f32N/A

              \[\leadsto 4 \cdot \color{blue}{\left(s \cdot u\right)} \]
            2. lower-*.f3273.4%

              \[\leadsto 4 \cdot \left(s \cdot \color{blue}{u}\right) \]
          4. Applied rewrites73.4%

            \[\leadsto \color{blue}{4 \cdot \left(s \cdot u\right)} \]
          5. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025258 
          (FPCore (s u)
            :name "Disney BSSRDF, sample scattering profile, lower"
            :precision binary32
            :pre (and (and (<= 0.0 s) (<= s 256.0)) (and (<= 2.328306437e-10 u) (<= u 0.25)))
            (* s (log (/ 1.0 (- 1.0 (* 4.0 u))))))