Diagrams.Trail:splitAtParam from diagrams-lib-1.3.0.3, D

?

Percentage Accurate: 65.4% → 99.9%
Time: 11.0s
Precision: binary64
Cost: 7940

?

\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
\[\begin{array}{l} t_0 := \frac{x + -1}{y \cdot y}\\ t_1 := \frac{1 - x}{y}\\ \mathbf{if}\;y \leq -11500:\\ \;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + t_1\right)\right) + t_0\\ \mathbf{elif}\;y \leq 300000:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \left(x + t_1\right)\\ \end{array} \]
(FPCore (x y) :precision binary64 (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (+ x -1.0) (* y y))) (t_1 (/ (- 1.0 x) y)))
   (if (<= y -11500.0)
     (+ (+ x (+ (/ (- 1.0 x) (pow y 3.0)) t_1)) t_0)
     (if (<= y 300000.0)
       (+ 1.0 (* y (/ (+ x -1.0) (+ y 1.0))))
       (+ t_0 (+ x t_1))))))
double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
double code(double x, double y) {
	double t_0 = (x + -1.0) / (y * y);
	double t_1 = (1.0 - x) / y;
	double tmp;
	if (y <= -11500.0) {
		tmp = (x + (((1.0 - x) / pow(y, 3.0)) + t_1)) + t_0;
	} else if (y <= 300000.0) {
		tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
	} else {
		tmp = t_0 + (x + t_1);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = 1.0d0 - (((1.0d0 - x) * y) / (y + 1.0d0))
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + (-1.0d0)) / (y * y)
    t_1 = (1.0d0 - x) / y
    if (y <= (-11500.0d0)) then
        tmp = (x + (((1.0d0 - x) / (y ** 3.0d0)) + t_1)) + t_0
    else if (y <= 300000.0d0) then
        tmp = 1.0d0 + (y * ((x + (-1.0d0)) / (y + 1.0d0)))
    else
        tmp = t_0 + (x + t_1)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return 1.0 - (((1.0 - x) * y) / (y + 1.0));
}
public static double code(double x, double y) {
	double t_0 = (x + -1.0) / (y * y);
	double t_1 = (1.0 - x) / y;
	double tmp;
	if (y <= -11500.0) {
		tmp = (x + (((1.0 - x) / Math.pow(y, 3.0)) + t_1)) + t_0;
	} else if (y <= 300000.0) {
		tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
	} else {
		tmp = t_0 + (x + t_1);
	}
	return tmp;
}
def code(x, y):
	return 1.0 - (((1.0 - x) * y) / (y + 1.0))
def code(x, y):
	t_0 = (x + -1.0) / (y * y)
	t_1 = (1.0 - x) / y
	tmp = 0
	if y <= -11500.0:
		tmp = (x + (((1.0 - x) / math.pow(y, 3.0)) + t_1)) + t_0
	elif y <= 300000.0:
		tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)))
	else:
		tmp = t_0 + (x + t_1)
	return tmp
function code(x, y)
	return Float64(1.0 - Float64(Float64(Float64(1.0 - x) * y) / Float64(y + 1.0)))
end
function code(x, y)
	t_0 = Float64(Float64(x + -1.0) / Float64(y * y))
	t_1 = Float64(Float64(1.0 - x) / y)
	tmp = 0.0
	if (y <= -11500.0)
		tmp = Float64(Float64(x + Float64(Float64(Float64(1.0 - x) / (y ^ 3.0)) + t_1)) + t_0);
	elseif (y <= 300000.0)
		tmp = Float64(1.0 + Float64(y * Float64(Float64(x + -1.0) / Float64(y + 1.0))));
	else
		tmp = Float64(t_0 + Float64(x + t_1));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = 1.0 - (((1.0 - x) * y) / (y + 1.0));
end
function tmp_2 = code(x, y)
	t_0 = (x + -1.0) / (y * y);
	t_1 = (1.0 - x) / y;
	tmp = 0.0;
	if (y <= -11500.0)
		tmp = (x + (((1.0 - x) / (y ^ 3.0)) + t_1)) + t_0;
	elseif (y <= 300000.0)
		tmp = 1.0 + (y * ((x + -1.0) / (y + 1.0)));
	else
		tmp = t_0 + (x + t_1);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(1.0 - N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(x + -1.0), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -11500.0], N[(N[(x + N[(N[(N[(1.0 - x), $MachinePrecision] / N[Power[y, 3.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 300000.0], N[(1.0 + N[(y * N[(N[(x + -1.0), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 + N[(x + t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
t_0 := \frac{x + -1}{y \cdot y}\\
t_1 := \frac{1 - x}{y}\\
\mathbf{if}\;y \leq -11500:\\
\;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + t_1\right)\right) + t_0\\

\mathbf{elif}\;y \leq 300000:\\
\;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\

\mathbf{else}:\\
\;\;\;\;t_0 + \left(x + t_1\right)\\


\end{array}

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.

Herbie found 11 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

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.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original65.4%
Target99.7%
Herbie99.9%
\[\begin{array}{l} \mathbf{if}\;y < -3693.8482788297247:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y < 6799310503.41891:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if y < -11500

    1. Initial program 34.7%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Simplified54.4%

      \[\leadsto \color{blue}{1 - \frac{1 - x}{1 + y} \cdot y} \]
      Step-by-step derivation

      [Start]34.7%

      \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]

      sub-neg [=>]34.7%

      \[ \color{blue}{1 + \left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right)} \]

      distribute-neg-frac [=>]34.7%

      \[ 1 + \color{blue}{\frac{-\left(1 - x\right) \cdot y}{y + 1}} \]

      neg-mul-1 [=>]34.7%

      \[ 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]

      associate-*l/ [<=]34.5%

      \[ 1 + \color{blue}{\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      metadata-eval [<=]34.5%

      \[ 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-*l/ [<=]34.5%

      \[ 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-/r/ [<=]34.5%

      \[ 1 + \color{blue}{\frac{1}{\frac{y + 1}{-1}}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      metadata-eval [<=]34.5%

      \[ 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      distribute-neg-frac [<=]34.5%

      \[ 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      cancel-sign-sub-inv [<=]34.5%

      \[ \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      associate-/r/ [<=]34.5%

      \[ 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]

      associate-/r* [<=]34.5%

      \[ 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]

      neg-mul-1 [<=]34.5%

      \[ 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]

      associate-/r/ [=>]34.5%

      \[ 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]

      distribute-rgt-neg-in [<=]34.5%

      \[ 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]

      associate-/r/ [<=]34.5%

      \[ 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]

      distribute-neg-frac [=>]34.5%

      \[ 1 - \color{blue}{\frac{--1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}} \]

      metadata-eval [=>]34.5%

      \[ 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]

      associate-/r/ [=>]34.5%

      \[ 1 - \color{blue}{\frac{1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
    3. Taylor expanded in y around -inf 99.9%

      \[\leadsto \color{blue}{\left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right)\right) - \frac{1}{{y}^{2}}} \]
    4. Simplified99.9%

      \[\leadsto \color{blue}{\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{x + -1}{y \cdot y}} \]
      Step-by-step derivation

      [Start]99.9%

      \[ \left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right)\right) - \frac{1}{{y}^{2}} \]

      +-commutative [=>]99.9%

      \[ \color{blue}{\left(\left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right) + \frac{x}{{y}^{2}}\right)} - \frac{1}{{y}^{2}} \]

      associate--l+ [=>]99.9%

      \[ \color{blue}{\left(-1 \cdot \frac{x - 1}{y} + \left(-1 \cdot \frac{x - 1}{{y}^{3}} + x\right)\right) + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right)} \]

    if -11500 < y < 3e5

    1. Initial program 100.0%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{1 - \frac{1 - x}{1 + y} \cdot y} \]
      Step-by-step derivation

      [Start]100.0%

      \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]

      sub-neg [=>]100.0%

      \[ \color{blue}{1 + \left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right)} \]

      distribute-neg-frac [=>]100.0%

      \[ 1 + \color{blue}{\frac{-\left(1 - x\right) \cdot y}{y + 1}} \]

      neg-mul-1 [=>]100.0%

      \[ 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]

      associate-*l/ [<=]100.0%

      \[ 1 + \color{blue}{\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      metadata-eval [<=]100.0%

      \[ 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-*l/ [<=]100.0%

      \[ 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-/r/ [<=]100.0%

      \[ 1 + \color{blue}{\frac{1}{\frac{y + 1}{-1}}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      metadata-eval [<=]100.0%

      \[ 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      distribute-neg-frac [<=]100.0%

      \[ 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      cancel-sign-sub-inv [<=]100.0%

      \[ \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      associate-/r/ [<=]99.9%

      \[ 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]

      associate-/r* [<=]99.9%

      \[ 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]

      neg-mul-1 [<=]99.9%

      \[ 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]

      associate-/r/ [=>]100.0%

      \[ 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]

      distribute-rgt-neg-in [<=]100.0%

      \[ 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]

      associate-/r/ [<=]99.9%

      \[ 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]

      distribute-neg-frac [=>]99.9%

      \[ 1 - \color{blue}{\frac{--1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}} \]

      metadata-eval [=>]99.9%

      \[ 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]

      associate-/r/ [=>]100.0%

      \[ 1 - \color{blue}{\frac{1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

    if 3e5 < y

    1. Initial program 39.4%

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]
    2. Simplified58.8%

      \[\leadsto \color{blue}{1 - \frac{1 - x}{1 + y} \cdot y} \]
      Step-by-step derivation

      [Start]39.4%

      \[ 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \]

      sub-neg [=>]39.4%

      \[ \color{blue}{1 + \left(-\frac{\left(1 - x\right) \cdot y}{y + 1}\right)} \]

      distribute-neg-frac [=>]39.4%

      \[ 1 + \color{blue}{\frac{-\left(1 - x\right) \cdot y}{y + 1}} \]

      neg-mul-1 [=>]39.4%

      \[ 1 + \frac{\color{blue}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}{y + 1} \]

      associate-*l/ [<=]39.6%

      \[ 1 + \color{blue}{\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      metadata-eval [<=]39.6%

      \[ 1 + \frac{\color{blue}{1 \cdot -1}}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-*l/ [<=]39.6%

      \[ 1 + \color{blue}{\left(\frac{1}{y + 1} \cdot -1\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      associate-/r/ [<=]39.6%

      \[ 1 + \color{blue}{\frac{1}{\frac{y + 1}{-1}}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      metadata-eval [<=]39.6%

      \[ 1 + \frac{\color{blue}{--1}}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      distribute-neg-frac [<=]39.6%

      \[ 1 + \color{blue}{\left(-\frac{-1}{\frac{y + 1}{-1}}\right)} \cdot \left(\left(1 - x\right) \cdot y\right) \]

      cancel-sign-sub-inv [<=]39.6%

      \[ \color{blue}{1 - \frac{-1}{\frac{y + 1}{-1}} \cdot \left(\left(1 - x\right) \cdot y\right)} \]

      associate-/r/ [<=]39.3%

      \[ 1 - \color{blue}{\frac{-1}{\frac{\frac{y + 1}{-1}}{\left(1 - x\right) \cdot y}}} \]

      associate-/r* [<=]39.3%

      \[ 1 - \frac{-1}{\color{blue}{\frac{y + 1}{-1 \cdot \left(\left(1 - x\right) \cdot y\right)}}} \]

      neg-mul-1 [<=]39.3%

      \[ 1 - \frac{-1}{\frac{y + 1}{\color{blue}{-\left(1 - x\right) \cdot y}}} \]

      associate-/r/ [=>]39.6%

      \[ 1 - \color{blue}{\frac{-1}{y + 1} \cdot \left(-\left(1 - x\right) \cdot y\right)} \]

      distribute-rgt-neg-in [<=]39.6%

      \[ 1 - \color{blue}{\left(-\frac{-1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)\right)} \]

      associate-/r/ [<=]39.3%

      \[ 1 - \left(-\color{blue}{\frac{-1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}}\right) \]

      distribute-neg-frac [=>]39.3%

      \[ 1 - \color{blue}{\frac{--1}{\frac{y + 1}{\left(1 - x\right) \cdot y}}} \]

      metadata-eval [=>]39.3%

      \[ 1 - \frac{\color{blue}{1}}{\frac{y + 1}{\left(1 - x\right) \cdot y}} \]

      associate-/r/ [=>]39.6%

      \[ 1 - \color{blue}{\frac{1}{y + 1} \cdot \left(\left(1 - x\right) \cdot y\right)} \]
    3. Taylor expanded in y around -inf 100.0%

      \[\leadsto \color{blue}{\left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + x\right)\right) - \frac{1}{{y}^{2}}} \]
    4. Simplified100.0%

      \[\leadsto \color{blue}{\left(x - \frac{x + -1}{y}\right) + \frac{x + -1}{y \cdot y}} \]
      Step-by-step derivation

      [Start]100.0%

      \[ \left(\frac{x}{{y}^{2}} + \left(-1 \cdot \frac{x - 1}{y} + x\right)\right) - \frac{1}{{y}^{2}} \]

      +-commutative [=>]100.0%

      \[ \color{blue}{\left(\left(-1 \cdot \frac{x - 1}{y} + x\right) + \frac{x}{{y}^{2}}\right)} - \frac{1}{{y}^{2}} \]

      associate--l+ [=>]100.0%

      \[ \color{blue}{\left(-1 \cdot \frac{x - 1}{y} + x\right) + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right)} \]

      +-commutative [=>]100.0%

      \[ \color{blue}{\left(x + -1 \cdot \frac{x - 1}{y}\right)} + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right) \]

      mul-1-neg [=>]100.0%

      \[ \left(x + \color{blue}{\left(-\frac{x - 1}{y}\right)}\right) + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right) \]

      unsub-neg [=>]100.0%

      \[ \color{blue}{\left(x - \frac{x - 1}{y}\right)} + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right) \]

      sub-neg [=>]100.0%

      \[ \left(x - \frac{\color{blue}{x + \left(-1\right)}}{y}\right) + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right) \]

      metadata-eval [=>]100.0%

      \[ \left(x - \frac{x + \color{blue}{-1}}{y}\right) + \left(\frac{x}{{y}^{2}} - \frac{1}{{y}^{2}}\right) \]

      div-sub [<=]100.0%

      \[ \left(x - \frac{x + -1}{y}\right) + \color{blue}{\frac{x - 1}{{y}^{2}}} \]

      sub-neg [=>]100.0%

      \[ \left(x - \frac{x + -1}{y}\right) + \frac{\color{blue}{x + \left(-1\right)}}{{y}^{2}} \]

      metadata-eval [=>]100.0%

      \[ \left(x - \frac{x + -1}{y}\right) + \frac{x + \color{blue}{-1}}{{y}^{2}} \]

      unpow2 [=>]100.0%

      \[ \left(x - \frac{x + -1}{y}\right) + \frac{x + -1}{\color{blue}{y \cdot y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -11500:\\ \;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + \frac{1 - x}{y}\right)\right) + \frac{x + -1}{y \cdot y}\\ \mathbf{elif}\;y \leq 300000:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + -1}{y \cdot y} + \left(x + \frac{1 - x}{y}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.9%
Cost7940
\[\begin{array}{l} t_0 := \frac{x + -1}{y \cdot y}\\ t_1 := \frac{1 - x}{y}\\ \mathbf{if}\;y \leq -11500:\\ \;\;\;\;\left(x + \left(\frac{1 - x}{{y}^{3}} + t_1\right)\right) + t_0\\ \mathbf{elif}\;y \leq 300000:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;t_0 + \left(x + t_1\right)\\ \end{array} \]
Alternative 2
Accuracy99.9%
Cost1225
\[\begin{array}{l} \mathbf{if}\;y \leq -205000 \lor \neg \left(y \leq 300000\right):\\ \;\;\;\;\frac{x + -1}{y \cdot y} + \left(x + \frac{1 - x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\ \end{array} \]
Alternative 3
Accuracy99.8%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -200000000 \lor \neg \left(y \leq 340000000\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + y \cdot \frac{x + -1}{y + 1}\\ \end{array} \]
Alternative 4
Accuracy99.0%
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -4600 \lor \neg \left(y \leq 1150000\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + y \cdot \frac{x}{y + 1}\\ \end{array} \]
Alternative 5
Accuracy98.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.85\right):\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(y \cdot x - y\right)\\ \end{array} \]
Alternative 6
Accuracy98.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;x + \frac{1 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(y \cdot x - y\right)\\ \end{array} \]
Alternative 7
Accuracy85.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 6.8 \cdot 10^{-17}\right):\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - y\\ \end{array} \]
Alternative 8
Accuracy98.1%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;x - \frac{-1}{y}\\ \mathbf{else}:\\ \;\;\;\;1 + y \cdot x\\ \end{array} \]
Alternative 9
Accuracy73.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-17}:\\ \;\;\;\;1 - y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy73.3%
Cost328
\[\begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-17}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy38.5%
Cost64
\[1 \]

Reproduce?

herbie shell --seed 2023271 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))

  (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))