bug500 (missed optimization)

Percentage Accurate: 70.1% → 98.7%
Time: 2.5s
Alternatives: 7
Speedup: 3.6×

Specification

?
\[-1000 < x \land x < 1000\]
\[\sin x - x \]
(FPCore (x) :precision binary64 (- (sin x) x))
double code(double x) {
	return sin(x) - x;
}
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(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = sin(x) - x
end function
public static double code(double x) {
	return Math.sin(x) - x;
}
def code(x):
	return math.sin(x) - x
function code(x)
	return Float64(sin(x) - x)
end
function tmp = code(x)
	tmp = sin(x) - x;
end
code[x_] := N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]
\sin x - x

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

\[\sin x - x \]
(FPCore (x) :precision binary64 (- (sin x) x))
double code(double x) {
	return sin(x) - x;
}
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(8) function code(x)
use fmin_fmax_functions
    real(8), intent (in) :: x
    code = sin(x) - x
end function
public static double code(double x) {
	return Math.sin(x) - x;
}
def code(x):
	return math.sin(x) - x
function code(x)
	return Float64(sin(x) - x)
end
function tmp = code(x)
	tmp = sin(x) - x;
end
code[x_] := N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]
\sin x - x

Alternative 1: 98.7% accurate, 1.1× speedup?

\[\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
(FPCore (x)
 :precision binary64
 (*
  (*
   (*
    (fma
     (*
      (fma
       (fma 2.7557319223985893e-6 (* x x) -0.0001984126984126984)
       (* x x)
       0.008333333333333333)
      x)
     x
     -0.16666666666666666)
    x)
   x)
  x))
double code(double x) {
	return ((fma((fma(fma(2.7557319223985893e-6, (x * x), -0.0001984126984126984), (x * x), 0.008333333333333333) * x), x, -0.16666666666666666) * x) * x) * x;
}
function code(x)
	return Float64(Float64(Float64(fma(Float64(fma(fma(2.7557319223985893e-6, Float64(x * x), -0.0001984126984126984), Float64(x * x), 0.008333333333333333) * x), x, -0.16666666666666666) * x) * x) * x)
end
code[x_] := N[(N[(N[(N[(N[(N[(N[(2.7557319223985893e-6 * N[(x * x), $MachinePrecision] + -0.0001984126984126984), $MachinePrecision] * N[(x * x), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * x), $MachinePrecision] * x + -0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x
Derivation
  1. Initial program 70.1%

    \[\sin x - x \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right)} - \frac{1}{6}\right) \]
    3. lower--.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \color{blue}{\frac{1}{6}}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    6. lower-+.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    8. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    9. lower--.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    10. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    11. lower-pow.f6498.8%

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right) \]
  4. Applied rewrites98.8%

    \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \color{blue}{{x}^{3}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{\color{blue}{3}} \]
    4. unpow3N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{x}\right) \]
    5. unpow2N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
    6. lift-pow.f64N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
    7. associate-*r*N/A

      \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
    8. lower-*.f64N/A

      \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
  6. Applied rewrites98.7%

    \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{x} \]
  7. Add Preprocessing

Alternative 2: 98.7% accurate, 1.4× speedup?

\[\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
(FPCore (x)
 :precision binary64
 (*
  (*
   (*
    (fma
     (* (fma -0.0001984126984126984 (* x x) 0.008333333333333333) x)
     x
     -0.16666666666666666)
    x)
   x)
  x))
double code(double x) {
	return ((fma((fma(-0.0001984126984126984, (x * x), 0.008333333333333333) * x), x, -0.16666666666666666) * x) * x) * x;
}
function code(x)
	return Float64(Float64(Float64(fma(Float64(fma(-0.0001984126984126984, Float64(x * x), 0.008333333333333333) * x), x, -0.16666666666666666) * x) * x) * x)
end
code[x_] := N[(N[(N[(N[(N[(N[(-0.0001984126984126984 * N[(x * x), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] * x), $MachinePrecision] * x + -0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x
Derivation
  1. Initial program 70.1%

    \[\sin x - x \]
  2. Taylor expanded in x around 0

    \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
    2. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right)} - \frac{1}{6}\right) \]
    3. lower--.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \color{blue}{\frac{1}{6}}\right) \]
    4. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    5. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    6. lower-+.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    7. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    8. lower-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    9. lower--.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    10. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
    11. lower-pow.f6498.8%

      \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right) \]
  4. Applied rewrites98.8%

    \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \color{blue}{{x}^{3}} \]
    3. lift-pow.f64N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{\color{blue}{3}} \]
    4. unpow3N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{x}\right) \]
    5. unpow2N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
    6. lift-pow.f64N/A

      \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
    7. associate-*r*N/A

      \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
    8. lower-*.f64N/A

      \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
  6. Applied rewrites98.7%

    \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{x} \]
  7. Taylor expanded in x around 0

    \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{-1}{5040}, x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
  8. Step-by-step derivation
    1. Applied rewrites98.7%

      \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.0001984126984126984, x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
    2. Add Preprocessing

    Alternative 3: 98.4% accurate, 2.0× speedup?

    \[\left(\left(\mathsf{fma}\left(0.008333333333333333 \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
    (FPCore (x)
     :precision binary64
     (* (* (* (fma (* 0.008333333333333333 x) x -0.16666666666666666) x) x) x))
    double code(double x) {
    	return ((fma((0.008333333333333333 * x), x, -0.16666666666666666) * x) * x) * x;
    }
    
    function code(x)
    	return Float64(Float64(Float64(fma(Float64(0.008333333333333333 * x), x, -0.16666666666666666) * x) * x) * x)
    end
    
    code[x_] := N[(N[(N[(N[(N[(0.008333333333333333 * x), $MachinePrecision] * x + -0.16666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
    
    \left(\left(\mathsf{fma}\left(0.008333333333333333 \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x
    
    Derivation
    1. Initial program 70.1%

      \[\sin x - x \]
    2. Taylor expanded in x around 0

      \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
      2. lower-pow.f64N/A

        \[\leadsto {x}^{3} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right)} - \frac{1}{6}\right) \]
      3. lower--.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \color{blue}{\frac{1}{6}}\right) \]
      4. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      5. lower-pow.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      6. lower-+.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      7. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      8. lower-pow.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      9. lower--.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      10. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
      11. lower-pow.f6498.8%

        \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right) \]
    4. Applied rewrites98.8%

      \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \color{blue}{{x}^{3}} \]
      3. lift-pow.f64N/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{\color{blue}{3}} \]
      4. unpow3N/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{x}\right) \]
      5. unpow2N/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
      6. lift-pow.f64N/A

        \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
      7. associate-*r*N/A

        \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
      8. lower-*.f64N/A

        \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
    6. Applied rewrites98.7%

      \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{x} \]
    7. Taylor expanded in x around 0

      \[\leadsto \left(\left(\mathsf{fma}\left(\frac{1}{120} \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
    8. Step-by-step derivation
      1. Applied rewrites98.4%

        \[\leadsto \left(\left(\mathsf{fma}\left(0.008333333333333333 \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot x \]
      2. Add Preprocessing

      Alternative 4: 98.0% accurate, 3.6× speedup?

      \[\left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x \]
      (FPCore (x) :precision binary64 (* (* (* -0.16666666666666666 x) x) x))
      double code(double x) {
      	return ((-0.16666666666666666 * x) * x) * x;
      }
      
      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(8) function code(x)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          code = (((-0.16666666666666666d0) * x) * x) * x
      end function
      
      public static double code(double x) {
      	return ((-0.16666666666666666 * x) * x) * x;
      }
      
      def code(x):
      	return ((-0.16666666666666666 * x) * x) * x
      
      function code(x)
      	return Float64(Float64(Float64(-0.16666666666666666 * x) * x) * x)
      end
      
      function tmp = code(x)
      	tmp = ((-0.16666666666666666 * x) * x) * x;
      end
      
      code[x_] := N[(N[(N[(-0.16666666666666666 * x), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]
      
      \left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x
      
      Derivation
      1. Initial program 70.1%

        \[\sin x - x \]
      2. Taylor expanded in x around 0

        \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
        2. lower-pow.f64N/A

          \[\leadsto {x}^{3} \cdot \left(\color{blue}{{x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right)} - \frac{1}{6}\right) \]
        3. lower--.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \color{blue}{\frac{1}{6}}\right) \]
        4. lower-*.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        5. lower-pow.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        6. lower-+.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        7. lower-*.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        8. lower-pow.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        9. lower--.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        10. lower-*.f64N/A

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \]
        11. lower-pow.f6498.8%

          \[\leadsto {x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right) \]
      4. Applied rewrites98.8%

        \[\leadsto \color{blue}{{x}^{3} \cdot \left({x}^{2} \cdot \left(0.008333333333333333 + {x}^{2} \cdot \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{2} - 0.0001984126984126984\right)\right) - 0.16666666666666666\right)} \]
      5. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto {x}^{3} \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right)} \]
        2. *-commutativeN/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \color{blue}{{x}^{3}} \]
        3. lift-pow.f64N/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{\color{blue}{3}} \]
        4. unpow3N/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{x}\right) \]
        5. unpow2N/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
        6. lift-pow.f64N/A

          \[\leadsto \left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot \left({x}^{2} \cdot x\right) \]
        7. associate-*r*N/A

          \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
        8. lower-*.f64N/A

          \[\leadsto \left(\left({x}^{2} \cdot \left(\frac{1}{120} + {x}^{2} \cdot \left(\frac{1}{362880} \cdot {x}^{2} - \frac{1}{5040}\right)\right) - \frac{1}{6}\right) \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
      6. Applied rewrites98.7%

        \[\leadsto \left(\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(2.7557319223985893 \cdot 10^{-6}, x \cdot x, -0.0001984126984126984\right), x \cdot x, 0.008333333333333333\right) \cdot x, x, -0.16666666666666666\right) \cdot x\right) \cdot x\right) \cdot \color{blue}{x} \]
      7. Taylor expanded in x around 0

        \[\leadsto \left(\left(\frac{-1}{6} \cdot x\right) \cdot x\right) \cdot x \]
      8. Step-by-step derivation
        1. Applied rewrites98.0%

          \[\leadsto \left(\left(-0.16666666666666666 \cdot x\right) \cdot x\right) \cdot x \]
        2. Add Preprocessing

        Alternative 5: 98.0% accurate, 3.6× speedup?

        \[\left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot x \]
        (FPCore (x) :precision binary64 (* (* -0.16666666666666666 (* x x)) x))
        double code(double x) {
        	return (-0.16666666666666666 * (x * x)) * x;
        }
        
        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(8) function code(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            code = ((-0.16666666666666666d0) * (x * x)) * x
        end function
        
        public static double code(double x) {
        	return (-0.16666666666666666 * (x * x)) * x;
        }
        
        def code(x):
        	return (-0.16666666666666666 * (x * x)) * x
        
        function code(x)
        	return Float64(Float64(-0.16666666666666666 * Float64(x * x)) * x)
        end
        
        function tmp = code(x)
        	tmp = (-0.16666666666666666 * (x * x)) * x;
        end
        
        code[x_] := N[(N[(-0.16666666666666666 * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]
        
        \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot x
        
        Derivation
        1. Initial program 70.1%

          \[\sin x - x \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\frac{-1}{6} \cdot {x}^{3}} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \frac{-1}{6} \cdot \color{blue}{{x}^{3}} \]
          2. lower-pow.f6498.0%

            \[\leadsto -0.16666666666666666 \cdot {x}^{\color{blue}{3}} \]
        4. Applied rewrites98.0%

          \[\leadsto \color{blue}{-0.16666666666666666 \cdot {x}^{3}} \]
        5. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{-1}{6} \cdot \color{blue}{{x}^{3}} \]
          2. lift-pow.f64N/A

            \[\leadsto \frac{-1}{6} \cdot {x}^{\color{blue}{3}} \]
          3. unpow3N/A

            \[\leadsto \frac{-1}{6} \cdot \left(\left(x \cdot x\right) \cdot \color{blue}{x}\right) \]
          4. unpow2N/A

            \[\leadsto \frac{-1}{6} \cdot \left({x}^{2} \cdot x\right) \]
          5. lift-pow.f64N/A

            \[\leadsto \frac{-1}{6} \cdot \left({x}^{2} \cdot x\right) \]
          6. associate-*l*N/A

            \[\leadsto \left(\frac{-1}{6} \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
          7. lift-*.f64N/A

            \[\leadsto \left(\frac{-1}{6} \cdot {x}^{2}\right) \cdot x \]
          8. lower-*.f6498.0%

            \[\leadsto \left(-0.16666666666666666 \cdot {x}^{2}\right) \cdot \color{blue}{x} \]
          9. lift-pow.f64N/A

            \[\leadsto \left(\frac{-1}{6} \cdot {x}^{2}\right) \cdot x \]
          10. unpow2N/A

            \[\leadsto \left(\frac{-1}{6} \cdot \left(x \cdot x\right)\right) \cdot x \]
          11. lower-*.f6498.0%

            \[\leadsto \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot x \]
        6. Applied rewrites98.0%

          \[\leadsto \left(-0.16666666666666666 \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{x} \]
        7. Add Preprocessing

        Alternative 6: 67.6% accurate, 9.8× speedup?

        \[x - x \]
        (FPCore (x) :precision binary64 (- x x))
        double code(double x) {
        	return x - x;
        }
        
        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(8) function code(x)
        use fmin_fmax_functions
            real(8), intent (in) :: x
            code = x - x
        end function
        
        public static double code(double x) {
        	return x - x;
        }
        
        def code(x):
        	return x - x
        
        function code(x)
        	return Float64(x - x)
        end
        
        function tmp = code(x)
        	tmp = x - x;
        end
        
        code[x_] := N[(x - x), $MachinePrecision]
        
        x - x
        
        Derivation
        1. Initial program 70.1%

          \[\sin x - x \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{x} - x \]
        3. Step-by-step derivation
          1. Applied rewrites67.6%

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

          Alternative 7: 6.5% accurate, 18.0× speedup?

          \[-x \]
          (FPCore (x) :precision binary64 (- x))
          double code(double x) {
          	return -x;
          }
          
          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(8) function code(x)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              code = -x
          end function
          
          public static double code(double x) {
          	return -x;
          }
          
          def code(x):
          	return -x
          
          function code(x)
          	return Float64(-x)
          end
          
          function tmp = code(x)
          	tmp = -x;
          end
          
          code[x_] := (-x)
          
          -x
          
          Derivation
          1. Initial program 70.1%

            \[\sin x - x \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{-1 \cdot x} \]
          3. Step-by-step derivation
            1. lower-*.f646.5%

              \[\leadsto -1 \cdot \color{blue}{x} \]
          4. Applied rewrites6.5%

            \[\leadsto \color{blue}{-1 \cdot x} \]
          5. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto -1 \cdot \color{blue}{x} \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{neg}\left(x\right) \]
            3. lower-neg.f646.5%

              \[\leadsto -x \]
          6. Applied rewrites6.5%

            \[\leadsto -x \]
          7. Add Preprocessing

          Reproduce

          ?
          herbie shell --seed 2025193 
          (FPCore (x)
            :name "bug500 (missed optimization)"
            :precision binary64
            :pre (and (< -1000.0 x) (< x 1000.0))
            (- (sin x) x))