xlohi (overflows)

Percentage Accurate: 3.1% → 99.4%
Time: 3.2s
Alternatives: 8
Speedup: 9.6×

Specification

?
\[lo < -1 \cdot 10^{+308} \land hi > 10^{+308}\]
\[\frac{x - lo}{hi - lo} \]
(FPCore (lo hi x) :precision binary64 (/ (- x lo) (- hi lo)))
double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
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(lo, hi, x)
use fmin_fmax_functions
    real(8), intent (in) :: lo
    real(8), intent (in) :: hi
    real(8), intent (in) :: x
    code = (x - lo) / (hi - lo)
end function
public static double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
def code(lo, hi, x):
	return (x - lo) / (hi - lo)
function code(lo, hi, x)
	return Float64(Float64(x - lo) / Float64(hi - lo))
end
function tmp = code(lo, hi, x)
	tmp = (x - lo) / (hi - lo);
end
code[lo_, hi_, x_] := N[(N[(x - lo), $MachinePrecision] / N[(hi - lo), $MachinePrecision]), $MachinePrecision]
\frac{x - lo}{hi - lo}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 3.1% accurate, 1.0× speedup?

\[\frac{x - lo}{hi - lo} \]
(FPCore (lo hi x) :precision binary64 (/ (- x lo) (- hi lo)))
double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
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(lo, hi, x)
use fmin_fmax_functions
    real(8), intent (in) :: lo
    real(8), intent (in) :: hi
    real(8), intent (in) :: x
    code = (x - lo) / (hi - lo)
end function
public static double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
def code(lo, hi, x):
	return (x - lo) / (hi - lo)
function code(lo, hi, x)
	return Float64(Float64(x - lo) / Float64(hi - lo))
end
function tmp = code(lo, hi, x)
	tmp = (x - lo) / (hi - lo);
end
code[lo_, hi_, x_] := N[(N[(x - lo), $MachinePrecision] / N[(hi - lo), $MachinePrecision]), $MachinePrecision]
\frac{x - lo}{hi - lo}

Alternative 1: 99.4% accurate, 0.4× speedup?

\[\frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)} \]
(FPCore (lo hi x)
 :precision binary64
 (/ 1.0 (fma -1.0 (/ lo (- x lo)) (/ 1.0 (/ (- x lo) hi)))))
double code(double lo, double hi, double x) {
	return 1.0 / fma(-1.0, (lo / (x - lo)), (1.0 / ((x - lo) / hi)));
}
function code(lo, hi, x)
	return Float64(1.0 / fma(-1.0, Float64(lo / Float64(x - lo)), Float64(1.0 / Float64(Float64(x - lo) / hi))))
end
code[lo_, hi_, x_] := N[(1.0 / N[(-1.0 * N[(lo / N[(x - lo), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[(x - lo), $MachinePrecision] / hi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)}
Derivation
  1. Initial program 3.1%

    \[\frac{x - lo}{hi - lo} \]
  2. Taylor expanded in lo around 0

    \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
  3. Step-by-step derivation
    1. Applied rewrites18.8%

      \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
    2. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
      2. div-flipN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
      4. lower-unsound-/.f6418.8%

        \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
    3. Applied rewrites18.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
    4. Taylor expanded in hi around 0

      \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{lo}{x - lo} + \frac{hi}{x - lo}}} \]
    5. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \color{blue}{\frac{lo}{x - lo}}, \frac{hi}{x - lo}\right)} \]
      2. lower-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{\color{blue}{x - lo}}, \frac{hi}{x - lo}\right)} \]
      3. lower--.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - \color{blue}{lo}}, \frac{hi}{x - lo}\right)} \]
      4. lower-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
      5. lower--.f6499.4%

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
    6. Applied rewrites99.4%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
      2. div-flipN/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)} \]
      3. lower-unsound-/.f64N/A

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)} \]
      4. lower-unsound-/.f6499.4%

        \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)} \]
    8. Applied rewrites99.4%

      \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{1}{\frac{x - lo}{hi}}\right)} \]
    9. Add Preprocessing

    Alternative 2: 99.4% accurate, 0.5× speedup?

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

      \[\frac{x - lo}{hi - lo} \]
    2. Taylor expanded in lo around 0

      \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
    3. Step-by-step derivation
      1. Applied rewrites18.8%

        \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
      2. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
        2. div-flipN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
        3. lower-unsound-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
        4. lower-unsound-/.f6418.8%

          \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
      3. Applied rewrites18.8%

        \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
      4. Taylor expanded in hi around 0

        \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{lo}{x - lo} + \frac{hi}{x - lo}}} \]
      5. Step-by-step derivation
        1. lower-fma.f64N/A

          \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \color{blue}{\frac{lo}{x - lo}}, \frac{hi}{x - lo}\right)} \]
        2. lower-/.f64N/A

          \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{\color{blue}{x - lo}}, \frac{hi}{x - lo}\right)} \]
        3. lower--.f64N/A

          \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - \color{blue}{lo}}, \frac{hi}{x - lo}\right)} \]
        4. lower-/.f64N/A

          \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
        5. lower--.f6499.4%

          \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
      6. Applied rewrites99.4%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)}} \]
      7. Step-by-step derivation
        1. lift-fma.f64N/A

          \[\leadsto \frac{1}{-1 \cdot \frac{lo}{x - lo} + \color{blue}{\frac{hi}{x - lo}}} \]
        2. add-flipN/A

          \[\leadsto \frac{1}{-1 \cdot \frac{lo}{x - lo} - \color{blue}{\left(\mathsf{neg}\left(\frac{hi}{x - lo}\right)\right)}} \]
        3. lower--.f64N/A

          \[\leadsto \frac{1}{-1 \cdot \frac{lo}{x - lo} - \color{blue}{\left(\mathsf{neg}\left(\frac{hi}{x - lo}\right)\right)}} \]
        4. mul-1-negN/A

          \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{lo}{x - lo}\right)\right) - \left(\mathsf{neg}\left(\color{blue}{\frac{hi}{x - lo}}\right)\right)} \]
        5. lift-/.f64N/A

          \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\frac{lo}{x - lo}\right)\right) - \left(\mathsf{neg}\left(\frac{\color{blue}{hi}}{x - lo}\right)\right)} \]
        6. distribute-neg-frac2N/A

          \[\leadsto \frac{1}{\frac{lo}{\mathsf{neg}\left(\left(x - lo\right)\right)} - \left(\mathsf{neg}\left(\color{blue}{\frac{hi}{x - lo}}\right)\right)} \]
        7. lift--.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{\mathsf{neg}\left(\left(x - lo\right)\right)} - \left(\mathsf{neg}\left(\frac{hi}{\color{blue}{x} - lo}\right)\right)} \]
        8. sub-negate-revN/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \left(\mathsf{neg}\left(\frac{hi}{\color{blue}{x - lo}}\right)\right)} \]
        9. lift--.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \left(\mathsf{neg}\left(\frac{hi}{\color{blue}{x - lo}}\right)\right)} \]
        10. lower-/.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \left(\mathsf{neg}\left(\color{blue}{\frac{hi}{x - lo}}\right)\right)} \]
        11. lift-/.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \left(\mathsf{neg}\left(\frac{hi}{x - lo}\right)\right)} \]
        12. distribute-neg-frac2N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \frac{hi}{\color{blue}{\mathsf{neg}\left(\left(x - lo\right)\right)}}} \]
        13. lift--.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \frac{hi}{\mathsf{neg}\left(\left(x - lo\right)\right)}} \]
        14. sub-negate-revN/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \frac{hi}{lo - \color{blue}{x}}} \]
        15. lift--.f64N/A

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \frac{hi}{lo - \color{blue}{x}}} \]
        16. lower-/.f6499.4%

          \[\leadsto \frac{1}{\frac{lo}{lo - x} - \frac{hi}{\color{blue}{lo - x}}} \]
      8. Applied rewrites99.4%

        \[\leadsto \frac{1}{\frac{lo}{lo - x} - \color{blue}{\frac{hi}{lo - x}}} \]
      9. Add Preprocessing

      Alternative 3: 98.4% accurate, 0.6× speedup?

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

        \[\frac{x - lo}{hi - lo} \]
      2. Taylor expanded in lo around 0

        \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
      3. Step-by-step derivation
        1. Applied rewrites18.8%

          \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
        2. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
          2. div-flipN/A

            \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
          3. lower-unsound-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
          4. lower-unsound-/.f6418.8%

            \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
        3. Applied rewrites18.8%

          \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
        4. Taylor expanded in lo around -inf

          \[\leadsto \frac{1}{\color{blue}{1 + -1 \cdot \frac{hi - x}{lo}}} \]
        5. Step-by-step derivation
          1. lower-+.f64N/A

            \[\leadsto \frac{1}{1 + \color{blue}{-1 \cdot \frac{hi - x}{lo}}} \]
          2. lower-*.f64N/A

            \[\leadsto \frac{1}{1 + -1 \cdot \color{blue}{\frac{hi - x}{lo}}} \]
          3. lower-/.f64N/A

            \[\leadsto \frac{1}{1 + -1 \cdot \frac{hi - x}{\color{blue}{lo}}} \]
          4. lower--.f6498.4%

            \[\leadsto \frac{1}{1 + -1 \cdot \frac{hi - x}{lo}} \]
        6. Applied rewrites98.4%

          \[\leadsto \frac{1}{\color{blue}{1 + -1 \cdot \frac{hi - x}{lo}}} \]
        7. Add Preprocessing

        Alternative 4: 98.4% accurate, 0.6× speedup?

        \[\frac{1}{\mathsf{fma}\left(-1, -1, \frac{hi}{x - lo}\right)} \]
        (FPCore (lo hi x) :precision binary64 (/ 1.0 (fma -1.0 -1.0 (/ hi (- x lo)))))
        double code(double lo, double hi, double x) {
        	return 1.0 / fma(-1.0, -1.0, (hi / (x - lo)));
        }
        
        function code(lo, hi, x)
        	return Float64(1.0 / fma(-1.0, -1.0, Float64(hi / Float64(x - lo))))
        end
        
        code[lo_, hi_, x_] := N[(1.0 / N[(-1.0 * -1.0 + N[(hi / N[(x - lo), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \frac{1}{\mathsf{fma}\left(-1, -1, \frac{hi}{x - lo}\right)}
        
        Derivation
        1. Initial program 3.1%

          \[\frac{x - lo}{hi - lo} \]
        2. Taylor expanded in lo around 0

          \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
        3. Step-by-step derivation
          1. Applied rewrites18.8%

            \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
          2. Step-by-step derivation
            1. lift-/.f64N/A

              \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
            2. div-flipN/A

              \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
            3. lower-unsound-/.f64N/A

              \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
            4. lower-unsound-/.f6418.8%

              \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
          3. Applied rewrites18.8%

            \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
          4. Taylor expanded in hi around 0

            \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{lo}{x - lo} + \frac{hi}{x - lo}}} \]
          5. Step-by-step derivation
            1. lower-fma.f64N/A

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \color{blue}{\frac{lo}{x - lo}}, \frac{hi}{x - lo}\right)} \]
            2. lower-/.f64N/A

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{\color{blue}{x - lo}}, \frac{hi}{x - lo}\right)} \]
            3. lower--.f64N/A

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - \color{blue}{lo}}, \frac{hi}{x - lo}\right)} \]
            4. lower-/.f64N/A

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
            5. lower--.f6499.4%

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
          6. Applied rewrites99.4%

            \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)}} \]
          7. Taylor expanded in lo around inf

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

              \[\leadsto \frac{1}{\mathsf{fma}\left(-1, -1, \frac{hi}{x - lo}\right)} \]
            2. Add Preprocessing

            Alternative 5: 98.4% accurate, 0.7× speedup?

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

              \[\frac{x - lo}{hi - lo} \]
            2. Taylor expanded in lo around 0

              \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
            3. Step-by-step derivation
              1. Applied rewrites18.8%

                \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
              2. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
                2. div-flipN/A

                  \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
                3. lower-unsound-/.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
                4. lower-unsound-/.f6418.8%

                  \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
              3. Applied rewrites18.8%

                \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
              4. Taylor expanded in hi around 0

                \[\leadsto \frac{1}{\color{blue}{-1 \cdot \frac{lo}{x - lo} + \frac{hi}{x - lo}}} \]
              5. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \color{blue}{\frac{lo}{x - lo}}, \frac{hi}{x - lo}\right)} \]
                2. lower-/.f64N/A

                  \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{\color{blue}{x - lo}}, \frac{hi}{x - lo}\right)} \]
                3. lower--.f64N/A

                  \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - \color{blue}{lo}}, \frac{hi}{x - lo}\right)} \]
                4. lower-/.f64N/A

                  \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
                5. lower--.f6499.4%

                  \[\leadsto \frac{1}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)} \]
              6. Applied rewrites99.4%

                \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-1, \frac{lo}{x - lo}, \frac{hi}{x - lo}\right)}} \]
              7. Taylor expanded in x around 0

                \[\leadsto \frac{1}{1 + \color{blue}{-1 \cdot \frac{hi}{lo}}} \]
              8. Step-by-step derivation
                1. lower-+.f64N/A

                  \[\leadsto \frac{1}{1 + -1 \cdot \color{blue}{\frac{hi}{lo}}} \]
                2. lower-*.f64N/A

                  \[\leadsto \frac{1}{1 + -1 \cdot \frac{hi}{\color{blue}{lo}}} \]
                3. lower-/.f6498.4%

                  \[\leadsto \frac{1}{1 + -1 \cdot \frac{hi}{lo}} \]
              9. Applied rewrites98.4%

                \[\leadsto \frac{1}{1 + \color{blue}{-1 \cdot \frac{hi}{lo}}} \]
              10. Add Preprocessing

              Alternative 6: 18.8% accurate, 1.4× speedup?

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

                \[\frac{x - lo}{hi - lo} \]
              2. Taylor expanded in lo around 0

                \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
              3. Step-by-step derivation
                1. Applied rewrites18.8%

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

                Alternative 7: 18.8% accurate, 1.8× speedup?

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

                  \[\frac{x - lo}{hi - lo} \]
                2. Taylor expanded in lo around 0

                  \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
                3. Step-by-step derivation
                  1. Applied rewrites18.8%

                    \[\leadsto \frac{x - lo}{\color{blue}{hi}} \]
                  2. Step-by-step derivation
                    1. lift-/.f64N/A

                      \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
                    2. div-flipN/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
                    3. lower-unsound-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
                    4. lower-unsound-/.f6418.8%

                      \[\leadsto \frac{1}{\color{blue}{\frac{hi}{x - lo}}} \]
                  3. Applied rewrites18.8%

                    \[\leadsto \color{blue}{\frac{1}{\frac{hi}{x - lo}}} \]
                  4. Taylor expanded in lo around inf

                    \[\leadsto \frac{1}{\frac{hi}{\color{blue}{-1 \cdot lo}}} \]
                  5. Step-by-step derivation
                    1. lower-*.f6418.8%

                      \[\leadsto \frac{1}{\frac{hi}{-1 \cdot \color{blue}{lo}}} \]
                  6. Applied rewrites18.8%

                    \[\leadsto \frac{1}{\frac{hi}{\color{blue}{-1 \cdot lo}}} \]
                  7. Step-by-step derivation
                    1. lift-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\frac{hi}{-1 \cdot lo}}} \]
                    2. lift-/.f64N/A

                      \[\leadsto \frac{1}{\color{blue}{\frac{hi}{-1 \cdot lo}}} \]
                    3. div-flip-revN/A

                      \[\leadsto \color{blue}{\frac{-1 \cdot lo}{hi}} \]
                    4. lower-/.f6418.8%

                      \[\leadsto \color{blue}{\frac{-1 \cdot lo}{hi}} \]
                    5. lift-*.f64N/A

                      \[\leadsto \frac{-1 \cdot \color{blue}{lo}}{hi} \]
                    6. mul-1-negN/A

                      \[\leadsto \frac{\mathsf{neg}\left(lo\right)}{hi} \]
                    7. lower-neg.f6418.8%

                      \[\leadsto \frac{-lo}{hi} \]
                  8. Applied rewrites18.8%

                    \[\leadsto \color{blue}{\frac{-lo}{hi}} \]
                  9. Add Preprocessing

                  Alternative 8: 18.7% accurate, 9.6× speedup?

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

                    \[\frac{x - lo}{hi - lo} \]
                  2. Taylor expanded in lo around inf

                    \[\leadsto \color{blue}{1} \]
                  3. Step-by-step derivation
                    1. Applied rewrites18.7%

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

                    Reproduce

                    ?
                    herbie shell --seed 2025191 
                    (FPCore (lo hi x)
                      :name "xlohi (overflows)"
                      :precision binary64
                      :pre (and (< lo -1e+308) (> hi 1e+308))
                      (/ (- x lo) (- hi lo)))