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

Percentage Accurate: 99.9% → 99.9%
Time: 13.0s
Alternatives: 13
Speedup: 1.0×

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 13 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.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}
Derivation
  1. Initial program 99.8%

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

Alternative 2: 94.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x} \cdot y + 1\\ \mathbf{if}\;y \leq -6.4 \cdot 10^{+34}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{+87}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (* (sqrt x) y) 1.0)))
   (if (<= y -6.4e+34) t_0 (if (<= y 2.15e+87) (- 1.0 x) t_0))))
double code(double x, double y) {
	double t_0 = (sqrt(x) * y) + 1.0;
	double tmp;
	if (y <= -6.4e+34) {
		tmp = t_0;
	} else if (y <= 2.15e+87) {
		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) + 1.0d0
    if (y <= (-6.4d+34)) then
        tmp = t_0
    else if (y <= 2.15d+87) 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) + 1.0;
	double tmp;
	if (y <= -6.4e+34) {
		tmp = t_0;
	} else if (y <= 2.15e+87) {
		tmp = 1.0 - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (math.sqrt(x) * y) + 1.0
	tmp = 0
	if y <= -6.4e+34:
		tmp = t_0
	elif y <= 2.15e+87:
		tmp = 1.0 - x
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(sqrt(x) * y) + 1.0)
	tmp = 0.0
	if (y <= -6.4e+34)
		tmp = t_0;
	elseif (y <= 2.15e+87)
		tmp = Float64(1.0 - x);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (sqrt(x) * y) + 1.0;
	tmp = 0.0;
	if (y <= -6.4e+34)
		tmp = t_0;
	elseif (y <= 2.15e+87)
		tmp = 1.0 - x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[y, -6.4e+34], t$95$0, If[LessEqual[y, 2.15e+87], N[(1.0 - x), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{x} \cdot y + 1\\
\mathbf{if}\;y \leq -6.4 \cdot 10^{+34}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2.15 \cdot 10^{+87}:\\
\;\;\;\;1 - x\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.3999999999999997e34 or 2.15e87 < y

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -6.3999999999999997e34 < y < 2.15e87

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 92.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x} \cdot y\\ \mathbf{if}\;y \leq -6 \cdot 10^{+79}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.32 \cdot 10^{+88}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (sqrt x) y)))
   (if (<= y -6e+79) t_0 (if (<= y 1.32e+88) (- 1.0 x) t_0))))
double code(double x, double y) {
	double t_0 = sqrt(x) * y;
	double tmp;
	if (y <= -6e+79) {
		tmp = t_0;
	} else if (y <= 1.32e+88) {
		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 <= (-6d+79)) then
        tmp = t_0
    else if (y <= 1.32d+88) 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 <= -6e+79) {
		tmp = t_0;
	} else if (y <= 1.32e+88) {
		tmp = 1.0 - x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = math.sqrt(x) * y
	tmp = 0
	if y <= -6e+79:
		tmp = t_0
	elif y <= 1.32e+88:
		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 <= -6e+79)
		tmp = t_0;
	elseif (y <= 1.32e+88)
		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 <= -6e+79)
		tmp = t_0;
	elseif (y <= 1.32e+88)
		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, -6e+79], t$95$0, If[LessEqual[y, 1.32e+88], 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 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.32 \cdot 10^{+88}:\\
\;\;\;\;1 - x\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.99999999999999948e79 or 1.3200000000000001e88 < y

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if -5.99999999999999948e79 < y < 1.3200000000000001e88

    1. Initial program 100.0%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 98.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 195:\\
\;\;\;\;\frac{y}{{x}^{-0.5}} + 1\\

\mathbf{else}:\\
\;\;\;\;\left(-1 + \frac{y}{\sqrt{x}}\right) \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 195

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]

    if 195 < x

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{y}{{x}^{-0.5}} + 1\\

\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.8%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]

    if 1 < x

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 98.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x} \cdot y\\ \mathbf{if}\;x \leq 1:\\ \;\;\;\;t\_0 + 1\\ \mathbf{else}:\\ \;\;\;\;t\_0 - x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (sqrt x) y))) (if (<= x 1.0) (+ t_0 1.0) (- t_0 x))))
double code(double x, double y) {
	double t_0 = sqrt(x) * y;
	double tmp;
	if (x <= 1.0) {
		tmp = t_0 + 1.0;
	} else {
		tmp = t_0 - x;
	}
	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 (x <= 1.0d0) then
        tmp = t_0 + 1.0d0
    else
        tmp = t_0 - x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = Math.sqrt(x) * y;
	double tmp;
	if (x <= 1.0) {
		tmp = t_0 + 1.0;
	} else {
		tmp = t_0 - x;
	}
	return tmp;
}
def code(x, y):
	t_0 = math.sqrt(x) * y
	tmp = 0
	if x <= 1.0:
		tmp = t_0 + 1.0
	else:
		tmp = t_0 - x
	return tmp
function code(x, y)
	t_0 = Float64(sqrt(x) * y)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64(t_0 + 1.0);
	else
		tmp = Float64(t_0 - x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = sqrt(x) * y;
	tmp = 0.0;
	if (x <= 1.0)
		tmp = t_0 + 1.0;
	else
		tmp = t_0 - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[x], $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[x, 1.0], N[(t$95$0 + 1.0), $MachinePrecision], N[(t$95$0 - x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{x} \cdot y\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;t\_0 + 1\\

\mathbf{else}:\\
\;\;\;\;t\_0 - x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 1 < x

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 68.9% accurate, 3.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\ \;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+88}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{1 - x \cdot x}} \cdot \left(\left(y \cdot \left(1 - x\right)\right) \cdot \left(1 + x \cdot x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.15e+116)
   (* (/ 1.0 y) (- 0.0 (* x y)))
   (if (<= y 6e+88)
     (- 1.0 x)
     (* (/ 1.0 (/ y (- 1.0 (* x x)))) (* (* y (- 1.0 x)) (+ 1.0 (* x x)))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else if (y <= 6e+88) {
		tmp = 1.0 - x;
	} else {
		tmp = (1.0 / (y / (1.0 - (x * x)))) * ((y * (1.0 - x)) * (1.0 + (x * x)));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.15d+116)) then
        tmp = (1.0d0 / y) * (0.0d0 - (x * y))
    else if (y <= 6d+88) then
        tmp = 1.0d0 - x
    else
        tmp = (1.0d0 / (y / (1.0d0 - (x * x)))) * ((y * (1.0d0 - x)) * (1.0d0 + (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else if (y <= 6e+88) {
		tmp = 1.0 - x;
	} else {
		tmp = (1.0 / (y / (1.0 - (x * x)))) * ((y * (1.0 - x)) * (1.0 + (x * x)));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.15e+116:
		tmp = (1.0 / y) * (0.0 - (x * y))
	elif y <= 6e+88:
		tmp = 1.0 - x
	else:
		tmp = (1.0 / (y / (1.0 - (x * x)))) * ((y * (1.0 - x)) * (1.0 + (x * x)))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.15e+116)
		tmp = Float64(Float64(1.0 / y) * Float64(0.0 - Float64(x * y)));
	elseif (y <= 6e+88)
		tmp = Float64(1.0 - x);
	else
		tmp = Float64(Float64(1.0 / Float64(y / Float64(1.0 - Float64(x * x)))) * Float64(Float64(y * Float64(1.0 - x)) * Float64(1.0 + Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.15e+116)
		tmp = (1.0 / y) * (0.0 - (x * y));
	elseif (y <= 6e+88)
		tmp = 1.0 - x;
	else
		tmp = (1.0 / (y / (1.0 - (x * x)))) * ((y * (1.0 - x)) * (1.0 + (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.15e+116], N[(N[(1.0 / y), $MachinePrecision] * N[(0.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+88], N[(1.0 - x), $MachinePrecision], N[(N[(1.0 / N[(y / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\
\;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\

\mathbf{elif}\;y \leq 6 \cdot 10^{+88}:\\
\;\;\;\;1 - x\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{y}{1 - x \cdot x}} \cdot \left(\left(y \cdot \left(1 - x\right)\right) \cdot \left(1 + x \cdot x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.15e116

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]

    if -2.15e116 < y < 6.00000000000000011e88

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 6.00000000000000011e88 < y

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 68.9% accurate, 4.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\ \;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+88}:\\ \;\;\;\;1 - x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y}{1 - x \cdot x}} \cdot \left(y \cdot \left(1 - x\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.15e+116)
   (* (/ 1.0 y) (- 0.0 (* x y)))
   (if (<= y 6e+88)
     (- 1.0 x)
     (* (/ 1.0 (/ y (- 1.0 (* x x)))) (* y (- 1.0 x))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else if (y <= 6e+88) {
		tmp = 1.0 - x;
	} else {
		tmp = (1.0 / (y / (1.0 - (x * x)))) * (y * (1.0 - x));
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.15d+116)) then
        tmp = (1.0d0 / y) * (0.0d0 - (x * y))
    else if (y <= 6d+88) then
        tmp = 1.0d0 - x
    else
        tmp = (1.0d0 / (y / (1.0d0 - (x * x)))) * (y * (1.0d0 - x))
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else if (y <= 6e+88) {
		tmp = 1.0 - x;
	} else {
		tmp = (1.0 / (y / (1.0 - (x * x)))) * (y * (1.0 - x));
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.15e+116:
		tmp = (1.0 / y) * (0.0 - (x * y))
	elif y <= 6e+88:
		tmp = 1.0 - x
	else:
		tmp = (1.0 / (y / (1.0 - (x * x)))) * (y * (1.0 - x))
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.15e+116)
		tmp = Float64(Float64(1.0 / y) * Float64(0.0 - Float64(x * y)));
	elseif (y <= 6e+88)
		tmp = Float64(1.0 - x);
	else
		tmp = Float64(Float64(1.0 / Float64(y / Float64(1.0 - Float64(x * x)))) * Float64(y * Float64(1.0 - x)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.15e+116)
		tmp = (1.0 / y) * (0.0 - (x * y));
	elseif (y <= 6e+88)
		tmp = 1.0 - x;
	else
		tmp = (1.0 / (y / (1.0 - (x * x)))) * (y * (1.0 - x));
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.15e+116], N[(N[(1.0 / y), $MachinePrecision] * N[(0.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+88], N[(1.0 - x), $MachinePrecision], N[(N[(1.0 / N[(y / N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\
\;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\

\mathbf{elif}\;y \leq 6 \cdot 10^{+88}:\\
\;\;\;\;1 - x\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{y}{1 - x \cdot x}} \cdot \left(y \cdot \left(1 - x\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.15e116

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]

    if -2.15e116 < y < 6.00000000000000011e88

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]

    if 6.00000000000000011e88 < y

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 65.5% accurate, 7.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\ \;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;1 - x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.15e+116) (* (/ 1.0 y) (- 0.0 (* x y))) (- 1.0 x)))
double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else {
		tmp = 1.0 - x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.15d+116)) then
        tmp = (1.0d0 / y) * (0.0d0 - (x * y))
    else
        tmp = 1.0d0 - x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.15e+116) {
		tmp = (1.0 / y) * (0.0 - (x * y));
	} else {
		tmp = 1.0 - x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.15e+116:
		tmp = (1.0 / y) * (0.0 - (x * y))
	else:
		tmp = 1.0 - x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.15e+116)
		tmp = Float64(Float64(1.0 / y) * Float64(0.0 - Float64(x * y)));
	else
		tmp = Float64(1.0 - x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.15e+116)
		tmp = (1.0 / y) * (0.0 - (x * y));
	else
		tmp = 1.0 - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.15e+116], N[(N[(1.0 / y), $MachinePrecision] * N[(0.0 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+116}:\\
\;\;\;\;\frac{1}{y} \cdot \left(0 - x \cdot y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.15e116

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    8. Simplified0

      \[\leadsto expr\]

    if -2.15e116 < y

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 65.6% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+146}:\\ \;\;\;\;\frac{\left(1 - x\right) \cdot y}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - x\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -1.02e+146) (/ (* (- 1.0 x) y) y) (- 1.0 x)))
double code(double x, double y) {
	double tmp;
	if (y <= -1.02e+146) {
		tmp = ((1.0 - x) * y) / y;
	} else {
		tmp = 1.0 - x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-1.02d+146)) then
        tmp = ((1.0d0 - x) * y) / y
    else
        tmp = 1.0d0 - x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -1.02e+146) {
		tmp = ((1.0 - x) * y) / y;
	} else {
		tmp = 1.0 - x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -1.02e+146:
		tmp = ((1.0 - x) * y) / y
	else:
		tmp = 1.0 - x
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -1.02e+146)
		tmp = Float64(Float64(Float64(1.0 - x) * y) / y);
	else
		tmp = Float64(1.0 - x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -1.02e+146)
		tmp = ((1.0 - x) * y) / y;
	else
		tmp = 1.0 - x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -1.02e+146], N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / y), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.02 \cdot 10^{+146}:\\
\;\;\;\;\frac{\left(1 - x\right) \cdot y}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.01999999999999997e146

    1. Initial program 99.6%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if -1.01999999999999997e146 < y

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 61.4% accurate, 15.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 400000000:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \end{array} \]
(FPCore (x y) :precision binary64 (if (<= x 400000000.0) 1.0 (- x)))
double code(double x, double y) {
	double tmp;
	if (x <= 400000000.0) {
		tmp = 1.0;
	} else {
		tmp = -x;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= 400000000.0d0) then
        tmp = 1.0d0
    else
        tmp = -x
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= 400000000.0) {
		tmp = 1.0;
	} else {
		tmp = -x;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= 400000000.0:
		tmp = 1.0
	else:
		tmp = -x
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= 400000000.0)
		tmp = 1.0;
	else
		tmp = Float64(-x);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= 400000000.0)
		tmp = 1.0;
	else
		tmp = -x;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, 400000000.0], 1.0, (-x)]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 400000000:\\
\;\;\;\;1\\

\mathbf{else}:\\
\;\;\;\;-x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4e8

    1. Initial program 99.8%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]

    if 4e8 < x

    1. Initial program 99.9%

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

      \[\leadsto expr\]
    4. Simplified0

      \[\leadsto expr\]
    5. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    6. Simplified0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 62.6% accurate, 35.7× 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.8%

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

    \[\leadsto expr\]
  4. Simplified0

    \[\leadsto expr\]
  5. Add Preprocessing

Alternative 13: 31.5% accurate, 107.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.8%

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

    \[\leadsto expr\]
  4. Simplified0

    \[\leadsto expr\]
  5. Taylor expanded in x around 0 0

    \[\leadsto expr\]
  6. Simplified0

    \[\leadsto expr\]
  7. Add Preprocessing

Reproduce

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