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

Percentage Accurate: 93.6% → 99.8%
Time: 7.4s
Alternatives: 12
Speedup: 3.7×

Specification

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

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 12 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.

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\frac{1 - x}{y} \cdot \left(1 - \frac{x}{3}\right) \]
Derivation
  1. Initial program 92.1%

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

      \[\leadsto \color{blue}{\frac{1 - x}{y} \cdot \frac{3 - x}{3}} \]
    2. div-sub99.8%

      \[\leadsto \frac{1 - x}{y} \cdot \color{blue}{\left(\frac{3}{3} - \frac{x}{3}\right)} \]
    3. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\frac{1 - x}{y} \cdot \left(1 - \frac{x}{3}\right)} \]
  4. Final simplification99.8%

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

Alternative 2: 98.8% accurate, 0.8× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \lor \neg \left(x \leq 1.72\right):\\ \;\;\;\;\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -1.75 or 1.71999999999999997 < x

    1. Initial program 83.8%

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

      \[\leadsto \frac{\color{blue}{-4 \cdot x + {x}^{2}}}{y \cdot 3} \]
    3. Step-by-step derivation
      1. +-commutative83.3%

        \[\leadsto \frac{\color{blue}{{x}^{2} + -4 \cdot x}}{y \cdot 3} \]
      2. unpow283.3%

        \[\leadsto \frac{\color{blue}{x \cdot x} + -4 \cdot x}{y \cdot 3} \]
      3. distribute-rgt-out83.3%

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

      \[\leadsto \frac{\color{blue}{x \cdot \left(x + -4\right)}}{y \cdot 3} \]
    5. Step-by-step derivation
      1. div-inv83.3%

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

        \[\leadsto \color{blue}{\left(\left(x + -4\right) \cdot x\right)} \cdot \frac{1}{y \cdot 3} \]
      3. *-commutative83.3%

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

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

        \[\leadsto \left(\left(x + -4\right) \cdot x\right) \cdot \frac{\color{blue}{0.3333333333333333}}{y} \]
      6. associate-*l*99.3%

        \[\leadsto \color{blue}{\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
    6. Applied egg-rr99.3%

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

    if -1.75 < x < 1.71999999999999997

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.4%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.4%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} + -1.3333333333333333 \cdot \frac{x}{y}} \]
    5. Step-by-step derivation
      1. *-commutative99.1%

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

      \[\leadsto \color{blue}{\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333} \]
    7. Taylor expanded in y around 0 99.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.75 \lor \neg \left(x \leq 1.72\right):\\ \;\;\;\;\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \end{array} \]

Alternative 3: 98.8% accurate, 0.8× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \lor \neg \left(x \leq 1.72\right):\\ \;\;\;\;\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -1.75 or 1.71999999999999997 < x

    1. Initial program 83.8%

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

      \[\leadsto \frac{\color{blue}{-4 \cdot x + {x}^{2}}}{y \cdot 3} \]
    3. Step-by-step derivation
      1. +-commutative83.3%

        \[\leadsto \frac{\color{blue}{{x}^{2} + -4 \cdot x}}{y \cdot 3} \]
      2. unpow283.3%

        \[\leadsto \frac{\color{blue}{x \cdot x} + -4 \cdot x}{y \cdot 3} \]
      3. distribute-rgt-out83.3%

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

      \[\leadsto \frac{\color{blue}{x \cdot \left(x + -4\right)}}{y \cdot 3} \]
    5. Step-by-step derivation
      1. div-inv83.3%

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

        \[\leadsto \color{blue}{\left(\left(x + -4\right) \cdot x\right)} \cdot \frac{1}{y \cdot 3} \]
      3. *-commutative83.3%

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

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

        \[\leadsto \left(\left(x + -4\right) \cdot x\right) \cdot \frac{\color{blue}{0.3333333333333333}}{y} \]
      6. associate-*l*99.3%

        \[\leadsto \color{blue}{\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
    6. Applied egg-rr99.3%

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

    if -1.75 < x < 1.71999999999999997

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.4%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.4%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} + -1.3333333333333333 \cdot \frac{x}{y}} \]
    5. Step-by-step derivation
      1. *-commutative99.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.75 \lor \neg \left(x \leq 1.72\right):\\ \;\;\;\;\left(x + -4\right) \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333\\ \end{array} \]

Alternative 4: 91.7% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;0.3333333333333333 \cdot \frac{x \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -3.7999999999999998 or 3 < x

    1. Initial program 83.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{x}^{2}}{y}} \]
    5. Step-by-step derivation
      1. unpow282.3%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{x \cdot x}}{y} \]
    6. Simplified82.3%

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

    if -3.7999999999999998 < x < 3

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{1 - x}{\frac{y \cdot 3}{3 - x}}} \]
      2. *-commutative99.9%

        \[\leadsto \frac{1 - x}{\frac{\color{blue}{3 \cdot y}}{3 - x}} \]
    3. Simplified99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;0.3333333333333333 \cdot \frac{x \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y}\\ \end{array} \]

Alternative 5: 97.7% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -3.7999999999999998 or 3 < x

    1. Initial program 83.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

      \[\leadsto \color{blue}{\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3}} \]
    4. Step-by-step derivation
      1. clear-num99.6%

        \[\leadsto \left(3 - x\right) \cdot \color{blue}{\frac{1}{\frac{3}{\frac{1 - x}{y}}}} \]
      2. un-div-inv99.7%

        \[\leadsto \color{blue}{\frac{3 - x}{\frac{3}{\frac{1 - x}{y}}}} \]
      3. associate-/r/99.7%

        \[\leadsto \frac{3 - x}{\color{blue}{\frac{3}{1 - x} \cdot y}} \]
    5. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{x}^{2}}{y}} \]
    7. Step-by-step derivation
      1. unpow282.3%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{x \cdot x}}{y} \]
      2. associate-*r/82.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
      3. associate-*l/82.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{y} \cdot \left(x \cdot x\right)} \]
      4. *-commutative82.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.3333333333333333}{y}} \]
      5. associate-*r*98.3%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
    8. Simplified98.3%

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

    if -3.7999999999999998 < x < 3

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{\frac{1 - x}{\frac{y \cdot 3}{3 - x}}} \]
      2. *-commutative99.9%

        \[\leadsto \frac{1 - x}{\frac{\color{blue}{3 \cdot y}}{3 - x}} \]
    3. Simplified99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - x}{y}\\ \end{array} \]

Alternative 6: 98.2% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -4.5999999999999996 or 3 < x

    1. Initial program 83.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

      \[\leadsto \color{blue}{\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3}} \]
    4. Step-by-step derivation
      1. clear-num99.6%

        \[\leadsto \left(3 - x\right) \cdot \color{blue}{\frac{1}{\frac{3}{\frac{1 - x}{y}}}} \]
      2. un-div-inv99.7%

        \[\leadsto \color{blue}{\frac{3 - x}{\frac{3}{\frac{1 - x}{y}}}} \]
      3. associate-/r/99.7%

        \[\leadsto \frac{3 - x}{\color{blue}{\frac{3}{1 - x} \cdot y}} \]
    5. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{x}^{2}}{y}} \]
    7. Step-by-step derivation
      1. unpow282.3%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{x \cdot x}}{y} \]
      2. associate-*r/82.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
      3. associate-*l/82.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{y} \cdot \left(x \cdot x\right)} \]
      4. *-commutative82.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.3333333333333333}{y}} \]
      5. associate-*r*98.3%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
    8. Simplified98.3%

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

    if -4.5999999999999996 < x < 3

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.4%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.4%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} + -1.3333333333333333 \cdot \frac{x}{y}} \]
    5. Step-by-step derivation
      1. *-commutative99.1%

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

      \[\leadsto \color{blue}{\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333} \]
    7. Taylor expanded in y around 0 99.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6 \lor \neg \left(x \leq 3\right):\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \end{array} \]

Alternative 7: 98.2% accurate, 1.0× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{3}{x}}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if x < -4.5999999999999996

    1. Initial program 81.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{x}^{2}}{y}} \]
    5. Step-by-step derivation
      1. associate-*r/79.7%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot {x}^{2}}{y}} \]
      2. unpow279.7%

        \[\leadsto \frac{0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}}{y} \]
    6. Simplified79.7%

      \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
    7. Step-by-step derivation
      1. associate-/l*79.7%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{\frac{y}{x \cdot x}}} \]
      2. associate-/r/79.8%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{y} \cdot \left(x \cdot x\right)} \]
    8. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{y} \cdot \left(x \cdot x\right)} \]
    9. Step-by-step derivation
      1. associate-*l/79.7%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
      2. associate-*r*79.9%

        \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot x\right) \cdot x}}{y} \]
      3. metadata-eval79.9%

        \[\leadsto \frac{\left(\color{blue}{\frac{1}{3}} \cdot x\right) \cdot x}{y} \]
      4. associate-/r/79.9%

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{3}{x}}} \cdot x}{y} \]
      5. clear-num80.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{3}} \cdot x}{y} \]
      6. associate-/r/80.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{\frac{3}{x}}}}{y} \]
      7. associate-/l/97.9%

        \[\leadsto \color{blue}{\frac{x}{y \cdot \frac{3}{x}}} \]
      8. associate-/r*98.0%

        \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{3}{x}}} \]
    10. Applied egg-rr98.0%

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

    if -4.5999999999999996 < x < 3

    1. Initial program 99.6%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.4%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.4%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} + -1.3333333333333333 \cdot \frac{x}{y}} \]
    5. Step-by-step derivation
      1. *-commutative99.1%

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

      \[\leadsto \color{blue}{\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333} \]
    7. Taylor expanded in y around 0 99.1%

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

    if 3 < x

    1. Initial program 86.2%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

      \[\leadsto \color{blue}{\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3}} \]
    4. Step-by-step derivation
      1. clear-num99.6%

        \[\leadsto \left(3 - x\right) \cdot \color{blue}{\frac{1}{\frac{3}{\frac{1 - x}{y}}}} \]
      2. un-div-inv99.6%

        \[\leadsto \color{blue}{\frac{3 - x}{\frac{3}{\frac{1 - x}{y}}}} \]
      3. associate-/r/99.7%

        \[\leadsto \frac{3 - x}{\color{blue}{\frac{3}{1 - x} \cdot y}} \]
    5. Applied egg-rr99.7%

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

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \frac{{x}^{2}}{y}} \]
    7. Step-by-step derivation
      1. unpow285.2%

        \[\leadsto 0.3333333333333333 \cdot \frac{\color{blue}{x \cdot x}}{y} \]
      2. associate-*r/85.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{y}} \]
      3. associate-*l/85.2%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{y} \cdot \left(x \cdot x\right)} \]
      4. *-commutative85.2%

        \[\leadsto \color{blue}{\left(x \cdot x\right) \cdot \frac{0.3333333333333333}{y}} \]
      5. associate-*r*98.7%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
    8. Simplified98.7%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.6:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{3}{x}}\\ \mathbf{elif}\;x \leq 3:\\ \;\;\;\;\frac{1 + x \cdot -1.3333333333333333}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \frac{0.3333333333333333}{y}\right)\\ \end{array} \]

Alternative 8: 99.8% accurate, 1.0× speedup?

\[\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3} \]
Derivation
  1. Initial program 92.1%

    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
  2. Step-by-step derivation
    1. associate-*l/99.6%

      \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
    2. *-commutative99.6%

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

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

    \[\leadsto \color{blue}{\left(3 - x\right) \cdot \frac{\frac{1 - x}{y}}{3}} \]
  4. Final simplification99.7%

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

Alternative 9: 57.2% accurate, 1.6× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -0.75:\\ \;\;\;\;\frac{x}{y} \cdot -1.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -0.75

    1. Initial program 81.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{y} + -1.3333333333333333 \cdot \frac{x}{y}} \]
    5. Step-by-step derivation
      1. *-commutative31.6%

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

      \[\leadsto \color{blue}{\frac{1}{y} + \frac{x}{y} \cdot -1.3333333333333333} \]
    7. Taylor expanded in y around 0 31.6%

      \[\leadsto \color{blue}{\frac{1 + -1.3333333333333333 \cdot x}{y}} \]
    8. Taylor expanded in x around inf 31.6%

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

    if -0.75 < x

    1. Initial program 95.7%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.5%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.5%

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

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

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

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

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

Alternative 10: 57.1% accurate, 1.8× speedup?

\[\begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -1

    1. Initial program 81.8%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.7%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.7%

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

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

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

      \[\leadsto \left(3 - x\right) \cdot \color{blue}{\left(-0.3333333333333333 \cdot \frac{x}{y}\right)} \]
    5. Taylor expanded in x around 0 31.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    6. Step-by-step derivation
      1. neg-mul-131.6%

        \[\leadsto \color{blue}{-\frac{x}{y}} \]
      2. distribute-neg-frac31.6%

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    7. Simplified31.6%

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

    if -1 < x

    1. Initial program 95.7%

      \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
    2. Step-by-step derivation
      1. associate-*l/99.5%

        \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
      2. *-commutative99.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y}\\ \end{array} \]

Alternative 11: 56.2% accurate, 2.2× speedup?

\[\frac{1 - x}{y} \]
Derivation
  1. Initial program 92.1%

    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
  2. Step-by-step derivation
    1. associate-/l*99.8%

      \[\leadsto \color{blue}{\frac{1 - x}{\frac{y \cdot 3}{3 - x}}} \]
    2. *-commutative99.8%

      \[\leadsto \frac{1 - x}{\frac{\color{blue}{3 \cdot y}}{3 - x}} \]
  3. Simplified99.8%

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

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

    \[\leadsto \frac{1 - x}{y} \]

Alternative 12: 51.4% accurate, 3.7× speedup?

\[\frac{1}{y} \]
Derivation
  1. Initial program 92.1%

    \[\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \]
  2. Step-by-step derivation
    1. associate-*l/99.6%

      \[\leadsto \color{blue}{\frac{1 - x}{y \cdot 3} \cdot \left(3 - x\right)} \]
    2. *-commutative99.6%

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

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

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

    \[\leadsto \color{blue}{\frac{1}{y}} \]
  5. Final simplification53.4%

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

Developer target: 99.8% accurate, 1.0× speedup?

\[\frac{1 - x}{y} \cdot \frac{3 - x}{3} \]

Reproduce

?
herbie shell --seed 2023167 
(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)))