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

Percentage Accurate: 93.6% → 99.8%
Time: 2.4s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (* (- 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)
use fmin_fmax_functions
    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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(((1) - x) * ((3) - x)) / (y * (3))
END code
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}

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 9 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?

\[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (/ (* (- 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)
use fmin_fmax_functions
    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]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(((1) - x) * ((3) - x)) / (y * (3))
END code
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\left(x - 1\right) \cdot \frac{\mathsf{fma}\left(x, 0.3333333333333333, -1\right)}{y} \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (* (- x 1.0) (/ (fma x 0.3333333333333333 -1.0) y)))
double code(double x, double y) {
	return (x - 1.0) * (fma(x, 0.3333333333333333, -1.0) / y);
}
function code(x, y)
	return Float64(Float64(x - 1.0) * Float64(fma(x, 0.3333333333333333, -1.0) / y))
end
code[x_, y_] := N[(N[(x - 1.0), $MachinePrecision] * N[(N[(x * 0.3333333333333333 + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	(x - (1)) * (((x * (333333333333333314829616256247390992939472198486328125e-54)) + (-1)) / y)
END code
\left(x - 1\right) \cdot \frac{\mathsf{fma}\left(x, 0.3333333333333333, -1\right)}{y}
Derivation
  1. Initial program 93.6%

    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
  2. Step-by-step derivation
    1. Applied rewrites99.8%

      \[\leadsto \left(x - 1\right) \cdot \frac{\mathsf{fma}\left(x, 0.3333333333333333, -1\right)}{y} \]
    2. Add Preprocessing

    Alternative 2: 99.5% accurate, 1.0× speedup?

    \[\frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
    (FPCore (x y)
      :precision binary64
      :pre TRUE
      (* (/ (- x 3.0) y) (fma x 0.3333333333333333 -0.3333333333333333)))
    double code(double x, double y) {
    	return ((x - 3.0) / y) * fma(x, 0.3333333333333333, -0.3333333333333333);
    }
    
    function code(x, y)
    	return Float64(Float64(Float64(x - 3.0) / y) * fma(x, 0.3333333333333333, -0.3333333333333333))
    end
    
    code[x_, y_] := N[(N[(N[(x - 3.0), $MachinePrecision] / y), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]
    
    f(x, y):
    	x in [-inf, +inf],
    	y in [-inf, +inf]
    code: THEORY
    BEGIN
    f(x, y: real): real =
    	((x - (3)) / y) * ((x * (333333333333333314829616256247390992939472198486328125e-54)) + (-333333333333333314829616256247390992939472198486328125e-54))
    END code
    \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right)
    
    Derivation
    1. Initial program 93.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. Applied rewrites99.5%

        \[\leadsto \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
      2. Add Preprocessing

      Alternative 3: 98.2% accurate, 0.6× speedup?

      \[\begin{array}{l} \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - 3\right) \cdot \frac{0.3333333333333333 \cdot x}{y}\\ \end{array} \]
      (FPCore (x y)
        :precision binary64
        :pre TRUE
        (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0)
        (/ (fma -1.3333333333333333 x 1.0) y)
        (* (- x 3.0) (/ (* 0.3333333333333333 x) y))))
      double code(double x, double y) {
      	double tmp;
      	if (((1.0 - x) * (3.0 - x)) <= 5.0) {
      		tmp = fma(-1.3333333333333333, x, 1.0) / y;
      	} else {
      		tmp = (x - 3.0) * ((0.3333333333333333 * x) / y);
      	}
      	return tmp;
      }
      
      function code(x, y)
      	tmp = 0.0
      	if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0)
      		tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y);
      	else
      		tmp = Float64(Float64(x - 3.0) * Float64(Float64(0.3333333333333333 * x) / y));
      	end
      	return tmp
      end
      
      code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - 3.0), $MachinePrecision] * N[(N[(0.3333333333333333 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
      
      f(x, y):
      	x in [-inf, +inf],
      	y in [-inf, +inf]
      code: THEORY
      BEGIN
      f(x, y: real): real =
      	LET tmp = IF ((((1) - x) * ((3) - x)) <= (5)) THEN ((((-13333333333333332593184650249895639717578887939453125e-52) * x) + (1)) / y) ELSE ((x - (3)) * (((333333333333333314829616256247390992939472198486328125e-54) * x) / y)) ENDIF IN
      	tmp
      END code
      \begin{array}{l}
      \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
      \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(x - 3\right) \cdot \frac{0.3333333333333333 \cdot x}{y}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5

        1. Initial program 93.6%

          \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
        2. Step-by-step derivation
          1. Applied rewrites93.8%

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

            \[\leadsto \frac{1 + \frac{-4}{3} \cdot x}{y} \]
          3. Step-by-step derivation
            1. Applied rewrites57.2%

              \[\leadsto \frac{1 + -1.3333333333333333 \cdot x}{y} \]
            2. Step-by-step derivation
              1. Applied rewrites57.2%

                \[\leadsto \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]

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

              1. Initial program 93.6%

                \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
              2. Step-by-step derivation
                1. Applied rewrites99.5%

                  \[\leadsto \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                2. Taylor expanded in x around inf

                  \[\leadsto \frac{x - 3}{y} \cdot \left(\frac{1}{3} \cdot x\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites50.8%

                    \[\leadsto \frac{x - 3}{y} \cdot \left(0.3333333333333333 \cdot x\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites50.7%

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

                  Alternative 4: 98.2% accurate, 0.6× speedup?

                  \[\begin{array}{l} \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - 3}{y} \cdot \left(0.3333333333333333 \cdot x\right)\\ \end{array} \]
                  (FPCore (x y)
                    :precision binary64
                    :pre TRUE
                    (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0)
                    (/ (fma -1.3333333333333333 x 1.0) y)
                    (* (/ (- x 3.0) y) (* 0.3333333333333333 x))))
                  double code(double x, double y) {
                  	double tmp;
                  	if (((1.0 - x) * (3.0 - x)) <= 5.0) {
                  		tmp = fma(-1.3333333333333333, x, 1.0) / y;
                  	} else {
                  		tmp = ((x - 3.0) / y) * (0.3333333333333333 * x);
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y)
                  	tmp = 0.0
                  	if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0)
                  		tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y);
                  	else
                  		tmp = Float64(Float64(Float64(x - 3.0) / y) * Float64(0.3333333333333333 * x));
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(x - 3.0), $MachinePrecision] / y), $MachinePrecision] * N[(0.3333333333333333 * x), $MachinePrecision]), $MachinePrecision]]
                  
                  f(x, y):
                  	x in [-inf, +inf],
                  	y in [-inf, +inf]
                  code: THEORY
                  BEGIN
                  f(x, y: real): real =
                  	LET tmp = IF ((((1) - x) * ((3) - x)) <= (5)) THEN ((((-13333333333333332593184650249895639717578887939453125e-52) * x) + (1)) / y) ELSE (((x - (3)) / y) * ((333333333333333314829616256247390992939472198486328125e-54) * x)) ENDIF IN
                  	tmp
                  END code
                  \begin{array}{l}
                  \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
                  \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{x - 3}{y} \cdot \left(0.3333333333333333 \cdot x\right)\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5

                    1. Initial program 93.6%

                      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                    2. Step-by-step derivation
                      1. Applied rewrites93.8%

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

                        \[\leadsto \frac{1 + \frac{-4}{3} \cdot x}{y} \]
                      3. Step-by-step derivation
                        1. Applied rewrites57.2%

                          \[\leadsto \frac{1 + -1.3333333333333333 \cdot x}{y} \]
                        2. Step-by-step derivation
                          1. Applied rewrites57.2%

                            \[\leadsto \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]

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

                          1. Initial program 93.6%

                            \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                          2. Step-by-step derivation
                            1. Applied rewrites99.5%

                              \[\leadsto \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                            2. Taylor expanded in x around inf

                              \[\leadsto \frac{x - 3}{y} \cdot \left(\frac{1}{3} \cdot x\right) \]
                            3. Step-by-step derivation
                              1. Applied rewrites50.8%

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

                            Alternative 5: 98.2% accurate, 0.6× speedup?

                            \[\begin{array}{l} \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 50:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right)\\ \end{array} \]
                            (FPCore (x y)
                              :precision binary64
                              :pre TRUE
                              (if (<= (* (- 1.0 x) (- 3.0 x)) 50.0)
                              (/ (fma -1.3333333333333333 x 1.0) y)
                              (* (/ x y) (fma x 0.3333333333333333 -0.3333333333333333))))
                            double code(double x, double y) {
                            	double tmp;
                            	if (((1.0 - x) * (3.0 - x)) <= 50.0) {
                            		tmp = fma(-1.3333333333333333, x, 1.0) / y;
                            	} else {
                            		tmp = (x / y) * fma(x, 0.3333333333333333, -0.3333333333333333);
                            	}
                            	return tmp;
                            }
                            
                            function code(x, y)
                            	tmp = 0.0
                            	if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 50.0)
                            		tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y);
                            	else
                            		tmp = Float64(Float64(x / y) * fma(x, 0.3333333333333333, -0.3333333333333333));
                            	end
                            	return tmp
                            end
                            
                            code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 50.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.3333333333333333 + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]]
                            
                            f(x, y):
                            	x in [-inf, +inf],
                            	y in [-inf, +inf]
                            code: THEORY
                            BEGIN
                            f(x, y: real): real =
                            	LET tmp = IF ((((1) - x) * ((3) - x)) <= (50)) THEN ((((-13333333333333332593184650249895639717578887939453125e-52) * x) + (1)) / y) ELSE ((x / y) * ((x * (333333333333333314829616256247390992939472198486328125e-54)) + (-333333333333333314829616256247390992939472198486328125e-54))) ENDIF IN
                            	tmp
                            END code
                            \begin{array}{l}
                            \mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 50:\\
                            \;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;\frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right)\\
                            
                            
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 50

                              1. Initial program 93.6%

                                \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                              2. Step-by-step derivation
                                1. Applied rewrites93.8%

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

                                  \[\leadsto \frac{1 + \frac{-4}{3} \cdot x}{y} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites57.2%

                                    \[\leadsto \frac{1 + -1.3333333333333333 \cdot x}{y} \]
                                  2. Step-by-step derivation
                                    1. Applied rewrites57.2%

                                      \[\leadsto \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]

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

                                    1. Initial program 93.6%

                                      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                                    2. Step-by-step derivation
                                      1. Applied rewrites99.5%

                                        \[\leadsto \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                      2. Taylor expanded in x around inf

                                        \[\leadsto \frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites50.7%

                                          \[\leadsto \frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                      4. Recombined 2 regimes into one program.
                                      5. Add Preprocessing

                                      Alternative 6: 57.7% accurate, 1.4× speedup?

                                      \[\begin{array}{l} \mathbf{if}\;x \leq -3.106191387612017:\\ \;\;\;\;\frac{-1.3333333333333333 \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \]
                                      (FPCore (x y)
                                        :precision binary64
                                        :pre TRUE
                                        (if (<= x -3.106191387612017)
                                        (/ (* -1.3333333333333333 x) y)
                                        (/ 1.0 y)))
                                      double code(double x, double y) {
                                      	double tmp;
                                      	if (x <= -3.106191387612017) {
                                      		tmp = (-1.3333333333333333 * x) / y;
                                      	} else {
                                      		tmp = 1.0 / y;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      real(8) function code(x, y)
                                      use fmin_fmax_functions
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          real(8) :: tmp
                                          if (x <= (-3.106191387612017d0)) then
                                              tmp = ((-1.3333333333333333d0) * x) / y
                                          else
                                              tmp = 1.0d0 / y
                                          end if
                                          code = tmp
                                      end function
                                      
                                      public static double code(double x, double y) {
                                      	double tmp;
                                      	if (x <= -3.106191387612017) {
                                      		tmp = (-1.3333333333333333 * x) / y;
                                      	} else {
                                      		tmp = 1.0 / y;
                                      	}
                                      	return tmp;
                                      }
                                      
                                      def code(x, y):
                                      	tmp = 0
                                      	if x <= -3.106191387612017:
                                      		tmp = (-1.3333333333333333 * x) / y
                                      	else:
                                      		tmp = 1.0 / y
                                      	return tmp
                                      
                                      function code(x, y)
                                      	tmp = 0.0
                                      	if (x <= -3.106191387612017)
                                      		tmp = Float64(Float64(-1.3333333333333333 * x) / y);
                                      	else
                                      		tmp = Float64(1.0 / y);
                                      	end
                                      	return tmp
                                      end
                                      
                                      function tmp_2 = code(x, y)
                                      	tmp = 0.0;
                                      	if (x <= -3.106191387612017)
                                      		tmp = (-1.3333333333333333 * x) / y;
                                      	else
                                      		tmp = 1.0 / y;
                                      	end
                                      	tmp_2 = tmp;
                                      end
                                      
                                      code[x_, y_] := If[LessEqual[x, -3.106191387612017], N[(N[(-1.3333333333333333 * x), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
                                      
                                      f(x, y):
                                      	x in [-inf, +inf],
                                      	y in [-inf, +inf]
                                      code: THEORY
                                      BEGIN
                                      f(x, y: real): real =
                                      	LET tmp = IF (x <= (-310619138761201707410464223357848823070526123046875e-50)) THEN (((-13333333333333332593184650249895639717578887939453125e-52) * x) / y) ELSE ((1) / y) ENDIF IN
                                      	tmp
                                      END code
                                      \begin{array}{l}
                                      \mathbf{if}\;x \leq -3.106191387612017:\\
                                      \;\;\;\;\frac{-1.3333333333333333 \cdot x}{y}\\
                                      
                                      \mathbf{else}:\\
                                      \;\;\;\;\frac{1}{y}\\
                                      
                                      
                                      \end{array}
                                      
                                      Derivation
                                      1. Split input into 2 regimes
                                      2. if x < -3.1061913876120171

                                        1. Initial program 93.6%

                                          \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites93.8%

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

                                            \[\leadsto \frac{1 + \frac{-4}{3} \cdot x}{y} \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites57.2%

                                              \[\leadsto \frac{1 + -1.3333333333333333 \cdot x}{y} \]
                                            2. Step-by-step derivation
                                              1. Applied rewrites57.2%

                                                \[\leadsto \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]
                                              2. Taylor expanded in x around inf

                                                \[\leadsto \frac{\frac{-4}{3} \cdot x}{y} \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites9.7%

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

                                                if -3.1061913876120171 < x

                                                1. Initial program 93.6%

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

                                                  \[\leadsto \frac{1}{y} \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites51.7%

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

                                                Alternative 7: 57.7% accurate, 1.4× speedup?

                                                \[\begin{array}{l} \mathbf{if}\;x \leq -3.106191387612017:\\ \;\;\;\;\frac{x}{y} \cdot -0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \]
                                                (FPCore (x y)
                                                  :precision binary64
                                                  :pre TRUE
                                                  (if (<= x -3.106191387612017)
                                                  (* (/ x y) -0.3333333333333333)
                                                  (/ 1.0 y)))
                                                double code(double x, double y) {
                                                	double tmp;
                                                	if (x <= -3.106191387612017) {
                                                		tmp = (x / y) * -0.3333333333333333;
                                                	} else {
                                                		tmp = 1.0 / y;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                real(8) function code(x, y)
                                                use fmin_fmax_functions
                                                    real(8), intent (in) :: x
                                                    real(8), intent (in) :: y
                                                    real(8) :: tmp
                                                    if (x <= (-3.106191387612017d0)) then
                                                        tmp = (x / y) * (-0.3333333333333333d0)
                                                    else
                                                        tmp = 1.0d0 / y
                                                    end if
                                                    code = tmp
                                                end function
                                                
                                                public static double code(double x, double y) {
                                                	double tmp;
                                                	if (x <= -3.106191387612017) {
                                                		tmp = (x / y) * -0.3333333333333333;
                                                	} else {
                                                		tmp = 1.0 / y;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(x, y):
                                                	tmp = 0
                                                	if x <= -3.106191387612017:
                                                		tmp = (x / y) * -0.3333333333333333
                                                	else:
                                                		tmp = 1.0 / y
                                                	return tmp
                                                
                                                function code(x, y)
                                                	tmp = 0.0
                                                	if (x <= -3.106191387612017)
                                                		tmp = Float64(Float64(x / y) * -0.3333333333333333);
                                                	else
                                                		tmp = Float64(1.0 / y);
                                                	end
                                                	return tmp
                                                end
                                                
                                                function tmp_2 = code(x, y)
                                                	tmp = 0.0;
                                                	if (x <= -3.106191387612017)
                                                		tmp = (x / y) * -0.3333333333333333;
                                                	else
                                                		tmp = 1.0 / y;
                                                	end
                                                	tmp_2 = tmp;
                                                end
                                                
                                                code[x_, y_] := If[LessEqual[x, -3.106191387612017], N[(N[(x / y), $MachinePrecision] * -0.3333333333333333), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
                                                
                                                f(x, y):
                                                	x in [-inf, +inf],
                                                	y in [-inf, +inf]
                                                code: THEORY
                                                BEGIN
                                                f(x, y: real): real =
                                                	LET tmp = IF (x <= (-310619138761201707410464223357848823070526123046875e-50)) THEN ((x / y) * (-333333333333333314829616256247390992939472198486328125e-54)) ELSE ((1) / y) ENDIF IN
                                                	tmp
                                                END code
                                                \begin{array}{l}
                                                \mathbf{if}\;x \leq -3.106191387612017:\\
                                                \;\;\;\;\frac{x}{y} \cdot -0.3333333333333333\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;\frac{1}{y}\\
                                                
                                                
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if x < -3.1061913876120171

                                                  1. Initial program 93.6%

                                                    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                                                  2. Step-by-step derivation
                                                    1. Applied rewrites99.5%

                                                      \[\leadsto \frac{x - 3}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                                    2. Taylor expanded in x around inf

                                                      \[\leadsto \frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites50.7%

                                                        \[\leadsto \frac{x}{y} \cdot \mathsf{fma}\left(x, 0.3333333333333333, -0.3333333333333333\right) \]
                                                      2. Taylor expanded in x around 0

                                                        \[\leadsto \frac{x}{y} \cdot \frac{-1}{3} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites9.7%

                                                          \[\leadsto \frac{x}{y} \cdot -0.3333333333333333 \]

                                                        if -3.1061913876120171 < x

                                                        1. Initial program 93.6%

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

                                                          \[\leadsto \frac{1}{y} \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites51.7%

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

                                                        Alternative 8: 57.2% accurate, 1.6× speedup?

                                                        \[\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]
                                                        (FPCore (x y)
                                                          :precision binary64
                                                          :pre TRUE
                                                          (/ (fma -1.3333333333333333 x 1.0) y))
                                                        double code(double x, double y) {
                                                        	return fma(-1.3333333333333333, x, 1.0) / y;
                                                        }
                                                        
                                                        function code(x, y)
                                                        	return Float64(fma(-1.3333333333333333, x, 1.0) / y)
                                                        end
                                                        
                                                        code[x_, y_] := N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision]
                                                        
                                                        f(x, y):
                                                        	x in [-inf, +inf],
                                                        	y in [-inf, +inf]
                                                        code: THEORY
                                                        BEGIN
                                                        f(x, y: real): real =
                                                        	(((-13333333333333332593184650249895639717578887939453125e-52) * x) + (1)) / y
                                                        END code
                                                        \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}
                                                        
                                                        Derivation
                                                        1. Initial program 93.6%

                                                          \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
                                                        2. Step-by-step derivation
                                                          1. Applied rewrites93.8%

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

                                                            \[\leadsto \frac{1 + \frac{-4}{3} \cdot x}{y} \]
                                                          3. Step-by-step derivation
                                                            1. Applied rewrites57.2%

                                                              \[\leadsto \frac{1 + -1.3333333333333333 \cdot x}{y} \]
                                                            2. Step-by-step derivation
                                                              1. Applied rewrites57.2%

                                                                \[\leadsto \frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y} \]
                                                              2. Add Preprocessing

                                                              Alternative 9: 51.7% accurate, 3.3× speedup?

                                                              \[\frac{1}{y} \]
                                                              (FPCore (x y)
                                                                :precision binary64
                                                                :pre TRUE
                                                                (/ 1.0 y))
                                                              double code(double x, double y) {
                                                              	return 1.0 / y;
                                                              }
                                                              
                                                              real(8) function code(x, y)
                                                              use fmin_fmax_functions
                                                                  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]
                                                              
                                                              f(x, y):
                                                              	x in [-inf, +inf],
                                                              	y in [-inf, +inf]
                                                              code: THEORY
                                                              BEGIN
                                                              f(x, y: real): real =
                                                              	(1) / y
                                                              END code
                                                              \frac{1}{y}
                                                              
                                                              Derivation
                                                              1. Initial program 93.6%

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

                                                                \[\leadsto \frac{1}{y} \]
                                                              3. Step-by-step derivation
                                                                1. Applied rewrites51.7%

                                                                  \[\leadsto \frac{1}{y} \]
                                                                2. Add Preprocessing

                                                                Reproduce

                                                                ?
                                                                herbie shell --seed 2026092 
                                                                (FPCore (x y)
                                                                  :name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
                                                                  :precision binary64
                                                                  (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))