Disney BSSRDF, sample scattering profile, lower

Percentage Accurate: 61.6% → 98.9%
Time: 4.8s
Alternatives: 16
Speedup: 11.4×

Specification

?
\[\left(0 \leq s \land s \leq 256\right) \land \left(\frac{2328306437}{10000000000000000000} \leq u \land u \leq \frac{1}{4}\right)\]
\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(FPCore (s u)
  :precision binary32
  (* s (log (/ 1 (- 1 (* 4 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 16 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.6% accurate, 1.0× speedup?

\[s \cdot \log \left(\frac{1}{1 - 4 \cdot u}\right) \]
(FPCore (s u)
  :precision binary32
  (* s (log (/ 1 (- 1 (* 4 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, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;u \leq \frac{10200547}{1073741824}:\\ \;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - \frac{-64}{3}\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 10200547/1073741824)
  (* s (+ (* (* (- (* (- (* 64 u) -64/3) u) -8) u) u) (* u 4)))
  (* (- (log (- 1 (* u 4)))) s)))
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 = -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.009499999694526196e0) 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.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(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.009499999694526196))
		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 \frac{10200547}{1073741824}:\\
\;\;\;\;s \cdot \left(\left(\left(\left(64 \cdot u - \frac{-64}{3}\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.00949999969

    1. Initial program 61.6%

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

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

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

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

    if 0.00949999969 < u

    1. Initial program 61.6%

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

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

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

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

      \[\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 2: 94.9% accurate, 1.7× speedup?

\[\left(\left(\left(\left(\left(\frac{320}{27} \cdot u - \frac{4}{9}\right) \cdot u - \frac{1}{3}\right) + \frac{\frac{1}{2}}{u}\right) \cdot u\right) \cdot \left(\left(s \cdot \left(64 \cdot u - \frac{-64}{3}\right)\right) \cdot u - -8 \cdot s\right)\right) \cdot u \]
(FPCore (s u)
  :precision binary32
  (*
 (*
  (* (+ (- (* (- (* 320/27 u) 4/9) u) 1/3) (/ 1/2 u)) u)
  (- (* (* s (- (* 64 u) -64/3)) u) (* -8 s)))
 u))
float code(float s, float u) {
	return (((((((11.851851851851851f * u) - 0.4444444444444444f) * u) - 0.3333333333333333f) + (0.5f / u)) * u) * (((s * ((64.0f * u) - -21.333333333333332f)) * 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 = (((((((11.851851851851851e0 * u) - 0.4444444444444444e0) * u) - 0.3333333333333333e0) + (0.5e0 / u)) * u) * (((s * ((64.0e0 * u) - (-21.333333333333332e0))) * u) - ((-8.0e0) * s))) * u
end function
function code(s, u)
	return Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(Float32(11.851851851851851) * u) - Float32(0.4444444444444444)) * u) - Float32(0.3333333333333333)) + Float32(Float32(0.5) / u)) * u) * Float32(Float32(Float32(s * Float32(Float32(Float32(64.0) * u) - Float32(-21.333333333333332))) * u) - Float32(Float32(-8.0) * s))) * u)
end
function tmp = code(s, u)
	tmp = (((((((single(11.851851851851851) * u) - single(0.4444444444444444)) * u) - single(0.3333333333333333)) + (single(0.5) / u)) * u) * (((s * ((single(64.0) * u) - single(-21.333333333333332))) * u) - (single(-8.0) * s))) * u;
end
\left(\left(\left(\left(\left(\frac{320}{27} \cdot u - \frac{4}{9}\right) \cdot u - \frac{1}{3}\right) + \frac{\frac{1}{2}}{u}\right) \cdot u\right) \cdot \left(\left(s \cdot \left(64 \cdot u - \frac{-64}{3}\right)\right) \cdot u - -8 \cdot s\right)\right) \cdot u
Derivation
  1. Initial program 61.6%

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

      \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.6%

    \[\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)} \]
  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. sum-to-multN/A

      \[\leadsto u \cdot \left(\left(1 + \frac{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) \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) \]
    4. lower-unsound-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 + \frac{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) \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.9%

    \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \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 - \frac{-64}{3} \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.7%

      \[\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) \]
  9. Applied rewrites94.7%

    \[\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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right)} \cdot u\right)\right) \]
  10. Applied rewrites94.9%

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

Alternative 3: 94.6% accurate, 1.7× speedup?

\[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(s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (*
 u
 (*
  (/ (+ 1/2 (* u (- (* u (- (* 320/27 u) 4/9)) 1/3))) u)
  (* s (* u (+ 8 (* u (+ 64/3 (* 64 u)))))))))
float code(float s, float u) {
	return u * (((0.5f + (u * ((u * ((11.851851851851851f * u) - 0.4444444444444444f)) - 0.3333333333333333f))) / u) * (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 * (((0.5e0 + (u * ((u * ((11.851851851851851e0 * u) - 0.4444444444444444e0)) - 0.3333333333333333e0))) / u) * (s * (u * (8.0e0 + (u * (21.333333333333332e0 + (64.0e0 * 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(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(0.5) + (u * ((u * ((single(11.851851851851851) * u) - single(0.4444444444444444))) - single(0.3333333333333333)))) / u) * (s * (u * (single(8.0) + (u * (single(21.333333333333332) + (single(64.0) * u)))))));
end
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(s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)\right)
Derivation
  1. Initial program 61.6%

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

      \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.6%

    \[\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)} \]
  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. sum-to-multN/A

      \[\leadsto u \cdot \left(\left(1 + \frac{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) \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) \]
    4. lower-unsound-*.f32N/A

      \[\leadsto u \cdot \left(\left(1 + \frac{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) \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.9%

    \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \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 - \frac{-64}{3} \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.7%

      \[\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) \]
  9. Applied rewrites94.7%

    \[\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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right)} \cdot u\right)\right) \]
  10. Taylor expanded in s 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(s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right)\right) \]
  11. 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(s \cdot \left(u \cdot \color{blue}{\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)}\right)\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(s \cdot \left(u \cdot \left(8 + \color{blue}{u \cdot \left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\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(s \cdot \left(u \cdot \left(8 + u \cdot \color{blue}{\left(\frac{64}{3} + 64 \cdot u\right)}\right)\right)\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(s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + \color{blue}{64 \cdot u}\right)\right)\right)\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(s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot \color{blue}{u}\right)\right)\right)\right)\right) \]
    6. lower-*.f3294.6%

      \[\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(s \cdot \left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)\right) \]
  12. Applied rewrites94.6%

    \[\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(s \cdot \color{blue}{\left(u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)}\right)\right) \]
  13. Add Preprocessing

Alternative 4: 93.6% accurate, 2.8× speedup?

\[s \cdot \left(\left(8 \cdot u - \left(\left(\frac{-64}{3} - 64 \cdot u\right) \cdot u\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
(FPCore (s u)
  :precision binary32
  (* s (+ (* (- (* 8 u) (* (* (- -64/3 (* 64 u)) u) u)) u) (* u 4))))
float code(float s, float u) {
	return s * ((((8.0f * u) - (((-21.333333333333332f - (64.0f * u)) * u) * 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) - ((((-21.333333333333332e0) - (64.0e0 * u)) * u) * u)) * u) + (u * 4.0e0))
end function
function code(s, u)
	return Float32(s * Float32(Float32(Float32(Float32(Float32(8.0) * u) - Float32(Float32(Float32(Float32(-21.333333333333332) - Float32(Float32(64.0) * u)) * u) * u)) * u) + Float32(u * Float32(4.0))))
end
function tmp = code(s, u)
	tmp = s * ((((single(8.0) * u) - (((single(-21.333333333333332) - (single(64.0) * u)) * u) * u)) * u) + (u * single(4.0)));
end
s \cdot \left(\left(8 \cdot u - \left(\left(\frac{-64}{3} - 64 \cdot u\right) \cdot u\right) \cdot u\right) \cdot u + u \cdot 4\right)
Derivation
  1. Initial program 61.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto s \cdot \left(\left(\left(u \cdot \left(64 \cdot u - \frac{-64}{3}\right) + \left(\mathsf{neg}\left(-8\right)\right)\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    7. sub-flipN/A

      \[\leadsto s \cdot \left(\left(\left(u \cdot \left(64 \cdot u + \left(\mathsf{neg}\left(\frac{-64}{3}\right)\right)\right) + \left(\mathsf{neg}\left(-8\right)\right)\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    8. metadata-evalN/A

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

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

      \[\leadsto s \cdot \left(\left(\left(u \cdot \left(\frac{64}{3} + 64 \cdot u\right) + \left(\mathsf{neg}\left(-8\right)\right)\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    11. metadata-evalN/A

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

      \[\leadsto s \cdot \left(\left(\left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    13. *-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 4\right) \]
    14. distribute-rgt-inN/A

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

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

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

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

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

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

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

    \[\leadsto s \cdot \left(\left(8 \cdot u - \left(\left(\frac{-64}{3} - 64 \cdot u\right) \cdot u\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
  9. Add Preprocessing

Alternative 5: 93.6% accurate, 3.1× speedup?

\[s \cdot \left(\left(\left(\left(64 \cdot u - \frac{-64}{3}\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
(FPCore (s u)
  :precision binary32
  (* s (+ (* (* (- (* (- (* 64 u) -64/3) u) -8) u) u) (* u 4))))
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 - \frac{-64}{3}\right) \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)
Derivation
  1. Initial program 61.6%

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

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

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

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

Alternative 6: 93.6% accurate, 3.1× speedup?

\[u \cdot \left(4 \cdot s + u \cdot \left(s \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (* u (+ (* 4 s) (* u (* s (+ 8 (* u (+ 64/3 (* 64 u)))))))))
float code(float s, float u) {
	return u * ((4.0f * s) + (u * (s * (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) + (u * (s * (8.0e0 + (u * (21.333333333333332e0 + (64.0e0 * u)))))))
end function
function code(s, u)
	return Float32(u * Float32(Float32(Float32(4.0) * s) + Float32(u * Float32(s * 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) + (u * (s * (single(8.0) + (u * (single(21.333333333333332) + (single(64.0) * u)))))));
end
u \cdot \left(4 \cdot s + u \cdot \left(s \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)
Derivation
  1. Initial program 61.6%

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

      \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.6%

    \[\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)} \]
  5. Taylor expanded in s around 0

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

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

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

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

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

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

Alternative 7: 93.3% accurate, 3.6× speedup?

\[u \cdot \left(s \cdot \left(4 + u \cdot \left(8 + u \cdot \left(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right) \]
(FPCore (s u)
  :precision binary32
  (* u (* s (+ 4 (* u (+ 8 (* u (+ 64/3 (* 64 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(\frac{64}{3} + 64 \cdot u\right)\right)\right)\right)
Derivation
  1. Initial program 61.6%

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

      \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
  4. Applied rewrites93.6%

    \[\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)} \]
  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-*.f3293.3%

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

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

Alternative 8: 91.4% accurate, 3.9× speedup?

\[s \cdot \left(\left(\left(\frac{64}{3} \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
(FPCore (s u)
  :precision binary32
  (* s (+ (* (* (- (* 64/3 u) -8) u) u) (* u 4))))
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(\frac{64}{3} \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right)
Derivation
  1. Initial program 61.6%

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

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

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

    \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - \frac{-64}{3}\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 rewrites91.4%

      \[\leadsto s \cdot \left(\left(\left(\frac{64}{3} \cdot u - -8\right) \cdot u\right) \cdot u + u \cdot 4\right) \]
    2. Add Preprocessing

    Alternative 9: 91.2% accurate, 3.9× speedup?

    \[u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right) \]
    (FPCore (s u)
      :precision binary32
      (* u (* (- 1 (* u (- (* -16/3 u) 2))) (* 4 s))))
    float code(float s, float u) {
    	return u * ((1.0f - (u * ((-5.333333333333333f * u) - 2.0f))) * (4.0f * s));
    }
    
    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 * (((-5.333333333333333e0) * u) - 2.0e0))) * (4.0e0 * s))
    end function
    
    function code(s, u)
    	return Float32(u * Float32(Float32(Float32(1.0) - Float32(u * Float32(Float32(Float32(-5.333333333333333) * u) - Float32(2.0)))) * Float32(Float32(4.0) * s)))
    end
    
    function tmp = code(s, u)
    	tmp = u * ((single(1.0) - (u * ((single(-5.333333333333333) * u) - single(2.0)))) * (single(4.0) * s));
    end
    
    u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right)
    
    Derivation
    1. Initial program 61.6%

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

        \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
    4. Applied rewrites93.6%

      \[\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)} \]
    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. sum-to-multN/A

        \[\leadsto u \cdot \left(\left(1 + \frac{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) \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) \]
      4. lower-unsound-*.f32N/A

        \[\leadsto u \cdot \left(\left(1 + \frac{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) \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.9%

      \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
    7. Step-by-step derivation
      1. lift-*.f32N/A

        \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
      2. lift-+.f32N/A

        \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \cdot \left(\color{blue}{\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. lift-/.f32N/A

        \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \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) \]
      4. sum-to-mult-revN/A

        \[\leadsto 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 + \color{blue}{4 \cdot s}\right) \]
      5. +-commutativeN/A

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

        \[\leadsto u \cdot \left(4 \cdot s - \color{blue}{\left(\mathsf{neg}\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)}\right) \]
      7. sub-to-multN/A

        \[\leadsto u \cdot \left(\left(1 - \frac{\mathsf{neg}\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)}{4 \cdot s}\right) \cdot \color{blue}{\left(4 \cdot s\right)}\right) \]
      8. lower-unsound-*.f32N/A

        \[\leadsto u \cdot \left(\left(1 - \frac{\mathsf{neg}\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)}{4 \cdot s}\right) \cdot \color{blue}{\left(4 \cdot s\right)}\right) \]
    8. Applied rewrites93.3%

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

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

        \[\leadsto u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right) \]
      2. lower--.f32N/A

        \[\leadsto u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right) \]
      3. lower-*.f3291.2%

        \[\leadsto u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right) \]
    11. Applied rewrites91.2%

      \[\leadsto u \cdot \left(\left(1 - u \cdot \left(\frac{-16}{3} \cdot u - 2\right)\right) \cdot \left(4 \cdot s\right)\right) \]
    12. Add Preprocessing

    Alternative 10: 91.2% accurate, 4.6× speedup?

    \[s \cdot \left(u \cdot \left(4 + u \cdot \left(8 + \frac{64}{3} \cdot u\right)\right)\right) \]
    (FPCore (s u)
      :precision binary32
      (* s (* u (+ 4 (* u (+ 8 (* 64/3 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 + \frac{64}{3} \cdot u\right)\right)\right)
    
    Derivation
    1. Initial program 61.6%

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

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

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

    Alternative 11: 87.0% 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 u) u) (* u 4))))
    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.6%

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

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

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

      \[\leadsto s \cdot \left(\left(\left(\left(64 \cdot u - \frac{-64}{3}\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 rewrites87.0%

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

      Alternative 12: 87.0% 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 s) (* 8 (* 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.6%

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

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

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

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

        \[\leadsto \color{blue}{u \cdot \left(4 \cdot s + 8 \cdot \left(s \cdot u\right)\right)} \]
      8. 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-*.f3287.0%

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

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

      Alternative 13: 86.8% accurate, 5.2× speedup?

      \[u \cdot \left(\left(1 - -2 \cdot u\right) \cdot \left(4 \cdot s\right)\right) \]
      (FPCore (s u)
        :precision binary32
        (* u (* (- 1 (* -2 u)) (* 4 s))))
      float code(float s, float u) {
      	return u * ((1.0f - (-2.0f * u)) * (4.0f * s));
      }
      
      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 - ((-2.0e0) * u)) * (4.0e0 * s))
      end function
      
      function code(s, u)
      	return Float32(u * Float32(Float32(Float32(1.0) - Float32(Float32(-2.0) * u)) * Float32(Float32(4.0) * s)))
      end
      
      function tmp = code(s, u)
      	tmp = u * ((single(1.0) - (single(-2.0) * u)) * (single(4.0) * s));
      end
      
      u \cdot \left(\left(1 - -2 \cdot u\right) \cdot \left(4 \cdot s\right)\right)
      
      Derivation
      1. Initial program 61.6%

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

          \[\leadsto 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 \color{blue}{u}\right)\right)\right)\right) \]
      4. Applied rewrites93.6%

        \[\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)} \]
      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. sum-to-multN/A

          \[\leadsto u \cdot \left(\left(1 + \frac{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) \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) \]
        4. lower-unsound-*.f32N/A

          \[\leadsto u \cdot \left(\left(1 + \frac{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) \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.9%

        \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
      7. Step-by-step derivation
        1. lift-*.f32N/A

          \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \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 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u\right)}\right) \]
        2. lift-+.f32N/A

          \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \cdot \left(\color{blue}{\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. lift-/.f32N/A

          \[\leadsto u \cdot \left(\left(1 + \frac{4 \cdot s}{\left(\left(\left(u \cdot s\right) \cdot 64 - \frac{-64}{3} \cdot s\right) \cdot u - -8 \cdot s\right) \cdot u}\right) \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) \]
        4. sum-to-mult-revN/A

          \[\leadsto 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 + \color{blue}{4 \cdot s}\right) \]
        5. +-commutativeN/A

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

          \[\leadsto u \cdot \left(4 \cdot s - \color{blue}{\left(\mathsf{neg}\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)}\right) \]
        7. sub-to-multN/A

          \[\leadsto u \cdot \left(\left(1 - \frac{\mathsf{neg}\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)}{4 \cdot s}\right) \cdot \color{blue}{\left(4 \cdot s\right)}\right) \]
        8. lower-unsound-*.f32N/A

          \[\leadsto u \cdot \left(\left(1 - \frac{\mathsf{neg}\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)}{4 \cdot s}\right) \cdot \color{blue}{\left(4 \cdot s\right)}\right) \]
      8. Applied rewrites93.3%

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

        \[\leadsto u \cdot \left(\left(1 - -2 \cdot u\right) \cdot \left(4 \cdot s\right)\right) \]
      10. Step-by-step derivation
        1. lower-*.f3286.8%

          \[\leadsto u \cdot \left(\left(1 - -2 \cdot u\right) \cdot \left(4 \cdot s\right)\right) \]
      11. Applied rewrites86.8%

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

      Alternative 14: 86.8% accurate, 6.6× speedup?

      \[s \cdot \left(u \cdot \left(4 + 8 \cdot u\right)\right) \]
      (FPCore (s u)
        :precision binary32
        (* s (* u (+ 4 (* 8 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.6%

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

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

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

      Alternative 15: 73.8% accurate, 11.4× speedup?

      \[s \cdot \left(u \cdot 4\right) \]
      (FPCore (s u)
        :precision binary32
        (* s (* u 4)))
      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.6%

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

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

        \[\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)} \]
      5. Taylor expanded in u around 0

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

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

        Alternative 16: 73.6% accurate, 11.4× speedup?

        \[4 \cdot \left(s \cdot u\right) \]
        (FPCore (s u)
          :precision binary32
          (* 4 (* 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.6%

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

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

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

        Reproduce

        ?
        herbie shell --seed 2025271 -o generate:evaluate
        (FPCore (s u)
          :name "Disney BSSRDF, sample scattering profile, lower"
          :precision binary32
          :pre (and (and (<= 0 s) (<= s 256)) (and (<= 2328306437/10000000000000000000 u) (<= u 1/4)))
          (* s (log (/ 1 (- 1 (* 4 u))))))