Average Error: 5.5 → 0.1
Time: 7.6s
Precision: binary64
Cost: 1220
\[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
\[\begin{array}{l} t_0 := \left(1 - x\right) \cdot \left(3 - x\right)\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{+291}:\\ \;\;\;\;\frac{\frac{t_0}{3}}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{3} \cdot \frac{x}{y}\\ \end{array} \]
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* (- 1.0 x) (- 3.0 x))))
   (if (<= t_0 5e+291) (/ (/ t_0 3.0) y) (* (/ x 3.0) (/ x y)))))
double code(double x, double y) {
	return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
double code(double x, double y) {
	double t_0 = (1.0 - x) * (3.0 - x);
	double tmp;
	if (t_0 <= 5e+291) {
		tmp = (t_0 / 3.0) / y;
	} else {
		tmp = (x / 3.0) * (x / y);
	}
	return tmp;
}
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
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 = (1.0d0 - x) * (3.0d0 - x)
    if (t_0 <= 5d+291) then
        tmp = (t_0 / 3.0d0) / y
    else
        tmp = (x / 3.0d0) * (x / y)
    end if
    code = tmp
end function
public static double code(double x, double y) {
	return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
public static double code(double x, double y) {
	double t_0 = (1.0 - x) * (3.0 - x);
	double tmp;
	if (t_0 <= 5e+291) {
		tmp = (t_0 / 3.0) / y;
	} else {
		tmp = (x / 3.0) * (x / y);
	}
	return tmp;
}
def code(x, y):
	return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
def code(x, y):
	t_0 = (1.0 - x) * (3.0 - x)
	tmp = 0
	if t_0 <= 5e+291:
		tmp = (t_0 / 3.0) / y
	else:
		tmp = (x / 3.0) * (x / y)
	return tmp
function code(x, y)
	return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0))
end
function code(x, y)
	t_0 = Float64(Float64(1.0 - x) * Float64(3.0 - x))
	tmp = 0.0
	if (t_0 <= 5e+291)
		tmp = Float64(Float64(t_0 / 3.0) / y);
	else
		tmp = Float64(Float64(x / 3.0) * Float64(x / y));
	end
	return tmp
end
function tmp = code(x, y)
	tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0);
end
function tmp_2 = code(x, y)
	t_0 = (1.0 - x) * (3.0 - x);
	tmp = 0.0;
	if (t_0 <= 5e+291)
		tmp = (t_0 / 3.0) / y;
	else
		tmp = (x / 3.0) * (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+291], N[(N[(t$95$0 / 3.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / 3.0), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\begin{array}{l}
t_0 := \left(1 - x\right) \cdot \left(3 - x\right)\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+291}:\\
\;\;\;\;\frac{\frac{t_0}{3}}{y}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original5.5
Target0.1
Herbie0.1
\[\frac{1 - x}{y} \cdot \frac{3 - x}{3} \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (-.f64 1 x) (-.f64 3 x)) < 5.0000000000000001e291

    1. Initial program 0.3

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{1 - x}{3 \cdot y} \cdot \left(3 - x\right)} \]
    3. Applied egg-rr0.1

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

    if 5.0000000000000001e291 < (*.f64 (-.f64 1 x) (-.f64 3 x))

    1. Initial program 57.6

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{1 - x}{3 \cdot y} \cdot \left(3 - x\right)} \]
    3. Applied egg-rr57.6

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

      \[\leadsto \frac{\frac{\color{blue}{{x}^{2}}}{3}}{y} \]
    5. Simplified57.6

      \[\leadsto \frac{\frac{\color{blue}{x \cdot x}}{3}}{y} \]
      Proof
      (*.f64 x x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow2_binary64 (pow.f64 x 2)): 0 points increase in error, 0 points decrease in error
    6. Applied egg-rr0.3

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

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

Alternatives

Alternative 1
Error1.4
Cost840
\[\begin{array}{l} t_0 := \frac{x}{3} \cdot \frac{x + -4}{y}\\ \mathbf{if}\;x \leq -102968357.36220635:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.0324510970799817 \cdot 10^{-7}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.2
Cost712
\[\begin{array}{l} t_0 := \frac{x}{3} \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -102968357.36220635:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.0324510970799817 \cdot 10^{-7}:\\ \;\;\;\;\frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.8
Cost712
\[\begin{array}{l} t_0 := \frac{x}{3} \cdot \frac{x}{y}\\ \mathbf{if}\;x \leq -102968357.36220635:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.0324510970799817 \cdot 10^{-7}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.1
Cost704
\[\frac{1 - x}{y} \cdot \left(1 - \frac{x}{3}\right) \]
Alternative 5
Error20.9
Cost192
\[\frac{1}{y} \]

Error

Reproduce

herbie shell --seed 2022302 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (* (/ (- 1.0 x) y) (/ (- 3.0 x) 3.0))

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