Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A

Percentage Accurate: 76.3% → 99.8%
Time: 8.7s
Alternatives: 7
Speedup: 3.1×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ \frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
	double t_0 = sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = sin((x * 0.5d0))
    code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
	double t_0 = Math.sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x):
	t_0 = math.sin((x * 0.5))
	return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x)
	t_0 = sin(Float64(x * 0.5))
	return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x))
end
function tmp = code(x)
	t_0 = sin((x * 0.5));
	tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x);
end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\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 7 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: 76.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ \frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
	double t_0 = sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / sin(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = sin((x * 0.5d0))
    code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
	double t_0 = Math.sin((x * 0.5));
	return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x):
	t_0 = math.sin((x * 0.5))
	return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x)
	t_0 = sin(Float64(x * 0.5))
	return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x))
end
function tmp = code(x)
	t_0 = sin((x * 0.5));
	tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x);
end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}

Alternative 1: 99.8% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \frac{\tan \left(0.5 \cdot x\right)}{0.75} \end{array} \]
(FPCore (x) :precision binary64 (/ (tan (* 0.5 x)) 0.75))
double code(double x) {
	return tan((0.5 * x)) / 0.75;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = tan((0.5d0 * x)) / 0.75d0
end function
public static double code(double x) {
	return Math.tan((0.5 * x)) / 0.75;
}
def code(x):
	return math.tan((0.5 * x)) / 0.75
function code(x)
	return Float64(tan(Float64(0.5 * x)) / 0.75)
end
function tmp = code(x)
	tmp = tan((0.5 * x)) / 0.75;
end
code[x_] := N[(N[Tan[N[(0.5 * x), $MachinePrecision]], $MachinePrecision] / 0.75), $MachinePrecision]
\begin{array}{l}

\\
\frac{\tan \left(0.5 \cdot x\right)}{0.75}
\end{array}
Derivation
  1. Initial program 80.2%

    \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. Applied rewrites55.0%

      \[\leadsto \color{blue}{\frac{\left(1 - \cos x\right) \cdot 1.3333333333333333}{\sin x}} \]
    2. Applied rewrites99.8%

      \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{0.75}} \]
    3. Step-by-step derivation
      1. lift-/.f64N/A

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

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

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

        \[\leadsto \frac{\tan \left(x \cdot \color{blue}{0.5}\right)}{0.75} \]
    4. Applied rewrites99.8%

      \[\leadsto \frac{\tan \color{blue}{\left(x \cdot 0.5\right)}}{0.75} \]
    5. Final simplification99.8%

      \[\leadsto \frac{\tan \left(0.5 \cdot x\right)}{0.75} \]
    6. Add Preprocessing

    Alternative 2: 99.5% accurate, 3.1× speedup?

    \[\begin{array}{l} \\ \tan \left(0.5 \cdot x\right) \cdot 1.3333333333333333 \end{array} \]
    (FPCore (x) :precision binary64 (* (tan (* 0.5 x)) 1.3333333333333333))
    double code(double x) {
    	return tan((0.5 * x)) * 1.3333333333333333;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = tan((0.5d0 * x)) * 1.3333333333333333d0
    end function
    
    public static double code(double x) {
    	return Math.tan((0.5 * x)) * 1.3333333333333333;
    }
    
    def code(x):
    	return math.tan((0.5 * x)) * 1.3333333333333333
    
    function code(x)
    	return Float64(tan(Float64(0.5 * x)) * 1.3333333333333333)
    end
    
    function tmp = code(x)
    	tmp = tan((0.5 * x)) * 1.3333333333333333;
    end
    
    code[x_] := N[(N[Tan[N[(0.5 * x), $MachinePrecision]], $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \tan \left(0.5 \cdot x\right) \cdot 1.3333333333333333
    \end{array}
    
    Derivation
    1. Initial program 80.2%

      \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. Applied rewrites55.0%

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

        \[\leadsto \color{blue}{\frac{4}{3} \cdot \frac{1 - \cos x}{\sin x}} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{\frac{1 - \cos x}{\sin x} \cdot \frac{4}{3}} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{\frac{1 - \cos x}{\sin x} \cdot \frac{4}{3}} \]
        3. hang-p0-tanN/A

          \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \cdot \frac{4}{3} \]
        4. *-rgt-identityN/A

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

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

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

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

          \[\leadsto \color{blue}{\tan \left(\frac{1}{2} \cdot x\right)} \cdot \frac{4}{3} \]
        9. lower-*.f6499.4

          \[\leadsto \tan \color{blue}{\left(0.5 \cdot x\right)} \cdot 1.3333333333333333 \]
      4. Applied rewrites99.4%

        \[\leadsto \color{blue}{\tan \left(0.5 \cdot x\right) \cdot 1.3333333333333333} \]
      5. Add Preprocessing

      Alternative 3: 51.5% accurate, 11.8× speedup?

      \[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(-0.125, x, \frac{1.5}{x}\right)} \end{array} \]
      (FPCore (x) :precision binary64 (/ 1.0 (fma -0.125 x (/ 1.5 x))))
      double code(double x) {
      	return 1.0 / fma(-0.125, x, (1.5 / x));
      }
      
      function code(x)
      	return Float64(1.0 / fma(-0.125, x, Float64(1.5 / x)))
      end
      
      code[x_] := N[(1.0 / N[(-0.125 * x + N[(1.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{1}{\mathsf{fma}\left(-0.125, x, \frac{1.5}{x}\right)}
      \end{array}
      
      Derivation
      1. Initial program 80.2%

        \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}{\sin x}} \]
        2. clear-numN/A

          \[\leadsto \color{blue}{\frac{1}{\frac{\sin x}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}}} \]
        3. lower-/.f64N/A

          \[\leadsto \color{blue}{\frac{1}{\frac{\sin x}{\left(\frac{8}{3} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)}}} \]
        4. lower-/.f6480.1

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

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

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

          \[\leadsto \frac{1}{\frac{\sin x}{\color{blue}{\frac{8}{3} \cdot \left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)}}} \]
        8. lift-sin.f64N/A

          \[\leadsto \frac{1}{\frac{\sin x}{\frac{8}{3} \cdot \left(\color{blue}{\sin \left(x \cdot \frac{1}{2}\right)} \cdot \sin \left(x \cdot \frac{1}{2}\right)\right)}} \]
        9. lift-sin.f64N/A

          \[\leadsto \frac{1}{\frac{\sin x}{\frac{8}{3} \cdot \left(\sin \left(x \cdot \frac{1}{2}\right) \cdot \color{blue}{\sin \left(x \cdot \frac{1}{2}\right)}\right)}} \]
        10. sin-multN/A

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

          \[\leadsto \frac{1}{\frac{\sin x}{\color{blue}{\frac{\frac{8}{3} \cdot \left(\cos \left(x \cdot \frac{1}{2} - x \cdot \frac{1}{2}\right) - \cos \left(x \cdot \frac{1}{2} + x \cdot \frac{1}{2}\right)\right)}{2}}}} \]
        12. *-commutativeN/A

          \[\leadsto \frac{1}{\frac{\sin x}{\frac{\color{blue}{\left(\cos \left(x \cdot \frac{1}{2} - x \cdot \frac{1}{2}\right) - \cos \left(x \cdot \frac{1}{2} + x \cdot \frac{1}{2}\right)\right) \cdot \frac{8}{3}}}{2}}} \]
        13. associate-/l*N/A

          \[\leadsto \frac{1}{\frac{\sin x}{\color{blue}{\left(\cos \left(x \cdot \frac{1}{2} - x \cdot \frac{1}{2}\right) - \cos \left(x \cdot \frac{1}{2} + x \cdot \frac{1}{2}\right)\right) \cdot \frac{\frac{8}{3}}{2}}}} \]
      4. Applied rewrites55.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sin x}{\left(1 - \cos x\right) \cdot 1.3333333333333333}}} \]
      5. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{3}{2} + \frac{-1}{8} \cdot {x}^{2}}{x}}} \]
      6. Step-by-step derivation
        1. lower-/.f64N/A

          \[\leadsto \frac{1}{\color{blue}{\frac{\frac{3}{2} + \frac{-1}{8} \cdot {x}^{2}}{x}}} \]
        2. +-commutativeN/A

          \[\leadsto \frac{1}{\frac{\color{blue}{\frac{-1}{8} \cdot {x}^{2} + \frac{3}{2}}}{x}} \]
        3. lower-fma.f64N/A

          \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(\frac{-1}{8}, {x}^{2}, \frac{3}{2}\right)}}{x}} \]
        4. unpow2N/A

          \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(\frac{-1}{8}, \color{blue}{x \cdot x}, \frac{3}{2}\right)}{x}} \]
        5. lower-*.f6449.2

          \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-0.125, \color{blue}{x \cdot x}, 1.5\right)}{x}} \]
      7. Applied rewrites49.2%

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(-0.125, x \cdot x, 1.5\right)}{x}}} \]
      8. Taylor expanded in x around 0

        \[\leadsto \frac{1}{\color{blue}{\frac{\frac{3}{2} + \frac{-1}{8} \cdot {x}^{2}}{x}}} \]
      9. Step-by-step derivation
        1. metadata-evalN/A

          \[\leadsto \frac{1}{\frac{\color{blue}{\frac{3}{2} \cdot 1} + \frac{-1}{8} \cdot {x}^{2}}{x}} \]
        2. lft-mult-inverseN/A

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

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

          \[\leadsto \frac{1}{\frac{\color{blue}{{x}^{2} \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} + \frac{-1}{8}\right)}}{x}} \]
        5. metadata-evalN/A

          \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} + \color{blue}{\left(\mathsf{neg}\left(\frac{1}{8}\right)\right)}\right)}{x}} \]
        6. sub-negN/A

          \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \color{blue}{\left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} - \frac{1}{8}\right)}}{x}} \]
        7. unpow2N/A

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

          \[\leadsto \frac{1}{\frac{\color{blue}{x \cdot \left(x \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} - \frac{1}{8}\right)\right)}}{x}} \]
        9. *-commutativeN/A

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

          \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} - \frac{1}{8}\right)\right) \cdot \frac{x}{x}}} \]
        11. *-inversesN/A

          \[\leadsto \frac{1}{\left(x \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} - \frac{1}{8}\right)\right) \cdot \color{blue}{1}} \]
        12. *-rgt-identityN/A

          \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} - \frac{1}{8}\right)}} \]
        13. sub-negN/A

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

          \[\leadsto \frac{1}{x \cdot \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}} + \color{blue}{\frac{-1}{8}}\right)} \]
        15. distribute-rgt-inN/A

          \[\leadsto \frac{1}{\color{blue}{\left(\frac{3}{2} \cdot \frac{1}{{x}^{2}}\right) \cdot x + \frac{-1}{8} \cdot x}} \]
        16. +-commutativeN/A

          \[\leadsto \frac{1}{\color{blue}{\frac{-1}{8} \cdot x + \left(\frac{3}{2} \cdot \frac{1}{{x}^{2}}\right) \cdot x}} \]
      10. Applied rewrites49.2%

        \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-0.125, x, \frac{1.5}{x}\right)}} \]
      11. Add Preprocessing

      Alternative 4: 51.4% accurate, 11.8× speedup?

      \[\begin{array}{l} \\ \frac{-1.3333333333333333}{\mathsf{fma}\left(0.16666666666666666, x, \frac{-2}{x}\right)} \end{array} \]
      (FPCore (x)
       :precision binary64
       (/ -1.3333333333333333 (fma 0.16666666666666666 x (/ -2.0 x))))
      double code(double x) {
      	return -1.3333333333333333 / fma(0.16666666666666666, x, (-2.0 / x));
      }
      
      function code(x)
      	return Float64(-1.3333333333333333 / fma(0.16666666666666666, x, Float64(-2.0 / x)))
      end
      
      code[x_] := N[(-1.3333333333333333 / N[(0.16666666666666666 * x + N[(-2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{-1.3333333333333333}{\mathsf{fma}\left(0.16666666666666666, x, \frac{-2}{x}\right)}
      \end{array}
      
      Derivation
      1. Initial program 80.2%

        \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. Applied rewrites55.0%

          \[\leadsto \color{blue}{\frac{\left(1 - \cos x\right) \cdot 1.3333333333333333}{\sin x}} \]
        2. Applied rewrites99.8%

          \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{0.75}} \]
        3. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{\frac{3}{4}}} \]
          2. clear-numN/A

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{4}{3}}}{\frac{1}{\tan \left(\frac{x}{2}\right)}} \]
          6. frac-2negN/A

            \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\mathsf{neg}\left(\frac{1}{\tan \left(\frac{x}{2}\right)}\right)}} \]
          7. distribute-frac-neg2N/A

            \[\leadsto \frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\color{blue}{\frac{1}{\mathsf{neg}\left(\tan \left(\frac{x}{2}\right)\right)}}} \]
          8. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(\frac{4}{3}\right)}{\frac{1}{\mathsf{neg}\left(\tan \left(\frac{x}{2}\right)\right)}}} \]
          9. metadata-evalN/A

            \[\leadsto \frac{\color{blue}{\frac{-4}{3}}}{\frac{1}{\mathsf{neg}\left(\tan \left(\frac{x}{2}\right)\right)}} \]
          10. distribute-frac-neg2N/A

            \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\mathsf{neg}\left(\frac{1}{\tan \left(\frac{x}{2}\right)}\right)}} \]
          11. distribute-neg-fracN/A

            \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\frac{\mathsf{neg}\left(1\right)}{\tan \left(\frac{x}{2}\right)}}} \]
          12. metadata-evalN/A

            \[\leadsto \frac{\frac{-4}{3}}{\frac{\color{blue}{-1}}{\tan \left(\frac{x}{2}\right)}} \]
          13. lower-/.f6499.3

            \[\leadsto \frac{-1.3333333333333333}{\color{blue}{\frac{-1}{\tan \left(\frac{x}{2}\right)}}} \]
          14. lift-/.f64N/A

            \[\leadsto \frac{\frac{-4}{3}}{\frac{-1}{\tan \color{blue}{\left(\frac{x}{2}\right)}}} \]
          15. clear-numN/A

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

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

            \[\leadsto \frac{\frac{-4}{3}}{\frac{-1}{\tan \color{blue}{\left(\frac{1}{2} \cdot x\right)}}} \]
          18. metadata-eval99.3

            \[\leadsto \frac{-1.3333333333333333}{\frac{-1}{\tan \left(\color{blue}{0.5} \cdot x\right)}} \]
        4. Applied rewrites99.3%

          \[\leadsto \color{blue}{\frac{-1.3333333333333333}{\frac{-1}{\tan \left(0.5 \cdot x\right)}}} \]
        5. Taylor expanded in x around 0

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

            \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\frac{\frac{1}{6} \cdot {x}^{2}}{x} - \frac{2}{x}}} \]
          2. associate-/l*N/A

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

            \[\leadsto \frac{\frac{-4}{3}}{\frac{1}{6} \cdot \frac{\color{blue}{x \cdot x}}{x} - \frac{2}{x}} \]
          4. associate-*l/N/A

            \[\leadsto \frac{\frac{-4}{3}}{\frac{1}{6} \cdot \color{blue}{\left(\frac{x}{x} \cdot x\right)} - \frac{2}{x}} \]
          5. *-inversesN/A

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

            \[\leadsto \frac{\frac{-4}{3}}{\frac{1}{6} \cdot \color{blue}{x} - \frac{2}{x}} \]
          7. sub-negN/A

            \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\frac{1}{6} \cdot x + \left(\mathsf{neg}\left(\frac{2}{x}\right)\right)}} \]
          8. lower-fma.f64N/A

            \[\leadsto \frac{\frac{-4}{3}}{\color{blue}{\mathsf{fma}\left(\frac{1}{6}, x, \mathsf{neg}\left(\frac{2}{x}\right)\right)}} \]
          9. distribute-neg-fracN/A

            \[\leadsto \frac{\frac{-4}{3}}{\mathsf{fma}\left(\frac{1}{6}, x, \color{blue}{\frac{\mathsf{neg}\left(2\right)}{x}}\right)} \]
          10. metadata-evalN/A

            \[\leadsto \frac{\frac{-4}{3}}{\mathsf{fma}\left(\frac{1}{6}, x, \frac{\color{blue}{-2}}{x}\right)} \]
          11. lower-/.f6449.1

            \[\leadsto \frac{-1.3333333333333333}{\mathsf{fma}\left(0.16666666666666666, x, \color{blue}{\frac{-2}{x}}\right)} \]
        7. Applied rewrites49.1%

          \[\leadsto \frac{-1.3333333333333333}{\color{blue}{\mathsf{fma}\left(0.16666666666666666, x, \frac{-2}{x}\right)}} \]
        8. Add Preprocessing

        Alternative 5: 51.1% accurate, 20.2× speedup?

        \[\begin{array}{l} \\ \frac{0.5 \cdot x}{0.75} \end{array} \]
        (FPCore (x) :precision binary64 (/ (* 0.5 x) 0.75))
        double code(double x) {
        	return (0.5 * x) / 0.75;
        }
        
        real(8) function code(x)
            real(8), intent (in) :: x
            code = (0.5d0 * x) / 0.75d0
        end function
        
        public static double code(double x) {
        	return (0.5 * x) / 0.75;
        }
        
        def code(x):
        	return (0.5 * x) / 0.75
        
        function code(x)
        	return Float64(Float64(0.5 * x) / 0.75)
        end
        
        function tmp = code(x)
        	tmp = (0.5 * x) / 0.75;
        end
        
        code[x_] := N[(N[(0.5 * x), $MachinePrecision] / 0.75), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{0.5 \cdot x}{0.75}
        \end{array}
        
        Derivation
        1. Initial program 80.2%

          \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. Applied rewrites55.0%

            \[\leadsto \color{blue}{\frac{\left(1 - \cos x\right) \cdot 1.3333333333333333}{\sin x}} \]
          2. Applied rewrites99.8%

            \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{0.75}} \]
          3. Taylor expanded in x around 0

            \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot x}}{\frac{3}{4}} \]
          4. Step-by-step derivation
            1. lower-*.f6448.8

              \[\leadsto \frac{\color{blue}{0.5 \cdot x}}{0.75} \]
          5. Applied rewrites48.8%

            \[\leadsto \frac{\color{blue}{0.5 \cdot x}}{0.75} \]
          6. Add Preprocessing

          Alternative 6: 50.8% accurate, 31.2× speedup?

          \[\begin{array}{l} \\ \left(0.5 \cdot x\right) \cdot 1.3333333333333333 \end{array} \]
          (FPCore (x) :precision binary64 (* (* 0.5 x) 1.3333333333333333))
          double code(double x) {
          	return (0.5 * x) * 1.3333333333333333;
          }
          
          real(8) function code(x)
              real(8), intent (in) :: x
              code = (0.5d0 * x) * 1.3333333333333333d0
          end function
          
          public static double code(double x) {
          	return (0.5 * x) * 1.3333333333333333;
          }
          
          def code(x):
          	return (0.5 * x) * 1.3333333333333333
          
          function code(x)
          	return Float64(Float64(0.5 * x) * 1.3333333333333333)
          end
          
          function tmp = code(x)
          	tmp = (0.5 * x) * 1.3333333333333333;
          end
          
          code[x_] := N[(N[(0.5 * x), $MachinePrecision] * 1.3333333333333333), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \left(0.5 \cdot x\right) \cdot 1.3333333333333333
          \end{array}
          
          Derivation
          1. Initial program 80.2%

            \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. Applied rewrites55.0%

              \[\leadsto \color{blue}{\frac{\left(1 - \cos x\right) \cdot 1.3333333333333333}{\sin x}} \]
            2. Applied rewrites99.8%

              \[\leadsto \color{blue}{\frac{\tan \left(\frac{x}{2}\right)}{0.75}} \]
            3. Taylor expanded in x around 0

              \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot x}}{\frac{3}{4}} \]
            4. Step-by-step derivation
              1. lower-*.f6448.8

                \[\leadsto \frac{\color{blue}{0.5 \cdot x}}{0.75} \]
            5. Applied rewrites48.8%

              \[\leadsto \frac{\color{blue}{0.5 \cdot x}}{0.75} \]
            6. Step-by-step derivation
              1. lift-/.f64N/A

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

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

                \[\leadsto \left(\frac{1}{2} \cdot x\right) \cdot \color{blue}{\frac{4}{3}} \]
              4. lower-*.f6448.5

                \[\leadsto \color{blue}{\left(0.5 \cdot x\right) \cdot 1.3333333333333333} \]
            7. Applied rewrites48.5%

              \[\leadsto \color{blue}{\left(0.5 \cdot x\right) \cdot 1.3333333333333333} \]
            8. Add Preprocessing

            Alternative 7: 50.8% accurate, 57.2× speedup?

            \[\begin{array}{l} \\ 0.6666666666666666 \cdot x \end{array} \]
            (FPCore (x) :precision binary64 (* 0.6666666666666666 x))
            double code(double x) {
            	return 0.6666666666666666 * x;
            }
            
            real(8) function code(x)
                real(8), intent (in) :: x
                code = 0.6666666666666666d0 * x
            end function
            
            public static double code(double x) {
            	return 0.6666666666666666 * x;
            }
            
            def code(x):
            	return 0.6666666666666666 * x
            
            function code(x)
            	return Float64(0.6666666666666666 * x)
            end
            
            function tmp = code(x)
            	tmp = 0.6666666666666666 * x;
            end
            
            code[x_] := N[(0.6666666666666666 * x), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            0.6666666666666666 \cdot x
            \end{array}
            
            Derivation
            1. Initial program 80.2%

              \[\frac{\left(\frac{8}{3} \cdot \sin \left(x \cdot 0.5\right)\right) \cdot \sin \left(x \cdot 0.5\right)}{\sin x} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

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

                \[\leadsto \color{blue}{x \cdot \frac{2}{3}} \]
              2. lower-*.f6448.5

                \[\leadsto \color{blue}{x \cdot 0.6666666666666666} \]
            5. Applied rewrites48.5%

              \[\leadsto \color{blue}{x \cdot 0.6666666666666666} \]
            6. Final simplification48.5%

              \[\leadsto 0.6666666666666666 \cdot x \]
            7. Add Preprocessing

            Developer Target 1: 99.5% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sin \left(x \cdot 0.5\right)\\ \frac{\frac{8 \cdot t\_0}{3}}{\frac{\sin x}{t\_0}} \end{array} \end{array} \]
            (FPCore (x)
             :precision binary64
             (let* ((t_0 (sin (* x 0.5)))) (/ (/ (* 8.0 t_0) 3.0) (/ (sin x) t_0))))
            double code(double x) {
            	double t_0 = sin((x * 0.5));
            	return ((8.0 * t_0) / 3.0) / (sin(x) / t_0);
            }
            
            real(8) function code(x)
                real(8), intent (in) :: x
                real(8) :: t_0
                t_0 = sin((x * 0.5d0))
                code = ((8.0d0 * t_0) / 3.0d0) / (sin(x) / t_0)
            end function
            
            public static double code(double x) {
            	double t_0 = Math.sin((x * 0.5));
            	return ((8.0 * t_0) / 3.0) / (Math.sin(x) / t_0);
            }
            
            def code(x):
            	t_0 = math.sin((x * 0.5))
            	return ((8.0 * t_0) / 3.0) / (math.sin(x) / t_0)
            
            function code(x)
            	t_0 = sin(Float64(x * 0.5))
            	return Float64(Float64(Float64(8.0 * t_0) / 3.0) / Float64(sin(x) / t_0))
            end
            
            function tmp = code(x)
            	t_0 = sin((x * 0.5));
            	tmp = ((8.0 * t_0) / 3.0) / (sin(x) / t_0);
            end
            
            code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(8.0 * t$95$0), $MachinePrecision] / 3.0), $MachinePrecision] / N[(N[Sin[x], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \sin \left(x \cdot 0.5\right)\\
            \frac{\frac{8 \cdot t\_0}{3}}{\frac{\sin x}{t\_0}}
            \end{array}
            \end{array}
            

            Reproduce

            ?
            herbie shell --seed 2024254 
            (FPCore (x)
              :name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
              :precision binary64
            
              :alt
              (! :herbie-platform default (/ (/ (* 8 (sin (* x 1/2))) 3) (/ (sin x) (sin (* x 1/2)))))
            
              (/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))