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

Percentage Accurate: 93.6% → 99.8%
Time: 8.1s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 93.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{3 - x}{3}}{\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(Float64(3.0 - x) / 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[(N[(3.0 - x), $MachinePrecision] / 3.0), $MachinePrecision] / N[(y / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y} \cdot \left(x \cdot 0.3333333333333333 + -1.3333333333333333\right)\\ \mathbf{if}\;x \leq -1.72:\\ \;\;\;\;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) (+ (* x 0.3333333333333333) -1.3333333333333333))))
   (if (<= x -1.72)
     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) * ((x * 0.3333333333333333) + -1.3333333333333333);
	double tmp;
	if (x <= -1.72) {
		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) * ((x * 0.3333333333333333d0) + (-1.3333333333333333d0))
    if (x <= (-1.72d0)) 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) * ((x * 0.3333333333333333) + -1.3333333333333333);
	double tmp;
	if (x <= -1.72) {
		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) * ((x * 0.3333333333333333) + -1.3333333333333333)
	tmp = 0
	if x <= -1.72:
		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(Float64(x * 0.3333333333333333) + -1.3333333333333333))
	tmp = 0.0
	if (x <= -1.72)
		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) * ((x * 0.3333333333333333) + -1.3333333333333333);
	tmp = 0.0;
	if (x <= -1.72)
		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[(N[(x * 0.3333333333333333), $MachinePrecision] + -1.3333333333333333), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.72], 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(x \cdot 0.3333333333333333 + -1.3333333333333333\right)\\
\mathbf{if}\;x \leq -1.72:\\
\;\;\;\;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.71999999999999997 or 1.75 < x

    1. Initial program 87.6%

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

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

    if -1.71999999999999997 < x < 1.75

    1. Initial program 99.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 \mathsf{/.f64}\left(\color{blue}{\left(3 + -4 \cdot x\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.3% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 86.8%

      \[\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-*.f6485.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.70000000000000018 < 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 \mathsf{/.f64}\left(\color{blue}{\left(3 + -4 \cdot x\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.3% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 86.8%

      \[\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-*.f6485.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.70000000000000018 < 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 \mathsf{/.f64}\left(\color{blue}{\left(3 + -4 \cdot x\right)}, \mathsf{*.f64}\left(y, 3\right)\right) \]
    4. Step-by-step derivation
      1. *-rgt-identityN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.7% accurate, 0.6× speedup?

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

\mathbf{elif}\;x \leq 0.56:\\
\;\;\;\;\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.71999999999999997

    1. Initial program 87.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-*.f6484.3%

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

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.71999999999999997 < x < 0.56000000000000005

    1. Initial program 99.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-/.f6497.6%

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

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

    if 0.56000000000000005 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 87.6%

      \[\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-*.f6485.9%

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

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

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

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

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

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

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

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

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

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

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

    if -1.71999999999999997 < x < 0.56000000000000005

    1. Initial program 99.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-/.f6497.6%

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

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

Alternative 7: 97.7% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 87.6%

      \[\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-*.f6485.9%

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

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

    if -1.71999999999999997 < x < 0.56000000000000005

    1. Initial program 99.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-/.f6497.6%

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

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

Alternative 8: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 99.5% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(3, x\right), \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(1, x\right)\right)\right), \left(\frac{1}{3}\right)\right) \]
    12. metadata-eval99.6%

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

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

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

Alternative 10: 58.0% 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 87.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -0.75 < x

      1. Initial program 96.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{1}{y}} \]
      4. Step-by-step derivation
        1. /-lowering-/.f6467.8%

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

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

    Alternative 11: 52.0% 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 93.4%

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

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

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

    Developer Target 1: 99.9% 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 2024149 
    (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)))