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

Percentage Accurate: 94.0% → 99.6%
Time: 9.1s
Alternatives: 14
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 14 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: 94.0% 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.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(3 - x\right) \cdot \left(1 - x\right)\\
\mathbf{if}\;t\_0 \leq 10^{+124}:\\
\;\;\;\;\frac{t\_0}{3 \cdot y}\\

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


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

    1. Initial program 99.6%

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

    if 9.99999999999999948e123 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x))

    1. Initial program 89.8%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{3}\right), y\right)\right) \]
    7. Simplified99.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\frac{x}{3}}}} \]
    10. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\frac{\color{blue}{x}}{3}}\right)\right) \]
      2. neg-mul-1N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(3, x\right), \left(-1 \cdot \left(\mathsf{neg}\left(\color{blue}{y}\right)\right)\right)\right)\right) \]
      16. neg-mul-1N/A

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(3, x\right), \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right)\right) \]
      17. remove-double-neg99.9%

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

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

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

Alternative 2: 98.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{x}{y}}{\frac{3}{x + -4}}\\ \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 (+ x -4.0)))))
   (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 / (x + -4.0));
	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 / (x + (-4.0d0)))
    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 / (x + -4.0));
	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 / (x + -4.0))
	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(3.0 / Float64(x + -4.0)))
	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 / (x + -4.0));
	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[(3.0 / N[(x + -4.0), $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{\frac{x}{y}}{\frac{3}{x + -4}}\\
\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 91.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-+.f6489.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(x, -4\right)\right), \mathsf{*.f64}\left(y, 3\right)\right) \]
    5. Simplified89.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. clear-numN/A

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

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

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

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

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

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

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

    if -1.69999999999999996 < x < 1.75

    1. Initial program 99.6%

      \[\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-/.f64100.0%

        \[\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. Simplified100.0%

      \[\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-*.f64100.0%

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

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

Alternative 3: 98.7% 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 91.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}{{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. Simplified97.1%

      \[\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.6%

      \[\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-/.f64100.0%

        \[\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. Simplified100.0%

      \[\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-*.f64100.0%

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

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

    \[\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 4: 98.2% 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}{\frac{y}{\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(x / Float64(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[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $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}{\frac{y}{\frac{x}{3}}}\\


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

    1. Initial program 93.0%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.5999999999999996 < x < 3

    1. Initial program 99.6%

      \[\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-/.f64100.0%

        \[\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. Simplified100.0%

      \[\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-*.f64100.0%

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

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

    if 3 < x

    1. Initial program 90.3%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{3}\right), y\right)\right) \]
    7. Simplified94.9%

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

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

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

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

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

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

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

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

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

Alternative 5: 98.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{3}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4.6)
   (* x (/ (/ x y) 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 * ((x / y) / 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 * ((x / y) / 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 * ((x / y) / 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 * ((x / y) / 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(Float64(x / y) / 3.0));
	elseif (x <= 3.0)
		tmp = Float64(Float64(1.0 + Float64(x * -1.3333333333333333)) / y);
	else
		tmp = Float64(x / Float64(y / Float64(x / 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4.6)
		tmp = x * ((x / y) / 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[(N[(x / y), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.0], N[(N[(1.0 + N[(x * -1.3333333333333333), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 93.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-*.f6489.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{0.3333333333333333}} \cdot x} \]
    8. Step-by-step derivation
      1. div-invN/A

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

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

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

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

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

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

    if -4.5999999999999996 < x < 3

    1. Initial program 99.6%

      \[\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-/.f64100.0%

        \[\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. Simplified100.0%

      \[\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-*.f64100.0%

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

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

    if 3 < x

    1. Initial program 90.3%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{3}\right), y\right)\right) \]
    7. Simplified94.9%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;x \cdot \frac{\frac{x}{y}}{3}\\ \mathbf{elif}\;x \leq 5.2:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{\frac{x}{3}}}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.7)
   (* x (/ (/ x y) 3.0))
   (if (<= x 5.2) (/ 1.0 y) (/ x (/ y (/ x 3.0))))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = x * ((x / y) / 3.0);
	} else if (x <= 5.2) {
		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 * ((x / y) / 3.0d0)
    else if (x <= 5.2d0) 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 * ((x / y) / 3.0);
	} else if (x <= 5.2) {
		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 * ((x / y) / 3.0)
	elif x <= 5.2:
		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(Float64(x / y) / 3.0));
	elseif (x <= 5.2)
		tmp = Float64(1.0 / y);
	else
		tmp = Float64(x / Float64(y / Float64(x / 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.7)
		tmp = x * ((x / y) / 3.0);
	elseif (x <= 5.2)
		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[(N[(x / y), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2], N[(1.0 / y), $MachinePrecision], N[(x / N[(y / N[(x / 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 93.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-*.f6489.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{0.3333333333333333}} \cdot x} \]
    8. Step-by-step derivation
      1. div-invN/A

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

    if 5.20000000000000018 < x

    1. Initial program 90.2%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 93.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-*.f6489.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{0.3333333333333333}} \cdot x} \]
    8. Step-by-step derivation
      1. div-invN/A

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

    if 5.20000000000000018 < x

    1. Initial program 90.2%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{\frac{x}{3}}}} \]
    10. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(x, \left(\frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)}{\frac{\color{blue}{x}}{3}}\right)\right) \]
      2. neg-mul-1N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(3, x\right), \left(-1 \cdot \left(\mathsf{neg}\left(\color{blue}{y}\right)\right)\right)\right)\right) \]
      16. neg-mul-1N/A

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{*.f64}\left(\mathsf{/.f64}\left(3, x\right), \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)\right)\right) \]
      17. remove-double-neg96.3%

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

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

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

Alternative 8: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 93.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-*.f6489.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{0.3333333333333333}} \cdot x} \]
    8. Step-by-step derivation
      1. div-invN/A

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

    if 5.20000000000000018 < x

    1. Initial program 90.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-*.f6486.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

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

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

Alternative 9: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 93.0%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

    if 5.20000000000000018 < x

    1. Initial program 90.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-*.f6486.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot x}{y \cdot 3} \cdot x \]
      9. *-lft-identityN/A

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

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

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

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

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

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

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

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

Alternative 10: 97.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7:\\ \;\;\;\;x \cdot \frac{x \cdot 0.3333333333333333}{y}\\ \mathbf{elif}\;x \leq 5.2:\\ \;\;\;\;\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 (/ (* x 0.3333333333333333) y))
   (if (<= x 5.2) (/ 1.0 y) (* (/ x y) (/ x 3.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.7) {
		tmp = x * ((x * 0.3333333333333333) / y);
	} else if (x <= 5.2) {
		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 * ((x * 0.3333333333333333d0) / y)
    else if (x <= 5.2d0) 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 * ((x * 0.3333333333333333) / y);
	} else if (x <= 5.2) {
		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 * ((x * 0.3333333333333333) / y)
	elif x <= 5.2:
		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(Float64(x * 0.3333333333333333) / y));
	elseif (x <= 5.2)
		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 * ((x * 0.3333333333333333) / y);
	elseif (x <= 5.2)
		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[(N[(x * 0.3333333333333333), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.2], 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:\\
\;\;\;\;x \cdot \frac{x \cdot 0.3333333333333333}{y}\\

\mathbf{elif}\;x \leq 5.2:\\
\;\;\;\;\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 93.0%

      \[\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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

    if 5.20000000000000018 < x

    1. Initial program 90.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-*.f6486.7%

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

      \[\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-/.f6496.2%

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

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

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

Alternative 11: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 91.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. clear-numN/A

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
    5. Taylor expanded in x around inf

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.69999999999999996 < x < 5.20000000000000018

    1. Initial program 99.6%

      \[\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-/.f6499.2%

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

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

Alternative 12: 99.6% accurate, 1.0× speedup?

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

\\
\frac{3 - x}{3 \cdot \frac{y}{1 - x}}
\end{array}
Derivation
  1. Initial program 95.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. clear-numN/A

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{3 - x}{\frac{y}{1 - x} \cdot 3}} \]
  5. Final simplification99.7%

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

Alternative 13: 57.8% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.75:\\ \;\;\;\;\frac{x}{y} \cdot -1.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -0.75) (* (/ x y) -1.3333333333333333) (/ 1.0 y)))
double code(double x, double y) {
	double tmp;
	if (x <= -0.75) {
		tmp = (x / y) * -1.3333333333333333;
	} 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) * (-1.3333333333333333d0)
    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) * -1.3333333333333333;
	} else {
		tmp = 1.0 / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -0.75:
		tmp = (x / y) * -1.3333333333333333
	else:
		tmp = 1.0 / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -0.75)
		tmp = Float64(Float64(x / y) * -1.3333333333333333);
	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) * -1.3333333333333333;
	else
		tmp = 1.0 / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -0.75], N[(N[(x / y), $MachinePrecision] * -1.3333333333333333), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 93.0%

      \[\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-/.f6429.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. Simplified29.4%

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

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

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

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

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

    if -0.75 < x

    1. Initial program 96.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-/.f6469.8%

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

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

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

Alternative 14: 51.1% 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 95.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-/.f6452.8%

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{y}\right) \]
  5. Simplified52.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 2024150 
(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)))