exp-w (used to crash)

Percentage Accurate: 99.4% → 99.4%
Time: 18.7s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \end{array} \]
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
	return exp(-w) * pow(l, exp(w));
}
real(8) function code(w, l)
    real(8), intent (in) :: w
    real(8), intent (in) :: l
    code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
	return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l):
	return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l)
	return Float64(exp(Float64(-w)) * (l ^ exp(w)))
end
function tmp = code(w, l)
	tmp = exp(-w) * (l ^ exp(w));
end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\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 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: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \end{array} \]
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
	return exp(-w) * pow(l, exp(w));
}
real(8) function code(w, l)
    real(8), intent (in) :: w
    real(8), intent (in) :: l
    code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
	return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l):
	return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l)
	return Float64(exp(Float64(-w)) * (l ^ exp(w)))
end
function tmp = code(w, l)
	tmp = exp(-w) * (l ^ exp(w));
end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}

Alternative 1: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \end{array} \]
(FPCore (w l) :precision binary64 (* (exp (- w)) (pow l (exp w))))
double code(double w, double l) {
	return exp(-w) * pow(l, exp(w));
}
real(8) function code(w, l)
    real(8), intent (in) :: w
    real(8), intent (in) :: l
    code = exp(-w) * (l ** exp(w))
end function
public static double code(double w, double l) {
	return Math.exp(-w) * Math.pow(l, Math.exp(w));
}
def code(w, l):
	return math.exp(-w) * math.pow(l, math.exp(w))
function code(w, l)
	return Float64(exp(Float64(-w)) * (l ^ exp(w)))
end
function tmp = code(w, l)
	tmp = exp(-w) * (l ^ exp(w));
end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * N[Power[l, N[Exp[w], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{-w} \cdot {\ell}^{\left(e^{w}\right)}
\end{array}
Derivation
  1. Initial program 99.4%

    \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 97.7% accurate, 2.9× speedup?

\[\begin{array}{l} \\ e^{-w} \cdot \ell \end{array} \]
(FPCore (w l) :precision binary64 (* (exp (- w)) l))
double code(double w, double l) {
	return exp(-w) * l;
}
real(8) function code(w, l)
    real(8), intent (in) :: w
    real(8), intent (in) :: l
    code = exp(-w) * l
end function
public static double code(double w, double l) {
	return Math.exp(-w) * l;
}
def code(w, l):
	return math.exp(-w) * l
function code(w, l)
	return Float64(exp(Float64(-w)) * l)
end
function tmp = code(w, l)
	tmp = exp(-w) * l;
end
code[w_, l_] := N[(N[Exp[(-w)], $MachinePrecision] * l), $MachinePrecision]
\begin{array}{l}

\\
e^{-w} \cdot \ell
\end{array}
Derivation
  1. Initial program 99.4%

    \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in w around 0

    \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
  4. Step-by-step derivation
    1. Simplified98.0%

      \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
    2. Taylor expanded in w around inf

      \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
      2. lower-exp.f64N/A

        \[\leadsto \ell \cdot \color{blue}{e^{\mathsf{neg}\left(w\right)}} \]
      3. lower-neg.f6498.0

        \[\leadsto \ell \cdot e^{\color{blue}{-w}} \]
    4. Simplified98.0%

      \[\leadsto \color{blue}{\ell \cdot e^{-w}} \]
    5. Final simplification98.0%

      \[\leadsto e^{-w} \cdot \ell \]
    6. Add Preprocessing

    Alternative 3: 83.6% accurate, 10.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\ \;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \mathsf{fma}\left(w, -0.16666666666666666, 0.5\right), -1\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;w \cdot \frac{\ell}{w}\\ \end{array} \end{array} \]
    (FPCore (w l)
     :precision binary64
     (if (<= w 1.25e-5)
       (* l (fma w (fma w (fma w -0.16666666666666666 0.5) -1.0) 1.0))
       (* w (/ l w))))
    double code(double w, double l) {
    	double tmp;
    	if (w <= 1.25e-5) {
    		tmp = l * fma(w, fma(w, fma(w, -0.16666666666666666, 0.5), -1.0), 1.0);
    	} else {
    		tmp = w * (l / w);
    	}
    	return tmp;
    }
    
    function code(w, l)
    	tmp = 0.0
    	if (w <= 1.25e-5)
    		tmp = Float64(l * fma(w, fma(w, fma(w, -0.16666666666666666, 0.5), -1.0), 1.0));
    	else
    		tmp = Float64(w * Float64(l / w));
    	end
    	return tmp
    end
    
    code[w_, l_] := If[LessEqual[w, 1.25e-5], N[(l * N[(w * N[(w * N[(w * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\
    \;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \mathsf{fma}\left(w, -0.16666666666666666, 0.5\right), -1\right), 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;w \cdot \frac{\ell}{w}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if w < 1.25000000000000006e-5

      1. Initial program 99.8%

        \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in w around 0

        \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
      4. Step-by-step derivation
        1. Simplified99.0%

          \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
        2. Taylor expanded in w around inf

          \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
          2. lower-exp.f64N/A

            \[\leadsto \ell \cdot \color{blue}{e^{\mathsf{neg}\left(w\right)}} \]
          3. lower-neg.f6499.0

            \[\leadsto \ell \cdot e^{\color{blue}{-w}} \]
        4. Simplified99.0%

          \[\leadsto \color{blue}{\ell \cdot e^{-w}} \]
        5. Taylor expanded in w around 0

          \[\leadsto \ell \cdot \color{blue}{\left(1 + w \cdot \left(w \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot w\right) - 1\right)\right)} \]
        6. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \ell \cdot \color{blue}{\left(w \cdot \left(w \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot w\right) - 1\right) + 1\right)} \]
          2. lower-fma.f64N/A

            \[\leadsto \ell \cdot \color{blue}{\mathsf{fma}\left(w, w \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot w\right) - 1, 1\right)} \]
          3. sub-negN/A

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, \color{blue}{w \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot w\right) + \left(\mathsf{neg}\left(1\right)\right)}, 1\right) \]
          4. metadata-evalN/A

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, w \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot w\right) + \color{blue}{-1}, 1\right) \]
          5. lower-fma.f64N/A

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, \color{blue}{\mathsf{fma}\left(w, \frac{1}{2} + \frac{-1}{6} \cdot w, -1\right)}, 1\right) \]
          6. +-commutativeN/A

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \color{blue}{\frac{-1}{6} \cdot w + \frac{1}{2}}, -1\right), 1\right) \]
          7. *-commutativeN/A

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \color{blue}{w \cdot \frac{-1}{6}} + \frac{1}{2}, -1\right), 1\right) \]
          8. lower-fma.f6489.8

            \[\leadsto \ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, \color{blue}{\mathsf{fma}\left(w, -0.16666666666666666, 0.5\right)}, -1\right), 1\right) \]
        7. Simplified89.8%

          \[\leadsto \ell \cdot \color{blue}{\mathsf{fma}\left(w, \mathsf{fma}\left(w, \mathsf{fma}\left(w, -0.16666666666666666, 0.5\right), -1\right), 1\right)} \]

        if 1.25000000000000006e-5 < w

        1. Initial program 97.1%

          \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
        2. Add Preprocessing
        3. Taylor expanded in w around 0

          \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
        4. Step-by-step derivation
          1. Simplified92.4%

            \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
          2. Taylor expanded in w around 0

            \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
          3. Step-by-step derivation
            1. mul-1-negN/A

              \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
            2. unsub-negN/A

              \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
            3. lower--.f64N/A

              \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
            4. lower-*.f643.2

              \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
          4. Simplified3.2%

            \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
          5. Taylor expanded in w around inf

            \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
          6. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
            2. lower--.f64N/A

              \[\leadsto w \cdot \color{blue}{\left(\frac{\ell}{w} - \ell\right)} \]
            3. lower-/.f643.2

              \[\leadsto w \cdot \left(\color{blue}{\frac{\ell}{w}} - \ell\right) \]
          7. Simplified3.2%

            \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
          8. Taylor expanded in w around 0

            \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
          9. Step-by-step derivation
            1. lower-/.f6447.0

              \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
          10. Simplified47.0%

            \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
        5. Recombined 2 regimes into one program.
        6. Add Preprocessing

        Alternative 4: 80.0% accurate, 12.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq 9000000:\\ \;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, 0.5, -1\right), 1\right)\\ \mathbf{else}:\\ \;\;\;\;w \cdot \frac{\ell}{w}\\ \end{array} \end{array} \]
        (FPCore (w l)
         :precision binary64
         (if (<= w 9000000.0) (* l (fma w (fma w 0.5 -1.0) 1.0)) (* w (/ l w))))
        double code(double w, double l) {
        	double tmp;
        	if (w <= 9000000.0) {
        		tmp = l * fma(w, fma(w, 0.5, -1.0), 1.0);
        	} else {
        		tmp = w * (l / w);
        	}
        	return tmp;
        }
        
        function code(w, l)
        	tmp = 0.0
        	if (w <= 9000000.0)
        		tmp = Float64(l * fma(w, fma(w, 0.5, -1.0), 1.0));
        	else
        		tmp = Float64(w * Float64(l / w));
        	end
        	return tmp
        end
        
        code[w_, l_] := If[LessEqual[w, 9000000.0], N[(l * N[(w * N[(w * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;w \leq 9000000:\\
        \;\;\;\;\ell \cdot \mathsf{fma}\left(w, \mathsf{fma}\left(w, 0.5, -1\right), 1\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;w \cdot \frac{\ell}{w}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if w < 9e6

          1. Initial program 99.3%

            \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in w around 0

            \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
          4. Step-by-step derivation
            1. Simplified97.7%

              \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
            2. Taylor expanded in w around inf

              \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
            3. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
              2. lower-exp.f64N/A

                \[\leadsto \ell \cdot \color{blue}{e^{\mathsf{neg}\left(w\right)}} \]
              3. lower-neg.f6497.7

                \[\leadsto \ell \cdot e^{\color{blue}{-w}} \]
            4. Simplified97.7%

              \[\leadsto \color{blue}{\ell \cdot e^{-w}} \]
            5. Taylor expanded in w around 0

              \[\leadsto \ell \cdot \color{blue}{\left(1 + w \cdot \left(\frac{1}{2} \cdot w - 1\right)\right)} \]
            6. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \ell \cdot \color{blue}{\left(w \cdot \left(\frac{1}{2} \cdot w - 1\right) + 1\right)} \]
              2. lower-fma.f64N/A

                \[\leadsto \ell \cdot \color{blue}{\mathsf{fma}\left(w, \frac{1}{2} \cdot w - 1, 1\right)} \]
              3. sub-negN/A

                \[\leadsto \ell \cdot \mathsf{fma}\left(w, \color{blue}{\frac{1}{2} \cdot w + \left(\mathsf{neg}\left(1\right)\right)}, 1\right) \]
              4. *-commutativeN/A

                \[\leadsto \ell \cdot \mathsf{fma}\left(w, \color{blue}{w \cdot \frac{1}{2}} + \left(\mathsf{neg}\left(1\right)\right), 1\right) \]
              5. metadata-evalN/A

                \[\leadsto \ell \cdot \mathsf{fma}\left(w, w \cdot \frac{1}{2} + \color{blue}{-1}, 1\right) \]
              6. lower-fma.f6482.2

                \[\leadsto \ell \cdot \mathsf{fma}\left(w, \color{blue}{\mathsf{fma}\left(w, 0.5, -1\right)}, 1\right) \]
            7. Simplified82.2%

              \[\leadsto \ell \cdot \color{blue}{\mathsf{fma}\left(w, \mathsf{fma}\left(w, 0.5, -1\right), 1\right)} \]

            if 9e6 < w

            1. Initial program 100.0%

              \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in w around 0

              \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
            4. Step-by-step derivation
              1. Simplified100.0%

                \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
              2. Taylor expanded in w around 0

                \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
              3. Step-by-step derivation
                1. mul-1-negN/A

                  \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
                2. unsub-negN/A

                  \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                3. lower--.f64N/A

                  \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                4. lower-*.f643.3

                  \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
              4. Simplified3.3%

                \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
              5. Taylor expanded in w around inf

                \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
              6. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
                2. lower--.f64N/A

                  \[\leadsto w \cdot \color{blue}{\left(\frac{\ell}{w} - \ell\right)} \]
                3. lower-/.f643.3

                  \[\leadsto w \cdot \left(\color{blue}{\frac{\ell}{w}} - \ell\right) \]
              7. Simplified3.3%

                \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
              8. Taylor expanded in w around 0

                \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
              9. Step-by-step derivation
                1. lower-/.f6450.6

                  \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
              10. Simplified50.6%

                \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
            5. Recombined 2 regimes into one program.
            6. Add Preprocessing

            Alternative 5: 69.7% accurate, 13.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\ \;\;\;\;\ell - w \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;w \cdot \frac{\ell}{w}\\ \end{array} \end{array} \]
            (FPCore (w l)
             :precision binary64
             (if (<= w 1.25e-5) (- l (* w l)) (* w (/ l w))))
            double code(double w, double l) {
            	double tmp;
            	if (w <= 1.25e-5) {
            		tmp = l - (w * l);
            	} else {
            		tmp = w * (l / w);
            	}
            	return tmp;
            }
            
            real(8) function code(w, l)
                real(8), intent (in) :: w
                real(8), intent (in) :: l
                real(8) :: tmp
                if (w <= 1.25d-5) then
                    tmp = l - (w * l)
                else
                    tmp = w * (l / w)
                end if
                code = tmp
            end function
            
            public static double code(double w, double l) {
            	double tmp;
            	if (w <= 1.25e-5) {
            		tmp = l - (w * l);
            	} else {
            		tmp = w * (l / w);
            	}
            	return tmp;
            }
            
            def code(w, l):
            	tmp = 0
            	if w <= 1.25e-5:
            		tmp = l - (w * l)
            	else:
            		tmp = w * (l / w)
            	return tmp
            
            function code(w, l)
            	tmp = 0.0
            	if (w <= 1.25e-5)
            		tmp = Float64(l - Float64(w * l));
            	else
            		tmp = Float64(w * Float64(l / w));
            	end
            	return tmp
            end
            
            function tmp_2 = code(w, l)
            	tmp = 0.0;
            	if (w <= 1.25e-5)
            		tmp = l - (w * l);
            	else
            		tmp = w * (l / w);
            	end
            	tmp_2 = tmp;
            end
            
            code[w_, l_] := If[LessEqual[w, 1.25e-5], N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision], N[(w * N[(l / w), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\
            \;\;\;\;\ell - w \cdot \ell\\
            
            \mathbf{else}:\\
            \;\;\;\;w \cdot \frac{\ell}{w}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if w < 1.25000000000000006e-5

              1. Initial program 99.8%

                \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in w around 0

                \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
              4. Step-by-step derivation
                1. Simplified99.0%

                  \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                2. Taylor expanded in w around 0

                  \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
                3. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
                  2. unsub-negN/A

                    \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                  3. lower--.f64N/A

                    \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                  4. lower-*.f6471.8

                    \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
                4. Simplified71.8%

                  \[\leadsto \color{blue}{\ell - \ell \cdot w} \]

                if 1.25000000000000006e-5 < w

                1. Initial program 97.1%

                  \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
                2. Add Preprocessing
                3. Taylor expanded in w around 0

                  \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
                4. Step-by-step derivation
                  1. Simplified92.4%

                    \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                  2. Taylor expanded in w around 0

                    \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
                  3. Step-by-step derivation
                    1. mul-1-negN/A

                      \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
                    2. unsub-negN/A

                      \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                    3. lower--.f64N/A

                      \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                    4. lower-*.f643.2

                      \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
                  4. Simplified3.2%

                    \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                  5. Taylor expanded in w around inf

                    \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
                  6. Step-by-step derivation
                    1. lower-*.f64N/A

                      \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
                    2. lower--.f64N/A

                      \[\leadsto w \cdot \color{blue}{\left(\frac{\ell}{w} - \ell\right)} \]
                    3. lower-/.f643.2

                      \[\leadsto w \cdot \left(\color{blue}{\frac{\ell}{w}} - \ell\right) \]
                  7. Simplified3.2%

                    \[\leadsto \color{blue}{w \cdot \left(\frac{\ell}{w} - \ell\right)} \]
                  8. Taylor expanded in w around 0

                    \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
                  9. Step-by-step derivation
                    1. lower-/.f6447.0

                      \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
                  10. Simplified47.0%

                    \[\leadsto w \cdot \color{blue}{\frac{\ell}{w}} \]
                5. Recombined 2 regimes into one program.
                6. Final simplification68.2%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq 1.25 \cdot 10^{-5}:\\ \;\;\;\;\ell - w \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;w \cdot \frac{\ell}{w}\\ \end{array} \]
                7. Add Preprocessing

                Alternative 6: 63.9% accurate, 22.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;w \leq -0.39:\\ \;\;\;\;-w \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell\\ \end{array} \end{array} \]
                (FPCore (w l) :precision binary64 (if (<= w -0.39) (- (* w l)) l))
                double code(double w, double l) {
                	double tmp;
                	if (w <= -0.39) {
                		tmp = -(w * l);
                	} else {
                		tmp = l;
                	}
                	return tmp;
                }
                
                real(8) function code(w, l)
                    real(8), intent (in) :: w
                    real(8), intent (in) :: l
                    real(8) :: tmp
                    if (w <= (-0.39d0)) then
                        tmp = -(w * l)
                    else
                        tmp = l
                    end if
                    code = tmp
                end function
                
                public static double code(double w, double l) {
                	double tmp;
                	if (w <= -0.39) {
                		tmp = -(w * l);
                	} else {
                		tmp = l;
                	}
                	return tmp;
                }
                
                def code(w, l):
                	tmp = 0
                	if w <= -0.39:
                		tmp = -(w * l)
                	else:
                		tmp = l
                	return tmp
                
                function code(w, l)
                	tmp = 0.0
                	if (w <= -0.39)
                		tmp = Float64(-Float64(w * l));
                	else
                		tmp = l;
                	end
                	return tmp
                end
                
                function tmp_2 = code(w, l)
                	tmp = 0.0;
                	if (w <= -0.39)
                		tmp = -(w * l);
                	else
                		tmp = l;
                	end
                	tmp_2 = tmp;
                end
                
                code[w_, l_] := If[LessEqual[w, -0.39], (-N[(w * l), $MachinePrecision]), l]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;w \leq -0.39:\\
                \;\;\;\;-w \cdot \ell\\
                
                \mathbf{else}:\\
                \;\;\;\;\ell\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if w < -0.39000000000000001

                  1. Initial program 100.0%

                    \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
                  2. Add Preprocessing
                  3. Taylor expanded in w around 0

                    \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
                  4. Step-by-step derivation
                    1. Simplified100.0%

                      \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                    2. Taylor expanded in w around 0

                      \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
                    3. Step-by-step derivation
                      1. mul-1-negN/A

                        \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
                      2. unsub-negN/A

                        \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                      3. lower--.f64N/A

                        \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                      4. lower-*.f6422.2

                        \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
                    4. Simplified22.2%

                      \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                    5. Taylor expanded in w around inf

                      \[\leadsto \color{blue}{-1 \cdot \left(\ell \cdot w\right)} \]
                    6. Step-by-step derivation
                      1. mul-1-negN/A

                        \[\leadsto \color{blue}{\mathsf{neg}\left(\ell \cdot w\right)} \]
                      2. distribute-rgt-neg-inN/A

                        \[\leadsto \color{blue}{\ell \cdot \left(\mathsf{neg}\left(w\right)\right)} \]
                      3. neg-mul-1N/A

                        \[\leadsto \ell \cdot \color{blue}{\left(-1 \cdot w\right)} \]
                      4. lower-*.f64N/A

                        \[\leadsto \color{blue}{\ell \cdot \left(-1 \cdot w\right)} \]
                      5. neg-mul-1N/A

                        \[\leadsto \ell \cdot \color{blue}{\left(\mathsf{neg}\left(w\right)\right)} \]
                      6. lower-neg.f6422.2

                        \[\leadsto \ell \cdot \color{blue}{\left(-w\right)} \]
                    7. Simplified22.2%

                      \[\leadsto \color{blue}{\ell \cdot \left(-w\right)} \]

                    if -0.39000000000000001 < w

                    1. Initial program 99.1%

                      \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in w around 0

                      \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
                    4. Step-by-step derivation
                      1. Simplified97.2%

                        \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                      2. Taylor expanded in w around inf

                        \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
                      3. Step-by-step derivation
                        1. lower-*.f64N/A

                          \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
                        2. lower-exp.f64N/A

                          \[\leadsto \ell \cdot \color{blue}{e^{\mathsf{neg}\left(w\right)}} \]
                        3. lower-neg.f6497.2

                          \[\leadsto \ell \cdot e^{\color{blue}{-w}} \]
                      4. Simplified97.2%

                        \[\leadsto \color{blue}{\ell \cdot e^{-w}} \]
                      5. Taylor expanded in w around 0

                        \[\leadsto \ell \cdot \color{blue}{1} \]
                      6. Step-by-step derivation
                        1. Simplified78.8%

                          \[\leadsto \ell \cdot \color{blue}{1} \]
                      7. Recombined 2 regimes into one program.
                      8. Final simplification62.0%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;w \leq -0.39:\\ \;\;\;\;-w \cdot \ell\\ \mathbf{else}:\\ \;\;\;\;\ell\\ \end{array} \]
                      9. Add Preprocessing

                      Alternative 7: 63.6% accurate, 34.3× speedup?

                      \[\begin{array}{l} \\ \ell - w \cdot \ell \end{array} \]
                      (FPCore (w l) :precision binary64 (- l (* w l)))
                      double code(double w, double l) {
                      	return l - (w * l);
                      }
                      
                      real(8) function code(w, l)
                          real(8), intent (in) :: w
                          real(8), intent (in) :: l
                          code = l - (w * l)
                      end function
                      
                      public static double code(double w, double l) {
                      	return l - (w * l);
                      }
                      
                      def code(w, l):
                      	return l - (w * l)
                      
                      function code(w, l)
                      	return Float64(l - Float64(w * l))
                      end
                      
                      function tmp = code(w, l)
                      	tmp = l - (w * l);
                      end
                      
                      code[w_, l_] := N[(l - N[(w * l), $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      \ell - w \cdot \ell
                      \end{array}
                      
                      Derivation
                      1. Initial program 99.4%

                        \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
                      2. Add Preprocessing
                      3. Taylor expanded in w around 0

                        \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
                      4. Step-by-step derivation
                        1. Simplified98.0%

                          \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                        2. Taylor expanded in w around 0

                          \[\leadsto \color{blue}{\ell + -1 \cdot \left(\ell \cdot w\right)} \]
                        3. Step-by-step derivation
                          1. mul-1-negN/A

                            \[\leadsto \ell + \color{blue}{\left(\mathsf{neg}\left(\ell \cdot w\right)\right)} \]
                          2. unsub-negN/A

                            \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                          3. lower--.f64N/A

                            \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                          4. lower-*.f6461.7

                            \[\leadsto \ell - \color{blue}{\ell \cdot w} \]
                        4. Simplified61.7%

                          \[\leadsto \color{blue}{\ell - \ell \cdot w} \]
                        5. Final simplification61.7%

                          \[\leadsto \ell - w \cdot \ell \]
                        6. Add Preprocessing

                        Alternative 8: 56.4% accurate, 309.0× speedup?

                        \[\begin{array}{l} \\ \ell \end{array} \]
                        (FPCore (w l) :precision binary64 l)
                        double code(double w, double l) {
                        	return l;
                        }
                        
                        real(8) function code(w, l)
                            real(8), intent (in) :: w
                            real(8), intent (in) :: l
                            code = l
                        end function
                        
                        public static double code(double w, double l) {
                        	return l;
                        }
                        
                        def code(w, l):
                        	return l
                        
                        function code(w, l)
                        	return l
                        end
                        
                        function tmp = code(w, l)
                        	tmp = l;
                        end
                        
                        code[w_, l_] := l
                        
                        \begin{array}{l}
                        
                        \\
                        \ell
                        \end{array}
                        
                        Derivation
                        1. Initial program 99.4%

                          \[e^{-w} \cdot {\ell}^{\left(e^{w}\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in w around 0

                          \[\leadsto e^{\mathsf{neg}\left(w\right)} \cdot {\ell}^{\color{blue}{1}} \]
                        4. Step-by-step derivation
                          1. Simplified98.0%

                            \[\leadsto e^{-w} \cdot {\ell}^{\color{blue}{1}} \]
                          2. Taylor expanded in w around inf

                            \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
                          3. Step-by-step derivation
                            1. lower-*.f64N/A

                              \[\leadsto \color{blue}{\ell \cdot e^{\mathsf{neg}\left(w\right)}} \]
                            2. lower-exp.f64N/A

                              \[\leadsto \ell \cdot \color{blue}{e^{\mathsf{neg}\left(w\right)}} \]
                            3. lower-neg.f6498.0

                              \[\leadsto \ell \cdot e^{\color{blue}{-w}} \]
                          4. Simplified98.0%

                            \[\leadsto \color{blue}{\ell \cdot e^{-w}} \]
                          5. Taylor expanded in w around 0

                            \[\leadsto \ell \cdot \color{blue}{1} \]
                          6. Step-by-step derivation
                            1. Simplified56.5%

                              \[\leadsto \ell \cdot \color{blue}{1} \]
                            2. Final simplification56.5%

                              \[\leadsto \ell \]
                            3. Add Preprocessing

                            Reproduce

                            ?
                            herbie shell --seed 2024215 
                            (FPCore (w l)
                              :name "exp-w (used to crash)"
                              :precision binary64
                              (* (exp (- w)) (pow l (exp w))))