xlohi (overflows)

Percentage Accurate: 3.1% → 99.4%
Time: 17.8s
Alternatives: 7
Speedup: 18.0×

Specification

?
\[lo < -1 \cdot 10^{+308} \land hi > 10^{+308}\]
\[\begin{array}{l} \\ \frac{x - lo}{hi - lo} \end{array} \]
(FPCore (lo hi x) :precision binary64 (/ (- x lo) (- hi lo)))
double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
real(8) function code(lo, hi, x)
    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]
\begin{array}{l}

\\
\frac{x - lo}{hi - lo}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

\[\begin{array}{l} \\ \frac{x - lo}{hi - lo} \end{array} \]
(FPCore (lo hi x) :precision binary64 (/ (- x lo) (- hi lo)))
double code(double lo, double hi, double x) {
	return (x - lo) / (hi - lo);
}
real(8) function code(lo, hi, x)
    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]
\begin{array}{l}

\\
\frac{x - lo}{hi - lo}
\end{array}

Alternative 1: 99.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\frac{lo}{lo - x}, 1, \frac{hi}{x - lo}\right)\\ {\left(t\_0 \cdot t\_0\right)}^{-0.5} \end{array} \end{array} \]
(FPCore (lo hi x)
 :precision binary64
 (let* ((t_0 (fma (/ lo (- lo x)) 1.0 (/ hi (- x lo)))))
   (pow (* t_0 t_0) -0.5)))
double code(double lo, double hi, double x) {
	double t_0 = fma((lo / (lo - x)), 1.0, (hi / (x - lo)));
	return pow((t_0 * t_0), -0.5);
}
function code(lo, hi, x)
	t_0 = fma(Float64(lo / Float64(lo - x)), 1.0, Float64(hi / Float64(x - lo)))
	return Float64(t_0 * t_0) ^ -0.5
end
code[lo_, hi_, x_] := Block[{t$95$0 = N[(N[(lo / N[(lo - x), $MachinePrecision]), $MachinePrecision] * 1.0 + N[(hi / N[(x - lo), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[Power[N[(t$95$0 * t$95$0), $MachinePrecision], -0.5], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{lo}{lo - x}, 1, \frac{hi}{x - lo}\right)\\
{\left(t\_0 \cdot t\_0\right)}^{-0.5}
\end{array}
\end{array}
Derivation
  1. Initial program 3.1%

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

    \[\leadsto \color{blue}{\frac{\left(x + \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right) - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi}} \]
  4. Step-by-step derivation
    1. remove-double-negN/A

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

      \[\leadsto \frac{\left(x + \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}}\right)\right)\right) - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi} \]
    3. sub-negN/A

      \[\leadsto \frac{\color{blue}{\left(x - -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)} - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi} \]
    4. associate--r+N/A

      \[\leadsto \frac{\color{blue}{x - \left(-1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}} + \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)\right)}}{hi} \]
    5. +-commutativeN/A

      \[\leadsto \frac{x - \color{blue}{\left(\left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right) + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)}}{hi} \]
    6. associate-+r+N/A

      \[\leadsto \frac{x - \color{blue}{\left(lo + \left(-1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi} + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)\right)}}{hi} \]
    7. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{x - \left(lo + \left(-1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi} + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)\right)}{hi}} \]
  5. Applied rewrites14.4%

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

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

      \[\leadsto \frac{1}{-1 \cdot \color{blue}{\left(hi \cdot \left(-1 \cdot \frac{\left(-1 \cdot \frac{{lo}^{2}}{hi \cdot \left(x - lo\right)} + \frac{{lo}^{2}}{hi \cdot \left(x - lo\right)}\right) - \frac{lo}{x - lo}}{hi} - \frac{1}{x - lo}\right)\right)}} \]
    3. Step-by-step derivation
      1. Applied rewrites98.9%

        \[\leadsto \frac{1}{\left(-hi\right) \cdot \color{blue}{\left(\frac{-\frac{lo}{x - lo}}{-hi} + \frac{-1}{x - lo}\right)}} \]
      2. Step-by-step derivation
        1. Applied rewrites99.4%

          \[\leadsto {\left(\mathsf{fma}\left(-\frac{lo}{x - lo}, 1, \frac{hi}{x - lo}\right) \cdot \mathsf{fma}\left(-\frac{lo}{x - lo}, 1, \frac{hi}{x - lo}\right)\right)}^{\color{blue}{-0.5}} \]
        2. Final simplification99.4%

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

        Alternative 2: 99.4% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \frac{1}{\frac{lo}{lo - x} + \frac{hi}{x - lo}} \end{array} \]
        (FPCore (lo hi x)
         :precision binary64
         (/ 1.0 (+ (/ lo (- lo x)) (/ hi (- x lo)))))
        double code(double lo, double hi, double x) {
        	return 1.0 / ((lo / (lo - x)) + (hi / (x - lo)));
        }
        
        real(8) function code(lo, hi, x)
            real(8), intent (in) :: lo
            real(8), intent (in) :: hi
            real(8), intent (in) :: x
            code = 1.0d0 / ((lo / (lo - x)) + (hi / (x - lo)))
        end function
        
        public static double code(double lo, double hi, double x) {
        	return 1.0 / ((lo / (lo - x)) + (hi / (x - lo)));
        }
        
        def code(lo, hi, x):
        	return 1.0 / ((lo / (lo - x)) + (hi / (x - lo)))
        
        function code(lo, hi, x)
        	return Float64(1.0 / Float64(Float64(lo / Float64(lo - x)) + Float64(hi / Float64(x - lo))))
        end
        
        function tmp = code(lo, hi, x)
        	tmp = 1.0 / ((lo / (lo - x)) + (hi / (x - lo)));
        end
        
        code[lo_, hi_, x_] := N[(1.0 / N[(N[(lo / N[(lo - x), $MachinePrecision]), $MachinePrecision] + N[(hi / N[(x - lo), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{1}{\frac{lo}{lo - x} + \frac{hi}{x - lo}}
        \end{array}
        
        Derivation
        1. Initial program 3.1%

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

          \[\leadsto \color{blue}{\frac{\left(x + \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right) - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi}} \]
        4. Step-by-step derivation
          1. remove-double-negN/A

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

            \[\leadsto \frac{\left(x + \left(\mathsf{neg}\left(\color{blue}{-1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}}\right)\right)\right) - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi} \]
          3. sub-negN/A

            \[\leadsto \frac{\color{blue}{\left(x - -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)} - \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)}{hi} \]
          4. associate--r+N/A

            \[\leadsto \frac{\color{blue}{x - \left(-1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}} + \left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right)\right)}}{hi} \]
          5. +-commutativeN/A

            \[\leadsto \frac{x - \color{blue}{\left(\left(lo + -1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi}\right) + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)}}{hi} \]
          6. associate-+r+N/A

            \[\leadsto \frac{x - \color{blue}{\left(lo + \left(-1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi} + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)\right)}}{hi} \]
          7. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{x - \left(lo + \left(-1 \cdot \frac{lo \cdot \left(x - lo\right)}{hi} + -1 \cdot \frac{{lo}^{2} \cdot \left(x - lo\right)}{{hi}^{2}}\right)\right)}{hi}} \]
        5. Applied rewrites14.4%

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

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

            \[\leadsto \frac{1}{-1 \cdot \color{blue}{\left(hi \cdot \left(-1 \cdot \frac{\left(-1 \cdot \frac{{lo}^{2}}{hi \cdot \left(x - lo\right)} + \frac{{lo}^{2}}{hi \cdot \left(x - lo\right)}\right) - \frac{lo}{x - lo}}{hi} - \frac{1}{x - lo}\right)\right)}} \]
          3. Step-by-step derivation
            1. Applied rewrites98.9%

              \[\leadsto \frac{1}{\left(-hi\right) \cdot \color{blue}{\left(\frac{-\frac{lo}{x - lo}}{-hi} + \frac{-1}{x - lo}\right)}} \]
            2. Taylor expanded in hi around 0

              \[\leadsto \frac{1}{-1 \cdot \frac{lo}{x - lo} + \frac{hi}{\color{blue}{x - lo}}} \]
            3. Step-by-step derivation
              1. Applied rewrites99.4%

                \[\leadsto \frac{1}{\frac{hi}{x - lo} + \frac{lo}{\color{blue}{lo - x}}} \]
              2. Final simplification99.4%

                \[\leadsto \frac{1}{\frac{lo}{lo - x} + \frac{hi}{x - lo}} \]
              3. Add Preprocessing

              Alternative 3: 18.9% accurate, 0.5× speedup?

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

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

                \[\leadsto \color{blue}{\left(1 + \left(-1 \cdot \frac{x}{lo} + \frac{hi \cdot \left(-1 \cdot x - -1 \cdot hi\right)}{{lo}^{2}}\right)\right) - -1 \cdot \frac{hi}{lo}} \]
              4. Applied rewrites18.9%

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

                \[\leadsto \mathsf{fma}\left(\frac{hi + lo}{lo}, \frac{\color{blue}{hi - x}}{lo}, 1\right) \]
              6. Step-by-step derivation
                1. Applied rewrites18.9%

                  \[\leadsto \mathsf{fma}\left(\frac{hi + lo}{lo}, \frac{\color{blue}{hi - x}}{lo}, 1\right) \]
                2. Final simplification18.9%

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

                Alternative 4: 18.9% accurate, 0.6× speedup?

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

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

                  \[\leadsto \color{blue}{\left(1 + \left(-1 \cdot \frac{x}{lo} + \frac{hi \cdot \left(-1 \cdot x - -1 \cdot hi\right)}{{lo}^{2}}\right)\right) - -1 \cdot \frac{hi}{lo}} \]
                4. Applied rewrites18.9%

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

                  \[\leadsto 1 + \color{blue}{\frac{hi \cdot \left(1 + \frac{hi}{lo}\right)}{lo}} \]
                6. Step-by-step derivation
                  1. Applied rewrites18.9%

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

                  Alternative 5: 18.8% accurate, 1.2× speedup?

                  \[\begin{array}{l} \\ \frac{x - lo}{hi} \end{array} \]
                  (FPCore (lo hi x) :precision binary64 (/ (- x lo) hi))
                  double code(double lo, double hi, double x) {
                  	return (x - lo) / hi;
                  }
                  
                  real(8) function code(lo, hi, x)
                      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]
                  
                  \begin{array}{l}
                  
                  \\
                  \frac{x - lo}{hi}
                  \end{array}
                  
                  Derivation
                  1. Initial program 3.1%

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

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

                      \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
                    2. lower--.f6418.8

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

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

                  Alternative 6: 18.8% accurate, 1.3× speedup?

                  \[\begin{array}{l} \\ \frac{-lo}{hi} \end{array} \]
                  (FPCore (lo hi x) :precision binary64 (/ (- lo) hi))
                  double code(double lo, double hi, double x) {
                  	return -lo / hi;
                  }
                  
                  real(8) function code(lo, hi, x)
                      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]
                  
                  \begin{array}{l}
                  
                  \\
                  \frac{-lo}{hi}
                  \end{array}
                  
                  Derivation
                  1. Initial program 3.1%

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

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

                      \[\leadsto \color{blue}{\frac{x - lo}{hi}} \]
                    2. lower--.f6418.8

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

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

                    \[\leadsto \frac{-1 \cdot lo}{hi} \]
                  7. Step-by-step derivation
                    1. Applied rewrites18.8%

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

                    Alternative 7: 18.7% accurate, 18.0× speedup?

                    \[\begin{array}{l} \\ 1 \end{array} \]
                    (FPCore (lo hi x) :precision binary64 1.0)
                    double code(double lo, double hi, double x) {
                    	return 1.0;
                    }
                    
                    real(8) function code(lo, hi, x)
                        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
                    
                    \begin{array}{l}
                    
                    \\
                    1
                    \end{array}
                    
                    Derivation
                    1. Initial program 3.1%

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

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

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

                      Reproduce

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