Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3

Percentage Accurate: 93.1% → 99.8%
Time: 8.4s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\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 11 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: 93.1% accurate, 1.0× speedup?

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

\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{3 - x}{3} \cdot \frac{1 - x}{y} \end{array} \]
(FPCore (x y) :precision binary64 (* (/ (- 3.0 x) 3.0) (/ (- 1.0 x) y)))
double code(double x, double y) {
	return ((3.0 - x) / 3.0) * ((1.0 - x) / y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((3.0d0 - x) / 3.0d0) * ((1.0d0 - x) / y)
end function
public static double code(double x, double y) {
	return ((3.0 - x) / 3.0) * ((1.0 - x) / y);
}
def code(x, y):
	return ((3.0 - x) / 3.0) * ((1.0 - x) / y)
function code(x, y)
	return Float64(Float64(Float64(3.0 - x) / 3.0) * Float64(Float64(1.0 - x) / y))
end
function tmp = code(x, y)
	tmp = ((3.0 - x) / 3.0) * ((1.0 - x) / y);
end
code[x_, y_] := N[(N[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision] * N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{3 - x}{3} \cdot \frac{1 - x}{y}
\end{array}
Derivation
  1. Initial program 92.7%

    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. times-fracN/A

      \[\leadsto \frac{1 - x}{y} \cdot \color{blue}{\frac{3 - x}{3}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{3 - x}{3} \cdot \color{blue}{\frac{1 - x}{y}} \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\frac{3 - x}{3}\right), \color{blue}{\left(\frac{1 - x}{y}\right)}\right) \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(3 - x\right), 3\right), \left(\frac{\color{blue}{1 - x}}{y}\right)\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(3, x\right), 3\right), \left(\frac{\color{blue}{1} - x}{y}\right)\right) \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(3, x\right), 3\right), \mathsf{/.f64}\left(\left(1 - x\right), \color{blue}{y}\right)\right) \]
    7. --lowering--.f6499.9%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(3, x\right), 3\right), \mathsf{/.f64}\left(\mathsf{\_.f64}\left(1, x\right), y\right)\right) \]
  4. Applied egg-rr99.9%

    \[\leadsto \color{blue}{\frac{3 - x}{3} \cdot \frac{1 - x}{y}} \]
  5. Add Preprocessing

Alternative 2: 98.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;\frac{\frac{x + -4}{3}}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 1.75:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{-3} \cdot \left(4 - x\right)\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.7)
   (/ (/ (+ x -4.0) 3.0) (/ y x))
   (if (<= x 1.75)
     (/ (+ 1.0 (* x -1.3333333333333333)) y)
     (* (/ (/ x y) -3.0) (- 4.0 x)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = ((x + -4.0) / 3.0) / (y / x);
	} else if (x <= 1.75) {
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	} else {
		tmp = ((x / y) / -3.0) * (4.0 - 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.7d0)) then
        tmp = ((x + (-4.0d0)) / 3.0d0) / (y / x)
    else if (x <= 1.75d0) then
        tmp = (1.0d0 + (x * (-1.3333333333333333d0))) / y
    else
        tmp = ((x / y) / (-3.0d0)) * (4.0d0 - x)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = ((x + -4.0) / 3.0) / (y / x);
	} else if (x <= 1.75) {
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	} else {
		tmp = ((x / y) / -3.0) * (4.0 - x);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.7:
		tmp = ((x + -4.0) / 3.0) / (y / x)
	elif x <= 1.75:
		tmp = (1.0 + (x * -1.3333333333333333)) / y
	else:
		tmp = ((x / y) / -3.0) * (4.0 - x)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.7)
		tmp = Float64(Float64(Float64(x + -4.0) / 3.0) / Float64(y / x));
	elseif (x <= 1.75)
		tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y);
	else
		tmp = Float64(Float64(Float64(x / y) / -3.0) * Float64(4.0 - x));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.7)
		tmp = ((x + -4.0) / 3.0) / (y / x);
	elseif (x <= 1.75)
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	else
		tmp = ((x / y) / -3.0) * (4.0 - x);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.7], N[(N[(N[(x + -4.0), $MachinePrecision] / 3.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.75], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / -3.0), $MachinePrecision] * N[(4.0 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7:\\
\;\;\;\;\frac{\frac{x + -4}{3}}{\frac{y}{x}}\\

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

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


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

    1. Initial program 91.2%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({x}^{2} \cdot \left(1 - 4 \cdot \frac{1}{x}\right)\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} \cdot \left(1 + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      2. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 \cdot {x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(-4 \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(\frac{1}{x} \cdot {x}^{2}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      8. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{1 \cdot {x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      9. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{{x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{x \cdot x}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      11. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x \cdot 1}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      13. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \left(x \cdot \frac{1}{x}\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      14. rgt-mult-inverseN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot 1\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot x\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      16. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + -4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      18. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x - 4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x - 4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      20. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      21. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      22. +-lowering-+.f6491.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(x, -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
    5. Simplified91.1%

      \[\leadsto \frac{\color{blue}{x \cdot \left(x + -4\right)}}{y \cdot 3} \]
    6. Step-by-step derivation
      1. times-fracN/A

        \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x + -4}{3}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{x + -4}{3} \cdot \color{blue}{\frac{x}{y}} \]
      3. clear-numN/A

        \[\leadsto \frac{x + -4}{3} \cdot \frac{1}{\color{blue}{\frac{y}{x}}} \]
      4. un-div-invN/A

        \[\leadsto \frac{\frac{x + -4}{3}}{\color{blue}{\frac{y}{x}}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x + -4}{3}\right), \color{blue}{\left(\frac{y}{x}\right)}\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(x + -4\right), 3\right), \left(\frac{\color{blue}{y}}{x}\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, -4\right), 3\right), \left(\frac{y}{x}\right)\right) \]
      8. /-lowering-/.f6499.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, -4\right), 3\right), \mathsf{/.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{x + -4}{3}}{\frac{y}{x}}} \]

    if -1.69999999999999996 < x < 1.75

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{1 + x \cdot -1.3333333333333333}{y}} \]

    if 1.75 < x

    1. Initial program 79.7%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({x}^{2} \cdot \left(1 - 4 \cdot \frac{1}{x}\right)\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} \cdot \left(1 + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      2. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 \cdot {x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(-4 \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(\frac{1}{x} \cdot {x}^{2}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      8. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{1 \cdot {x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      9. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{{x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{x \cdot x}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      11. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x \cdot 1}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      13. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \left(x \cdot \frac{1}{x}\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      14. rgt-mult-inverseN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot 1\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot x\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      16. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + -4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      18. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x - 4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x - 4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      20. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      21. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      22. +-lowering-+.f6479.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(x, -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
    5. Simplified79.7%

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

        \[\leadsto \frac{x \cdot \left(x + -4\right)}{3 \cdot \color{blue}{y}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{x \cdot \left(x + -4\right)}{3}}{\color{blue}{y}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \left(x + -4\right)}{3}\right), \color{blue}{y}\right) \]
      4. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      8. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{x + -4}{3}\right), y\right) \]
      9. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{3}{x + -4}}\right), y\right) \]
      10. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{3}{x + -4}}\right), y\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{3}{x + -4}\right)\right), y\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \left(x + -4\right)\right)\right), y\right) \]
      13. +-lowering-+.f6479.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \mathsf{+.f64}\left(x, -4\right)\right)\right), y\right) \]
    7. Applied egg-rr79.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{3}{x + -4}}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{3}{x + -4}}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{\frac{3}{x + -4}}} \]
      3. frac-2negN/A

        \[\leadsto \frac{\frac{x}{y}}{\frac{\mathsf{neg}\left(3\right)}{\color{blue}{\mathsf{neg}\left(\left(x + -4\right)\right)}}} \]
      4. associate-/r/N/A

        \[\leadsto \frac{\frac{x}{y}}{\mathsf{neg}\left(3\right)} \cdot \color{blue}{\left(\mathsf{neg}\left(\left(x + -4\right)\right)\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{x}{y}}{\mathsf{neg}\left(3\right)}\right), \color{blue}{\left(\mathsf{neg}\left(\left(x + -4\right)\right)\right)}\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{x}{y}\right), \left(\mathsf{neg}\left(3\right)\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(x + -4\right)}\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), \left(\mathsf{neg}\left(3\right)\right)\right), \left(\mathsf{neg}\left(\left(\color{blue}{x} + -4\right)\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\mathsf{neg}\left(\left(x + \color{blue}{-4}\right)\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\mathsf{neg}\left(\left(-4 + x\right)\right)\right)\right) \]
      10. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\left(\mathsf{neg}\left(-4\right)\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \]
      11. unsub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\left(\mathsf{neg}\left(-4\right)\right) - \color{blue}{x}\right)\right) \]
      12. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \mathsf{\_.f64}\left(\left(\mathsf{neg}\left(-4\right)\right), \color{blue}{x}\right)\right) \]
      13. metadata-eval99.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \mathsf{\_.f64}\left(4, x\right)\right) \]
    9. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{-3} \cdot \left(4 - x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 98.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{x}{y}}{-3} \cdot \left(4 - x\right)\\ \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.75:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (/ (/ x y) -3.0) (- 4.0 x))))
   (if (<= x -1.7)
     t_0
     (if (<= x 1.75) (/ (+ 1.0 (* x -1.3333333333333333)) y) t_0))))
double code(double x, double y) {
	double t_0 = ((x / y) / -3.0) * (4.0 - x);
	double tmp;
	if (x <= -1.7) {
		tmp = t_0;
	} else if (x <= 1.75) {
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	} 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 = ((x / y) / (-3.0d0)) * (4.0d0 - x)
    if (x <= (-1.7d0)) then
        tmp = t_0
    else if (x <= 1.75d0) then
        tmp = (1.0d0 + (x * (-1.3333333333333333d0))) / y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = ((x / y) / -3.0) * (4.0 - x);
	double tmp;
	if (x <= -1.7) {
		tmp = t_0;
	} else if (x <= 1.75) {
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = ((x / y) / -3.0) * (4.0 - x)
	tmp = 0
	if x <= -1.7:
		tmp = t_0
	elif x <= 1.75:
		tmp = (1.0 + (x * -1.3333333333333333)) / y
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(Float64(x / y) / -3.0) * Float64(4.0 - x))
	tmp = 0.0
	if (x <= -1.7)
		tmp = t_0;
	elseif (x <= 1.75)
		tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = ((x / y) / -3.0) * (4.0 - x);
	tmp = 0.0;
	if (x <= -1.7)
		tmp = t_0;
	elseif (x <= 1.75)
		tmp = (1.0 + (x * -1.3333333333333333)) / y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(x / y), $MachinePrecision] / -3.0), $MachinePrecision] * N[(4.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.7], t$95$0, If[LessEqual[x, 1.75], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{x}{y}}{-3} \cdot \left(4 - x\right)\\
\mathbf{if}\;x \leq -1.7:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 85.0%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({x}^{2} \cdot \left(1 - 4 \cdot \frac{1}{x}\right)\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} \cdot \left(1 + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      2. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 \cdot {x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(-4 \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(\frac{1}{x} \cdot {x}^{2}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      8. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{1 \cdot {x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      9. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{{x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{x \cdot x}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      11. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x \cdot 1}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      13. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \left(x \cdot \frac{1}{x}\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      14. rgt-mult-inverseN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot 1\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot x\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      16. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + -4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      18. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x - 4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x - 4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      20. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      21. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      22. +-lowering-+.f6485.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(x, -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
    5. Simplified85.0%

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

        \[\leadsto \frac{x \cdot \left(x + -4\right)}{3 \cdot \color{blue}{y}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{x \cdot \left(x + -4\right)}{3}}{\color{blue}{y}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \left(x + -4\right)}{3}\right), \color{blue}{y}\right) \]
      4. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      8. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{x + -4}{3}\right), y\right) \]
      9. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{3}{x + -4}}\right), y\right) \]
      10. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{3}{x + -4}}\right), y\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{3}{x + -4}\right)\right), y\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \left(x + -4\right)\right)\right), y\right) \]
      13. +-lowering-+.f6485.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \mathsf{+.f64}\left(x, -4\right)\right)\right), y\right) \]
    7. Applied egg-rr85.0%

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{3}{x + -4}}}{y}} \]
    8. Step-by-step derivation
      1. associate-/l/N/A

        \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{3}{x + -4}}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{x}{y}}{\color{blue}{\frac{3}{x + -4}}} \]
      3. frac-2negN/A

        \[\leadsto \frac{\frac{x}{y}}{\frac{\mathsf{neg}\left(3\right)}{\color{blue}{\mathsf{neg}\left(\left(x + -4\right)\right)}}} \]
      4. associate-/r/N/A

        \[\leadsto \frac{\frac{x}{y}}{\mathsf{neg}\left(3\right)} \cdot \color{blue}{\left(\mathsf{neg}\left(\left(x + -4\right)\right)\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{x}{y}}{\mathsf{neg}\left(3\right)}\right), \color{blue}{\left(\mathsf{neg}\left(\left(x + -4\right)\right)\right)}\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{x}{y}\right), \left(\mathsf{neg}\left(3\right)\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(x + -4\right)}\right)\right)\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), \left(\mathsf{neg}\left(3\right)\right)\right), \left(\mathsf{neg}\left(\left(\color{blue}{x} + -4\right)\right)\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\mathsf{neg}\left(\left(x + \color{blue}{-4}\right)\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\mathsf{neg}\left(\left(-4 + x\right)\right)\right)\right) \]
      10. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\left(\mathsf{neg}\left(-4\right)\right) + \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) \]
      11. unsub-negN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \left(\left(\mathsf{neg}\left(-4\right)\right) - \color{blue}{x}\right)\right) \]
      12. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \mathsf{\_.f64}\left(\left(\mathsf{neg}\left(-4\right)\right), \color{blue}{x}\right)\right) \]
      13. metadata-eval99.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(x, y\right), -3\right), \mathsf{\_.f64}\left(4, x\right)\right) \]
    9. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{x}{y}}{-3} \cdot \left(4 - x\right)} \]

    if -1.69999999999999996 < x < 1.75

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

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

Alternative 4: 98.9% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(-1.3333333333333333 + x \cdot 0.3333333333333333\right)\\
\mathbf{if}\;x \leq -1.7:\\
\;\;\;\;t\_0\\

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

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


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

    1. Initial program 85.0%

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

      \[\leadsto \color{blue}{{x}^{2} \cdot \left(\frac{1}{3} \cdot \frac{1}{y} - \frac{4}{3} \cdot \frac{1}{x \cdot y}\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto {x}^{2} \cdot \left(\frac{1}{3} \cdot \frac{1}{y}\right) + \color{blue}{{x}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\frac{1}{3} \cdot \frac{1}{y}\right) \cdot {x}^{2} + \color{blue}{{x}^{2}} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      4. unpow2N/A

        \[\leadsto \left(\frac{1}{3} \cdot \frac{1}{y}\right) \cdot \left(x \cdot x\right) + {x}^{\color{blue}{2}} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(\left(\frac{1}{3} \cdot \frac{1}{y}\right) \cdot x\right) \cdot x + \color{blue}{{x}^{2}} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      6. associate-*r/N/A

        \[\leadsto \left(\frac{\frac{1}{3} \cdot 1}{y} \cdot x\right) \cdot x + {x}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      7. metadata-evalN/A

        \[\leadsto \left(\frac{\frac{1}{3}}{y} \cdot x\right) \cdot x + {x}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      8. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot x}{y} \cdot x + {\color{blue}{x}}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      9. associate-*r/N/A

        \[\leadsto \left(\frac{1}{3} \cdot \frac{x}{y}\right) \cdot x + {\color{blue}{x}}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \left(\frac{x}{y} \cdot \frac{1}{3}\right) \cdot x + {\color{blue}{x}}^{2} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      11. associate-*l*N/A

        \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{3} \cdot x\right) + \color{blue}{{x}^{2}} \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{x \cdot y}\right)\right) \]
      12. associate-*r/N/A

        \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{3} \cdot x\right) + {x}^{2} \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{x \cdot y}\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{3} \cdot x\right) + {x}^{2} \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{x \cdot y}\right)\right) \]
      14. distribute-neg-fracN/A

        \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{3} \cdot x\right) + {x}^{2} \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\color{blue}{x \cdot y}} \]
      15. metadata-evalN/A

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

        \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{3} \cdot x\right) + \frac{{x}^{2} \cdot \frac{-4}{3}}{\color{blue}{x \cdot y}} \]
      17. times-fracN/A

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

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

    if -1.69999999999999996 < x < 1.75

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{1 + x \cdot -1.3333333333333333}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;\frac{x}{y} \cdot \left(-1.3333333333333333 + x \cdot 0.3333333333333333\right)\\ \mathbf{elif}\;x \leq 1.75:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-1.3333333333333333 + x \cdot 0.3333333333333333\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{3}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\


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

    1. Initial program 91.2%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified88.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6497.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{x}{y}}{\color{blue}{3}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{x}{y}\right), \color{blue}{3}\right) \]
      3. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{y}{x}}\right), 3\right) \]
      4. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{y}{x}}\right), 3\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{x}\right)\right), 3\right) \]
      6. /-lowering-/.f6497.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, x\right)\right), 3\right) \]
    9. Applied egg-rr97.3%

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{y}{x}}}{3}} \]

    if -4.5999999999999996 < x < 3

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{1 + x \cdot -1.3333333333333333}{y}} \]

    if 3 < x

    1. Initial program 79.7%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6479.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified79.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr99.3%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{3}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6:\\
\;\;\;\;\frac{\frac{x}{3}}{\frac{y}{x}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\


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

    1. Initial program 91.2%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified88.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. clear-numN/A

        \[\leadsto \frac{x}{3} \cdot \frac{1}{\color{blue}{\frac{y}{x}}} \]
      7. un-div-invN/A

        \[\leadsto \frac{\frac{x}{3}}{\color{blue}{\frac{y}{x}}} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{y}{x}\right)}\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{y}}{x}\right)\right) \]
      10. /-lowering-/.f6497.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(y, \color{blue}{x}\right)\right) \]
    7. Applied egg-rr97.3%

      \[\leadsto \color{blue}{\frac{\frac{x}{3}}{\frac{y}{x}}} \]

    if -4.5999999999999996 < x < 3

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{1 + x \cdot -1.3333333333333333}{y}} \]

    if 3 < x

    1. Initial program 79.7%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6479.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified79.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr99.3%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;\frac{\frac{x}{3}}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 98.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\


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

    1. Initial program 91.2%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified88.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6497.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{x}{3} \cdot \frac{1}{\color{blue}{\frac{y}{x}}} \]
      2. div-invN/A

        \[\leadsto \frac{\frac{x}{3}}{\color{blue}{\frac{y}{x}}} \]
      3. associate-/l/N/A

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{x} \cdot 3}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(\frac{y}{x} \cdot 3\right)}\right) \]
      5. associate-/r/N/A

        \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{y}{\color{blue}{\frac{x}{3}}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, \color{blue}{\left(\frac{x}{3}\right)}\right)\right) \]
      7. /-lowering-/.f6497.2%

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, \mathsf{/.f64}\left(x, \color{blue}{3}\right)\right)\right) \]
    9. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\frac{x}{3}}}} \]

    if -4.5999999999999996 < x < 3

    1. Initial program 99.5%

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

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

        \[\leadsto \frac{x}{y} \cdot \frac{-4}{3} + \frac{\color{blue}{1}}{y} \]
      2. associate-*l/N/A

        \[\leadsto \frac{x \cdot \frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      3. associate-*r/N/A

        \[\leadsto x \cdot \frac{\frac{-4}{3}}{y} + \frac{\color{blue}{1}}{y} \]
      4. metadata-evalN/A

        \[\leadsto x \cdot \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{y} + \frac{1}{y} \]
      5. distribute-neg-fracN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3}}{y}\right)\right) + \frac{1}{y} \]
      6. metadata-evalN/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{\frac{4}{3} \cdot 1}{y}\right)\right) + \frac{1}{y} \]
      7. associate-*r/N/A

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\frac{4}{3} \cdot \frac{1}{y}\right)\right) + \frac{1}{y} \]
      8. distribute-lft-neg-inN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\frac{4}{3}\right)\right) \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      9. metadata-evalN/A

        \[\leadsto x \cdot \left(\frac{-4}{3} \cdot \frac{1}{y}\right) + \frac{1}{y} \]
      10. associate-*r*N/A

        \[\leadsto \left(x \cdot \frac{-4}{3}\right) \cdot \frac{1}{y} + \frac{\color{blue}{1}}{y} \]
      11. *-commutativeN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x\right) \cdot \frac{1}{y} + \frac{1}{y} \]
      12. distribute-lft1-inN/A

        \[\leadsto \left(\frac{-4}{3} \cdot x + 1\right) \cdot \color{blue}{\frac{1}{y}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{\left(\frac{1}{y}\right)}\right) \]
      14. +-lowering-+.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\left(\frac{-4}{3} \cdot x\right), 1\right), \left(\frac{\color{blue}{1}}{y}\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \left(\frac{1}{y}\right)\right) \]
      16. /-lowering-/.f6498.4%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-4}{3}, x\right), 1\right), \mathsf{/.f64}\left(1, \color{blue}{y}\right)\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{\left(-1.3333333333333333 \cdot x + 1\right) \cdot \frac{1}{y}} \]
    6. Step-by-step derivation
      1. un-div-invN/A

        \[\leadsto \frac{\frac{-4}{3} \cdot x + 1}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-4}{3} \cdot x + 1\right), \color{blue}{y}\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 + \frac{-4}{3} \cdot x\right), y\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-4}{3} \cdot x\right)\right), y\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \frac{-4}{3}\right)\right), y\right) \]
      6. *-lowering-*.f6498.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \frac{-4}{3}\right)\right), y\right) \]
    7. Applied egg-rr98.4%

      \[\leadsto \color{blue}{\frac{1 + x \cdot -1.3333333333333333}{y}} \]

    if 3 < x

    1. Initial program 79.7%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6479.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified79.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr99.3%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 97.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\ \mathbf{elif}\;x \leq 0.58:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.7)
   (/ x (/ y (/ x 3.0)))
   (if (<= x 0.58) (/ 1.0 y) (* (/ x y) (/ x 3.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = x / (y / (x / 3.0));
	} else if (x <= 0.58) {
		tmp = 1.0 / y;
	} else {
		tmp = (x / y) * (x / 3.0);
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-1.7d0)) then
        tmp = x / (y / (x / 3.0d0))
    else if (x <= 0.58d0) then
        tmp = 1.0d0 / y
    else
        tmp = (x / y) * (x / 3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = x / (y / (x / 3.0));
	} else if (x <= 0.58) {
		tmp = 1.0 / y;
	} else {
		tmp = (x / y) * (x / 3.0);
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.7:
		tmp = x / (y / (x / 3.0))
	elif x <= 0.58:
		tmp = 1.0 / y
	else:
		tmp = (x / y) * (x / 3.0)
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.7)
		tmp = Float64(x / Float64(y / Float64(x / 3.0)));
	elseif (x <= 0.58)
		tmp = Float64(1.0 / y);
	else
		tmp = Float64(Float64(x / y) * Float64(x / 3.0));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.7)
		tmp = x / (y / (x / 3.0));
	elseif (x <= 0.58)
		tmp = 1.0 / y;
	else
		tmp = (x / y) * (x / 3.0);
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.7], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.58], N[(1.0 / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7:\\
\;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\

\mathbf{elif}\;x \leq 0.58:\\
\;\;\;\;\frac{1}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\


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

    1. Initial program 91.2%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified88.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6497.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. clear-numN/A

        \[\leadsto \frac{x}{3} \cdot \frac{1}{\color{blue}{\frac{y}{x}}} \]
      2. div-invN/A

        \[\leadsto \frac{\frac{x}{3}}{\color{blue}{\frac{y}{x}}} \]
      3. associate-/l/N/A

        \[\leadsto \frac{x}{\color{blue}{\frac{y}{x} \cdot 3}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(\frac{y}{x} \cdot 3\right)}\right) \]
      5. associate-/r/N/A

        \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{y}{\color{blue}{\frac{x}{3}}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, \color{blue}{\left(\frac{x}{3}\right)}\right)\right) \]
      7. /-lowering-/.f6497.2%

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, \mathsf{/.f64}\left(x, \color{blue}{3}\right)\right)\right) \]
    9. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\frac{x}{3}}}} \]

    if -1.69999999999999996 < x < 0.57999999999999996

    1. Initial program 99.5%

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

      \[\leadsto \color{blue}{\frac{1}{y}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6497.7%

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{y}\right) \]
    5. Simplified97.7%

      \[\leadsto \color{blue}{\frac{1}{y}} \]

    if 0.57999999999999996 < x

    1. Initial program 79.7%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6479.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified79.2%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr99.3%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\ \mathbf{elif}\;x \leq 0.58:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 97.8% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \frac{x}{3}\\
\mathbf{if}\;x \leq -1.7:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 0.58:\\
\;\;\;\;\frac{1}{y}\\

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


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

    1. Initial program 85.0%

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

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{{x}^{2}}{y}} \]
    4. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{1}{3} \cdot {x}^{2}}{\color{blue}{y}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{3} \cdot {x}^{2}\right), \color{blue}{y}\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left({x}^{2}\right)\right), y\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \left(x \cdot x\right)\right), y\right) \]
      5. *-lowering-*.f6483.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{1}{3}, \mathsf{*.f64}\left(x, x\right)\right), y\right) \]
    5. Simplified83.6%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \frac{\left(\frac{1}{3} \cdot x\right) \cdot x}{y} \]
      2. associate-/l*N/A

        \[\leadsto \left(\frac{1}{3} \cdot x\right) \cdot \color{blue}{\frac{x}{y}} \]
      3. *-commutativeN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{\color{blue}{x}}{y} \]
      4. metadata-evalN/A

        \[\leadsto \left(x \cdot \frac{1}{3}\right) \cdot \frac{x}{y} \]
      5. div-invN/A

        \[\leadsto \frac{x}{3} \cdot \frac{\color{blue}{x}}{y} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{x}{3}\right), \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \left(\frac{\color{blue}{x}}{y}\right)\right) \]
      8. /-lowering-/.f6498.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, 3\right), \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Applied egg-rr98.3%

      \[\leadsto \color{blue}{\frac{x}{3} \cdot \frac{x}{y}} \]

    if -1.69999999999999996 < x < 0.57999999999999996

    1. Initial program 99.5%

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

      \[\leadsto \color{blue}{\frac{1}{y}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6497.7%

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{y}\right) \]
    5. Simplified97.7%

      \[\leadsto \color{blue}{\frac{1}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \mathbf{elif}\;x \leq 0.58:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{3}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 57.6% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.75:\\
\;\;\;\;\frac{x}{y \cdot -0.75}\\

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


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

    1. Initial program 91.4%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left({x}^{2} \cdot \left(1 - 4 \cdot \frac{1}{x}\right)\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} \cdot \left(1 + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      2. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(1 \cdot {x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      3. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left({x}^{2} + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      4. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\mathsf{neg}\left(4 \cdot \frac{1}{x}\right)\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(\left(\mathsf{neg}\left(4\right)\right) \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + \left(-4 \cdot \frac{1}{x}\right) \cdot {x}^{2}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(\frac{1}{x} \cdot {x}^{2}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      8. associate-*l/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{1 \cdot {x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      9. *-lft-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{{x}^{2}}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \frac{x \cdot x}{x}\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      11. associate-/l*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      12. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \frac{x \cdot 1}{x}\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      13. associate-*r/N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot \left(x \cdot \frac{1}{x}\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      14. rgt-mult-inverseN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot \left(x \cdot 1\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      15. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot x + -4 \cdot x\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      16. distribute-rgt-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + -4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      17. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      18. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(x - 4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      19. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x - 4\right)\right), \mathsf{*.f64}\left(\color{blue}{y}, 3\right)\right) \]
      20. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + \left(\mathsf{neg}\left(4\right)\right)\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      21. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(x + -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
      22. +-lowering-+.f6489.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(x, -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
    5. Simplified89.9%

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

        \[\leadsto \frac{x \cdot \left(x + -4\right)}{3 \cdot \color{blue}{y}} \]
      2. associate-/r*N/A

        \[\leadsto \frac{\frac{x \cdot \left(x + -4\right)}{3}}{\color{blue}{y}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x \cdot \left(x + -4\right)}{3}\right), \color{blue}{y}\right) \]
      4. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x \cdot \left(x + -4\right)\right) \cdot \frac{1}{3}\right), y\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      7. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \left(\left(x + -4\right) \cdot \frac{1}{3}\right)\right), y\right) \]
      8. div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{x + -4}{3}\right), y\right) \]
      9. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x \cdot \frac{1}{\frac{3}{x + -4}}\right), y\right) \]
      10. un-div-invN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{x}{\frac{3}{x + -4}}\right), y\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{3}{x + -4}\right)\right), y\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \left(x + -4\right)\right)\right), y\right) \]
      13. +-lowering-+.f6489.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(3, \mathsf{+.f64}\left(x, -4\right)\right)\right), y\right) \]
    7. Applied egg-rr89.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{3}{x + -4}}}{y}} \]
    8. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(x, \color{blue}{\frac{-3}{4}}\right), y\right) \]
    9. Step-by-step derivation
      1. Simplified31.7%

        \[\leadsto \frac{\frac{x}{\color{blue}{-0.75}}}{y} \]
      2. Step-by-step derivation
        1. associate-/l/N/A

          \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{-3}{4}}} \]
        2. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(y \cdot \frac{-3}{4}\right)}\right) \]
        3. *-lowering-*.f6431.7%

          \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(y, \color{blue}{\frac{-3}{4}}\right)\right) \]
      3. Applied egg-rr31.7%

        \[\leadsto \color{blue}{\frac{x}{y \cdot -0.75}} \]

      if -0.75 < x

      1. Initial program 93.1%

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

        \[\leadsto \color{blue}{\frac{1}{y}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f6467.6%

          \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{y}\right) \]
      5. Simplified67.6%

        \[\leadsto \color{blue}{\frac{1}{y}} \]
    10. Recombined 2 regimes into one program.
    11. Add Preprocessing

    Alternative 11: 50.8% accurate, 3.7× speedup?

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

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

      \[\leadsto \color{blue}{\frac{1}{y}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f6453.8%

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{y}\right) \]
    5. Simplified53.8%

      \[\leadsto \color{blue}{\frac{1}{y}} \]
    6. Add Preprocessing

    Developer Target 1: 99.8% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \frac{1 - x}{y} \cdot \frac{3 - x}{3} \end{array} \]
    (FPCore (x y) :precision binary64 (* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0)))
    double code(double x, double y) {
    	return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
    }
    
    real(8) function code(x, y)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        code = ((1.0d0 - x) / y) * ((3.0d0 - x) / 3.0d0)
    end function
    
    public static double code(double x, double y) {
    	return ((1.0 - x) / y) * ((3.0 - x) / 3.0);
    }
    
    def code(x, y):
    	return ((1.0 - x) / y) * ((3.0 - x) / 3.0)
    
    function code(x, y)
    	return Float64(Float64(Float64(1.0 - x) / y) * Float64(Float64(3.0 - x) / 3.0))
    end
    
    function tmp = code(x, y)
    	tmp = ((1.0 - x) / y) * ((3.0 - x) / 3.0);
    end
    
    code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision] * N[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{1 - x}{y} \cdot \frac{3 - x}{3}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024145 
    (FPCore (x y)
      :name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
      :precision binary64
    
      :alt
      (! :herbie-platform default (* (/ (- 1 x) y) (/ (- 3 x) 3)))
    
      (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))