Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E

Percentage Accurate: 99.9% → 99.9%
Time: 7.1s
Alternatives: 8
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left(1 - x\right) + y \cdot \sqrt{x} \end{array} \]
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
	return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
	return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y):
	return (1.0 - x) + (y * math.sqrt(x))
function code(x, y)
	return Float64(Float64(1.0 - x) + Float64(y * sqrt(x)))
end
function tmp = code(x, y)
	tmp = (1.0 - x) + (y * sqrt(x));
end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(1 - x\right) + y \cdot \sqrt{x}
\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.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(1 - x\right) + y \cdot \sqrt{x} \end{array} \]
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
	return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
	return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y):
	return (1.0 - x) + (y * math.sqrt(x))
function code(x, y)
	return Float64(Float64(1.0 - x) + Float64(y * sqrt(x)))
end
function tmp = code(x, y)
	tmp = (1.0 - x) + (y * sqrt(x));
end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}

Alternative 1: 99.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\sqrt{x}, y, 1\right) - x \end{array} \]
(FPCore (x y) :precision binary64 (- (fma (sqrt x) y 1.0) x))
double code(double x, double y) {
	return fma(sqrt(x), y, 1.0) - x;
}
function code(x, y)
	return Float64(fma(sqrt(x), y, 1.0) - x)
end
code[x_, y_] := N[(N[(N[Sqrt[x], $MachinePrecision] * y + 1.0), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\sqrt{x}, y, 1\right) - x
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(1 - x\right) + y \cdot \sqrt{x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0

    \[\leadsto \color{blue}{1 + \left(-1 \cdot x + \sqrt{x} \cdot y\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\left(-1 \cdot x + \sqrt{x} \cdot y\right) + 1} \]
    2. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y + -1 \cdot x\right)} + 1 \]
    3. mul-1-negN/A

      \[\leadsto \left(\sqrt{x} \cdot y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) + 1 \]
    4. sub-negN/A

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y - x\right)} + 1 \]
    5. associate-+l-N/A

      \[\leadsto \color{blue}{\sqrt{x} \cdot y - \left(x - 1\right)} \]
    6. sub-negN/A

      \[\leadsto \sqrt{x} \cdot y - \color{blue}{\left(x + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
    7. *-lft-identityN/A

      \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{1 \cdot x} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
    8. lft-mult-inverseN/A

      \[\leadsto \sqrt{x} \cdot y - \left(1 \cdot x + \left(\mathsf{neg}\left(\color{blue}{\frac{1}{x} \cdot x}\right)\right)\right) \]
    9. distribute-lft-neg-outN/A

      \[\leadsto \sqrt{x} \cdot y - \left(1 \cdot x + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot x}\right) \]
    10. distribute-rgt-inN/A

      \[\leadsto \sqrt{x} \cdot y - \color{blue}{x \cdot \left(1 + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \]
    11. sub-negN/A

      \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(1 - \frac{1}{x}\right)} \]
    12. sub-negN/A

      \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \]
    13. +-commutativeN/A

      \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1\right)} \]
    14. distribute-lft-inN/A

      \[\leadsto \sqrt{x} \cdot y - \color{blue}{\left(x \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + x \cdot 1\right)} \]
    15. distribute-rgt-neg-outN/A

      \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{x}\right)\right)} + x \cdot 1\right) \]
    16. rgt-mult-inverseN/A

      \[\leadsto \sqrt{x} \cdot y - \left(\left(\mathsf{neg}\left(\color{blue}{1}\right)\right) + x \cdot 1\right) \]
    17. metadata-evalN/A

      \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{-1} + x \cdot 1\right) \]
    18. *-rgt-identityN/A

      \[\leadsto \sqrt{x} \cdot y - \left(-1 + \color{blue}{x}\right) \]
    19. associate--r+N/A

      \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y - -1\right) - x} \]
  5. Simplified99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right) - x} \]
  6. Add Preprocessing

Alternative 2: 63.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (+ (* (sqrt x) y) (- 1.0 x)) -2.0) (- x) (+ x 1.0)))
double code(double x, double y) {
	double tmp;
	if (((sqrt(x) * y) + (1.0 - x)) <= -2.0) {
		tmp = -x;
	} else {
		tmp = x + 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((sqrt(x) * y) + (1.0d0 - x)) <= (-2.0d0)) then
        tmp = -x
    else
        tmp = x + 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (((Math.sqrt(x) * y) + (1.0 - x)) <= -2.0) {
		tmp = -x;
	} else {
		tmp = x + 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((math.sqrt(x) * y) + (1.0 - x)) <= -2.0:
		tmp = -x
	else:
		tmp = x + 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(sqrt(x) * y) + Float64(1.0 - x)) <= -2.0)
		tmp = Float64(-x);
	else
		tmp = Float64(x + 1.0);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((sqrt(x) * y) + (1.0 - x)) <= -2.0)
		tmp = -x;
	else
		tmp = x + 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision], -2.0], (-x), N[(x + 1.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;x + 1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 #s(literal 1 binary64) x) (*.f64 y (sqrt.f64 x))) < -2

    1. Initial program 99.9%

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{1 - x} \]
    4. Step-by-step derivation
      1. lower--.f6460.8

        \[\leadsto \color{blue}{1 - x} \]
    5. Simplified60.8%

      \[\leadsto \color{blue}{1 - x} \]
    6. Taylor expanded in x around inf

      \[\leadsto \color{blue}{-1 \cdot x} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(x\right)} \]
      2. lower-neg.f6461.1

        \[\leadsto \color{blue}{-x} \]
    8. Simplified61.1%

      \[\leadsto \color{blue}{-x} \]

    if -2 < (+.f64 (-.f64 #s(literal 1 binary64) x) (*.f64 y (sqrt.f64 x)))

    1. Initial program 99.9%

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr94.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \sqrt{x}, 1 + x\right) \cdot \left(\left(1 - \mathsf{fma}\left(y, \sqrt{x}, x\right)\right) \cdot \frac{1}{1 - \mathsf{fma}\left(y, \sqrt{x}, x\right)}\right)} \]
    4. Taylor expanded in y around 0

      \[\leadsto \color{blue}{1 + x} \]
    5. Step-by-step derivation
      1. lower-+.f6463.0

        \[\leadsto \color{blue}{1 + x} \]
    6. Simplified63.0%

      \[\leadsto \color{blue}{1 + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;x + 1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 62.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= (+ (* (sqrt x) y) (- 1.0 x)) -2.0) (- x) 1.0))
double code(double x, double y) {
	double tmp;
	if (((sqrt(x) * y) + (1.0 - x)) <= -2.0) {
		tmp = -x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (((sqrt(x) * y) + (1.0d0 - x)) <= (-2.0d0)) then
        tmp = -x
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (((Math.sqrt(x) * y) + (1.0 - x)) <= -2.0) {
		tmp = -x;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if ((math.sqrt(x) * y) + (1.0 - x)) <= -2.0:
		tmp = -x
	else:
		tmp = 1.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (Float64(Float64(sqrt(x) * y) + Float64(1.0 - x)) <= -2.0)
		tmp = Float64(-x);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (((sqrt(x) * y) + (1.0 - x)) <= -2.0)
		tmp = -x;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[N[(N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] + N[(1.0 - x), $MachinePrecision]), $MachinePrecision], -2.0], (-x), 1.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\
\;\;\;\;-x\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 #s(literal 1 binary64) x) (*.f64 y (sqrt.f64 x))) < -2

    1. Initial program 99.9%

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{1 - x} \]
    4. Step-by-step derivation
      1. lower--.f6460.8

        \[\leadsto \color{blue}{1 - x} \]
    5. Simplified60.8%

      \[\leadsto \color{blue}{1 - x} \]
    6. Taylor expanded in x around inf

      \[\leadsto \color{blue}{-1 \cdot x} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(x\right)} \]
      2. lower-neg.f6461.1

        \[\leadsto \color{blue}{-x} \]
    8. Simplified61.1%

      \[\leadsto \color{blue}{-x} \]

    if -2 < (+.f64 (-.f64 #s(literal 1 binary64) x) (*.f64 y (sqrt.f64 x)))

    1. Initial program 99.9%

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 + \sqrt{x} \cdot y} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{x} \cdot y + 1} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
      3. lower-sqrt.f6498.2

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{x}}, y, 1\right) \]
    5. Simplified98.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
    6. Taylor expanded in y around 0

      \[\leadsto \color{blue}{1} \]
    7. Step-by-step derivation
      1. Simplified62.5%

        \[\leadsto \color{blue}{1} \]
    8. Recombined 2 regimes into one program.
    9. Final simplification61.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{x} \cdot y + \left(1 - x\right) \leq -2:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
    10. Add Preprocessing

    Alternative 4: 95.2% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(\sqrt{x}, y, 1\right)\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{+45}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+55}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (fma (sqrt x) y 1.0)))
       (if (<= y -2.7e+45) t_0 (if (<= y 4.8e+55) (- 1.0 x) t_0))))
    double code(double x, double y) {
    	double t_0 = fma(sqrt(x), y, 1.0);
    	double tmp;
    	if (y <= -2.7e+45) {
    		tmp = t_0;
    	} else if (y <= 4.8e+55) {
    		tmp = 1.0 - x;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	t_0 = fma(sqrt(x), y, 1.0)
    	tmp = 0.0
    	if (y <= -2.7e+45)
    		tmp = t_0;
    	elseif (y <= 4.8e+55)
    		tmp = Float64(1.0 - x);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[x], $MachinePrecision] * y + 1.0), $MachinePrecision]}, If[LessEqual[y, -2.7e+45], t$95$0, If[LessEqual[y, 4.8e+55], N[(1.0 - x), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(\sqrt{x}, y, 1\right)\\
    \mathbf{if}\;y \leq -2.7 \cdot 10^{+45}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 4.8 \cdot 10^{+55}:\\
    \;\;\;\;1 - x\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -2.69999999999999984e45 or 4.7999999999999998e55 < y

      1. Initial program 99.7%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{1 + \sqrt{x} \cdot y} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{x} \cdot y + 1} \]
        2. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
        3. lower-sqrt.f6493.0

          \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{x}}, y, 1\right) \]
      5. Simplified93.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]

      if -2.69999999999999984e45 < y < 4.7999999999999998e55

      1. Initial program 100.0%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in y around 0

        \[\leadsto \color{blue}{1 - x} \]
      4. Step-by-step derivation
        1. lower--.f6496.3

          \[\leadsto \color{blue}{1 - x} \]
      5. Simplified96.3%

        \[\leadsto \color{blue}{1 - x} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 5: 91.6% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x} \cdot y\\ \mathbf{if}\;y \leq -6.8 \cdot 10^{+121}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+56}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (let* ((t_0 (* (sqrt x) y)))
       (if (<= y -6.8e+121) t_0 (if (<= y 5e+56) (- 1.0 x) t_0))))
    double code(double x, double y) {
    	double t_0 = sqrt(x) * y;
    	double tmp;
    	if (y <= -6.8e+121) {
    		tmp = t_0;
    	} else if (y <= 5e+56) {
    		tmp = 1.0 - x;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8) :: t_0
        real(8) :: tmp
        t_0 = sqrt(x) * y
        if (y <= (-6.8d+121)) then
            tmp = t_0
        else if (y <= 5d+56) then
            tmp = 1.0d0 - x
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y) {
    	double t_0 = Math.sqrt(x) * y;
    	double tmp;
    	if (y <= -6.8e+121) {
    		tmp = t_0;
    	} else if (y <= 5e+56) {
    		tmp = 1.0 - x;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y):
    	t_0 = math.sqrt(x) * y
    	tmp = 0
    	if y <= -6.8e+121:
    		tmp = t_0
    	elif y <= 5e+56:
    		tmp = 1.0 - x
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y)
    	t_0 = Float64(sqrt(x) * y)
    	tmp = 0.0
    	if (y <= -6.8e+121)
    		tmp = t_0;
    	elseif (y <= 5e+56)
    		tmp = Float64(1.0 - x);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y)
    	t_0 = sqrt(x) * y;
    	tmp = 0.0;
    	if (y <= -6.8e+121)
    		tmp = t_0;
    	elseif (y <= 5e+56)
    		tmp = 1.0 - x;
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -6.8e+121], t$95$0, If[LessEqual[y, 5e+56], N[(1.0 - x), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \sqrt{x} \cdot y\\
    \mathbf{if}\;y \leq -6.8 \cdot 10^{+121}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 5 \cdot 10^{+56}:\\
    \;\;\;\;1 - x\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -6.80000000000000021e121 or 5.00000000000000024e56 < y

      1. Initial program 99.7%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in y around inf

        \[\leadsto \color{blue}{\sqrt{x} \cdot y} \]
      4. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{\sqrt{x} \cdot y} \]
        2. lower-sqrt.f6492.1

          \[\leadsto \color{blue}{\sqrt{x}} \cdot y \]
      5. Simplified92.1%

        \[\leadsto \color{blue}{\sqrt{x} \cdot y} \]

      if -6.80000000000000021e121 < y < 5.00000000000000024e56

      1. Initial program 100.0%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in y around 0

        \[\leadsto \color{blue}{1 - x} \]
      4. Step-by-step derivation
        1. lower--.f6491.7

          \[\leadsto \color{blue}{1 - x} \]
      5. Simplified91.7%

        \[\leadsto \color{blue}{1 - x} \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 6: 98.7% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{x}, y, 1\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot y - x\\ \end{array} \end{array} \]
    (FPCore (x y)
     :precision binary64
     (if (<= x 1.0) (fma (sqrt x) y 1.0) (- (* (sqrt x) y) x)))
    double code(double x, double y) {
    	double tmp;
    	if (x <= 1.0) {
    		tmp = fma(sqrt(x), y, 1.0);
    	} else {
    		tmp = (sqrt(x) * y) - x;
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (x <= 1.0)
    		tmp = fma(sqrt(x), y, 1.0);
    	else
    		tmp = Float64(Float64(sqrt(x) * y) - x);
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[x, 1.0], N[(N[Sqrt[x], $MachinePrecision] * y + 1.0), $MachinePrecision], N[(N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] - x), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 1:\\
    \;\;\;\;\mathsf{fma}\left(\sqrt{x}, y, 1\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\sqrt{x} \cdot y - x\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 1

      1. Initial program 99.9%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{1 + \sqrt{x} \cdot y} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{x} \cdot y + 1} \]
        2. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
        3. lower-sqrt.f6498.9

          \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{x}}, y, 1\right) \]
      5. Simplified98.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]

      if 1 < x

      1. Initial program 99.8%

        \[\left(1 - x\right) + y \cdot \sqrt{x} \]
      2. Add Preprocessing
      3. Taylor expanded in x around 0

        \[\leadsto \color{blue}{1 + \left(-1 \cdot x + \sqrt{x} \cdot y\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{\left(-1 \cdot x + \sqrt{x} \cdot y\right) + 1} \]
        2. +-commutativeN/A

          \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y + -1 \cdot x\right)} + 1 \]
        3. mul-1-negN/A

          \[\leadsto \left(\sqrt{x} \cdot y + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right) + 1 \]
        4. sub-negN/A

          \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y - x\right)} + 1 \]
        5. associate-+l-N/A

          \[\leadsto \color{blue}{\sqrt{x} \cdot y - \left(x - 1\right)} \]
        6. sub-negN/A

          \[\leadsto \sqrt{x} \cdot y - \color{blue}{\left(x + \left(\mathsf{neg}\left(1\right)\right)\right)} \]
        7. *-lft-identityN/A

          \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{1 \cdot x} + \left(\mathsf{neg}\left(1\right)\right)\right) \]
        8. lft-mult-inverseN/A

          \[\leadsto \sqrt{x} \cdot y - \left(1 \cdot x + \left(\mathsf{neg}\left(\color{blue}{\frac{1}{x} \cdot x}\right)\right)\right) \]
        9. distribute-lft-neg-outN/A

          \[\leadsto \sqrt{x} \cdot y - \left(1 \cdot x + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) \cdot x}\right) \]
        10. distribute-rgt-inN/A

          \[\leadsto \sqrt{x} \cdot y - \color{blue}{x \cdot \left(1 + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \]
        11. sub-negN/A

          \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(1 - \frac{1}{x}\right)} \]
        12. sub-negN/A

          \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(1 + \left(\mathsf{neg}\left(\frac{1}{x}\right)\right)\right)} \]
        13. +-commutativeN/A

          \[\leadsto \sqrt{x} \cdot y - x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + 1\right)} \]
        14. distribute-lft-inN/A

          \[\leadsto \sqrt{x} \cdot y - \color{blue}{\left(x \cdot \left(\mathsf{neg}\left(\frac{1}{x}\right)\right) + x \cdot 1\right)} \]
        15. distribute-rgt-neg-outN/A

          \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{\left(\mathsf{neg}\left(x \cdot \frac{1}{x}\right)\right)} + x \cdot 1\right) \]
        16. rgt-mult-inverseN/A

          \[\leadsto \sqrt{x} \cdot y - \left(\left(\mathsf{neg}\left(\color{blue}{1}\right)\right) + x \cdot 1\right) \]
        17. metadata-evalN/A

          \[\leadsto \sqrt{x} \cdot y - \left(\color{blue}{-1} + x \cdot 1\right) \]
        18. *-rgt-identityN/A

          \[\leadsto \sqrt{x} \cdot y - \left(-1 + \color{blue}{x}\right) \]
        19. associate--r+N/A

          \[\leadsto \color{blue}{\left(\sqrt{x} \cdot y - -1\right) - x} \]
      5. Simplified99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right) - x} \]
      6. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\sqrt{x} \cdot y} - x \]
      7. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \color{blue}{\sqrt{x} \cdot y} - x \]
        2. lower-sqrt.f6499.6

          \[\leadsto \color{blue}{\sqrt{x}} \cdot y - x \]
      8. Simplified99.6%

        \[\leadsto \color{blue}{\sqrt{x} \cdot y} - x \]
    3. Recombined 2 regimes into one program.
    4. Add Preprocessing

    Alternative 7: 63.4% accurate, 5.5× speedup?

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

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{1 - x} \]
    4. Step-by-step derivation
      1. lower--.f6461.6

        \[\leadsto \color{blue}{1 - x} \]
    5. Simplified61.6%

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

    Alternative 8: 32.5% accurate, 22.0× speedup?

    \[\begin{array}{l} \\ 1 \end{array} \]
    (FPCore (x y) :precision binary64 1.0)
    double code(double x, double y) {
    	return 1.0;
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        code = 1.0d0
    end function
    
    public static double code(double x, double y) {
    	return 1.0;
    }
    
    def code(x, y):
    	return 1.0
    
    function code(x, y)
    	return 1.0
    end
    
    function tmp = code(x, y)
    	tmp = 1.0;
    end
    
    code[x_, y_] := 1.0
    
    \begin{array}{l}
    
    \\
    1
    \end{array}
    
    Derivation
    1. Initial program 99.9%

      \[\left(1 - x\right) + y \cdot \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{1 + \sqrt{x} \cdot y} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{x} \cdot y + 1} \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
      3. lower-sqrt.f6467.9

        \[\leadsto \mathsf{fma}\left(\color{blue}{\sqrt{x}}, y, 1\right) \]
    5. Simplified67.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, y, 1\right)} \]
    6. Taylor expanded in y around 0

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

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

      Reproduce

      ?
      herbie shell --seed 2024207 
      (FPCore (x y)
        :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E"
        :precision binary64
        (+ (- 1.0 x) (* y (sqrt x))))