tanhf (example 3.4)

Percentage Accurate: 52.1% → 100.0%
Time: 7.0s
Alternatives: 8
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \frac{1 - \cos x}{\sin x} \end{array} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
double code(double x) {
	return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
	return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x):
	return (1.0 - math.cos(x)) / math.sin(x)
function code(x)
	return Float64(Float64(1.0 - cos(x)) / sin(x))
end
function tmp = code(x)
	tmp = (1.0 - cos(x)) / sin(x);
end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - \cos x}{\sin x}
\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 8 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: 52.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1 - \cos x}{\sin x} \end{array} \]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
double code(double x) {
	return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
	return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x):
	return (1.0 - math.cos(x)) / math.sin(x)
function code(x)
	return Float64(Float64(1.0 - cos(x)) / sin(x))
end
function tmp = code(x)
	tmp = (1.0 - cos(x)) / sin(x);
end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - \cos x}{\sin x}
\end{array}

Alternative 1: 100.0% accurate, 2.0× speedup?

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

\\
\tan \left(\frac{x}{2}\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 51.8% accurate, 8.2× speedup?

\[\begin{array}{l} \\ x \cdot \left(\left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right) + \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  x
  (+
   (+ 0.5 (* x (* x 0.041666666666666664)))
   (*
    (* x (+ 0.004166666666666667 (* (* x x) 0.00042162698412698415)))
    (* x (* x x))))))
double code(double x) {
	return x * ((0.5 + (x * (x * 0.041666666666666664))) + ((x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) * (x * (x * x))));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * ((0.5d0 + (x * (x * 0.041666666666666664d0))) + ((x * (0.004166666666666667d0 + ((x * x) * 0.00042162698412698415d0))) * (x * (x * x))))
end function
public static double code(double x) {
	return x * ((0.5 + (x * (x * 0.041666666666666664))) + ((x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) * (x * (x * x))));
}
def code(x):
	return x * ((0.5 + (x * (x * 0.041666666666666664))) + ((x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) * (x * (x * x))))
function code(x)
	return Float64(x * Float64(Float64(0.5 + Float64(x * Float64(x * 0.041666666666666664))) + Float64(Float64(x * Float64(0.004166666666666667 + Float64(Float64(x * x) * 0.00042162698412698415))) * Float64(x * Float64(x * x)))))
end
function tmp = code(x)
	tmp = x * ((0.5 + (x * (x * 0.041666666666666664))) + ((x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) * (x * (x * x))));
end
code[x_] := N[(x * N[(N[(0.5 + N[(x * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(0.004166666666666667 + N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(\left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right) + \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(x \cdot x\right), \left(\color{blue}{\frac{1}{24}} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(\color{blue}{\frac{1}{24}} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right)\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{\frac{1}{240}} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right)\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \left(\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) \cdot \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) \cdot x\right)}\right)\right)\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
    13. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \color{blue}{\left(\frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \left({x}^{2} \cdot \color{blue}{\frac{17}{40320}}\right)\right)\right)\right)\right)\right)\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{17}{40320}}\right)\right)\right)\right)\right)\right)\right)\right) \]
    16. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{17}{40320}\right)\right)\right)\right)\right)\right)\right)\right) \]
    17. *-lowering-*.f6453.3%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{17}{40320}\right)\right)\right)\right)\right)\right)\right)\right) \]
  7. Simplified53.3%

    \[\leadsto \color{blue}{x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right)\right)\right)} \]
  8. Step-by-step derivation
    1. distribute-rgt-inN/A

      \[\leadsto \mathsf{*.f64}\left(x, \left(\frac{1}{2} + \left(\frac{1}{24} \cdot \left(x \cdot x\right) + \color{blue}{\left(x \cdot \left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)\right) \cdot \left(x \cdot x\right)}\right)\right)\right) \]
    2. associate-+r+N/A

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\left(\frac{1}{2} + \frac{1}{24} \cdot \left(x \cdot x\right)\right), \color{blue}{\left(\left(x \cdot \left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)\right) \cdot \left(x \cdot x\right)\right)}\right)\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{1}{24} \cdot \left(x \cdot x\right)\right)\right), \left(\color{blue}{\left(x \cdot \left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)\right)} \cdot \left(x \cdot x\right)\right)\right)\right) \]
    5. associate-*r*N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(\left(\frac{1}{24} \cdot x\right) \cdot x\right)\right), \left(\left(x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)}\right) \cdot \left(x \cdot x\right)\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \left(x \cdot \left(\frac{1}{24} \cdot x\right)\right)\right), \left(\left(x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)}\right) \cdot \left(x \cdot x\right)\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \left(\frac{1}{24} \cdot x\right)\right)\right), \left(\left(x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)}\right) \cdot \left(x \cdot x\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \left(x \cdot \frac{1}{24}\right)\right)\right), \left(\left(x \cdot \left(x \cdot \color{blue}{\left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)}\right)\right) \cdot \left(x \cdot x\right)\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \left(\left(x \cdot \left(x \cdot \color{blue}{\left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)}\right)\right) \cdot \left(x \cdot x\right)\right)\right)\right) \]
    10. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \left(\left(\left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right) \cdot x\right) \cdot \left(\color{blue}{x} \cdot x\right)\right)\right)\right) \]
    11. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \left(\left(x \cdot \left(\frac{1}{240} + \left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}\right)\right)\right) \]
    12. cube-unmultN/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \left(\left(x \cdot x\right) \cdot \frac{17}{40320}\right)\right)\right), \left({x}^{3}\right)\right)\right)\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{17}{40320}\right)\right)\right), \left({x}^{3}\right)\right)\right)\right) \]
    17. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{17}{40320}\right)\right)\right), \left({x}^{3}\right)\right)\right)\right) \]
    18. cube-unmultN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{17}{40320}\right)\right)\right), \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right) \]
    19. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{17}{40320}\right)\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(x \cdot x\right)}\right)\right)\right)\right) \]
  9. Applied egg-rr53.3%

    \[\leadsto x \cdot \color{blue}{\left(\left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right) + \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)} \]
  10. Add Preprocessing

Alternative 3: 51.8% accurate, 9.8× speedup?

\[\begin{array}{l} \\ x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  x
  (+
   0.5
   (*
    (* x x)
    (+
     0.041666666666666664
     (*
      x
      (* x (+ 0.004166666666666667 (* (* x x) 0.00042162698412698415)))))))))
double code(double x) {
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415)))))));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * (0.5d0 + ((x * x) * (0.041666666666666664d0 + (x * (x * (0.004166666666666667d0 + ((x * x) * 0.00042162698412698415d0)))))))
end function
public static double code(double x) {
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415)))))));
}
def code(x):
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415)))))))
function code(x)
	return Float64(x * Float64(0.5 + Float64(Float64(x * x) * Float64(0.041666666666666664 + Float64(x * Float64(x * Float64(0.004166666666666667 + Float64(Float64(x * x) * 0.00042162698412698415))))))))
end
function tmp = code(x)
	tmp = x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * (0.004166666666666667 + ((x * x) * 0.00042162698412698415)))))));
end
code[x_] := N[(x * N[(0.5 + N[(N[(x * x), $MachinePrecision] * N[(0.041666666666666664 + N[(x * N[(x * N[(0.004166666666666667 + N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right)\right)\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\left(\frac{1}{24} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right) \]
    4. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(x \cdot x\right), \left(\color{blue}{\frac{1}{24}} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \left(\color{blue}{\frac{1}{24}} + {x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right)\right) \]
    7. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\left(x \cdot x\right) \cdot \left(\color{blue}{\frac{1}{240}} + \frac{17}{40320} \cdot {x}^{2}\right)\right)\right)\right)\right)\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{\left(x \cdot \left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)\right)}\right)\right)\right)\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \left(\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) \cdot \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right) \cdot x\right)}\right)\right)\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1}{240} + \frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right) \]
    13. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \color{blue}{\left(\frac{17}{40320} \cdot {x}^{2}\right)}\right)\right)\right)\right)\right)\right)\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \left({x}^{2} \cdot \color{blue}{\frac{17}{40320}}\right)\right)\right)\right)\right)\right)\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\frac{17}{40320}}\right)\right)\right)\right)\right)\right)\right)\right) \]
    16. unpow2N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\left(x \cdot x\right), \frac{17}{40320}\right)\right)\right)\right)\right)\right)\right)\right) \]
    17. *-lowering-*.f6453.3%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{240}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{17}{40320}\right)\right)\right)\right)\right)\right)\right)\right) \]
  7. Simplified53.3%

    \[\leadsto \color{blue}{x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right)\right)\right)} \]
  8. Add Preprocessing

Alternative 4: 51.8% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.041666666666666664 + 0.004166666666666667 \cdot \left(x \cdot x\right)\right) + x \cdot 0.5 \end{array} \]
(FPCore (x)
 :precision binary64
 (+
  (* (* x (* x x)) (+ 0.041666666666666664 (* 0.004166666666666667 (* x x))))
  (* x 0.5)))
double code(double x) {
	return ((x * (x * x)) * (0.041666666666666664 + (0.004166666666666667 * (x * x)))) + (x * 0.5);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((x * (x * x)) * (0.041666666666666664d0 + (0.004166666666666667d0 * (x * x)))) + (x * 0.5d0)
end function
public static double code(double x) {
	return ((x * (x * x)) * (0.041666666666666664 + (0.004166666666666667 * (x * x)))) + (x * 0.5);
}
def code(x):
	return ((x * (x * x)) * (0.041666666666666664 + (0.004166666666666667 * (x * x)))) + (x * 0.5)
function code(x)
	return Float64(Float64(Float64(x * Float64(x * x)) * Float64(0.041666666666666664 + Float64(0.004166666666666667 * Float64(x * x)))) + Float64(x * 0.5))
end
function tmp = code(x)
	tmp = ((x * (x * x)) * (0.041666666666666664 + (0.004166666666666667 * (x * x)))) + (x * 0.5);
end
code[x_] := N[(N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.041666666666666664 + N[(0.004166666666666667 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.041666666666666664 + 0.004166666666666667 \cdot \left(x \cdot x\right)\right) + x \cdot 0.5
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)}\right)\right)\right) \]
    4. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\frac{1}{240} \cdot {x}^{2}\right)}\right)\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({x}^{2} \cdot \color{blue}{\frac{1}{240}}\right)\right)\right)\right)\right) \]
    8. unpow2N/A

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{\left(x \cdot \frac{1}{240}\right)}\right)\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{\left(x \cdot \frac{1}{240}\right)}\right)\right)\right)\right)\right) \]
    11. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{240}}\right)\right)\right)\right)\right)\right) \]
  7. Simplified53.2%

    \[\leadsto \color{blue}{x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot 0.004166666666666667\right)\right)\right)} \]
  8. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\frac{1}{24} + x \cdot \left(x \cdot \frac{1}{240}\right)\right) \cdot \left(\left(x \cdot x\right) \cdot x\right)\right), \left(\color{blue}{\frac{1}{2}} \cdot x\right)\right) \]
    6. pow3N/A

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{1}{240}\right)\right), \left({x}^{3}\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    12. cube-unmultN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{1}{240}\right)\right), \left(x \cdot \left(x \cdot x\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{1}{240}\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot x\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{1}{240}\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    15. *-lowering-*.f6453.3%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \frac{1}{240}\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right)\right), \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right)\right) \]
  9. Applied egg-rr53.3%

    \[\leadsto \color{blue}{\left(0.041666666666666664 + \left(x \cdot x\right) \cdot 0.004166666666666667\right) \cdot \left(x \cdot \left(x \cdot x\right)\right) + 0.5 \cdot x} \]
  10. Final simplification53.3%

    \[\leadsto \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.041666666666666664 + 0.004166666666666667 \cdot \left(x \cdot x\right)\right) + x \cdot 0.5 \]
  11. Add Preprocessing

Alternative 5: 51.8% accurate, 13.7× speedup?

\[\begin{array}{l} \\ x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot 0.004166666666666667\right)\right)\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  x
  (+
   0.5
   (* (* x x) (+ 0.041666666666666664 (* x (* x 0.004166666666666667)))))))
double code(double x) {
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x * (0.5d0 + ((x * x) * (0.041666666666666664d0 + (x * (x * 0.004166666666666667d0)))))
end function
public static double code(double x) {
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))));
}
def code(x):
	return x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))))
function code(x)
	return Float64(x * Float64(0.5 + Float64(Float64(x * x) * Float64(0.041666666666666664 + Float64(x * Float64(x * 0.004166666666666667))))))
end
function tmp = code(x)
	tmp = x * (0.5 + ((x * x) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))));
end
code[x_] := N[(x * N[(0.5 + N[(N[(x * x), $MachinePrecision] * N[(0.041666666666666664 + N[(x * N[(x * 0.004166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot 0.004166666666666667\right)\right)\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left({x}^{2}\right), \color{blue}{\left(\frac{1}{24} + \frac{1}{240} \cdot {x}^{2}\right)}\right)\right)\right) \]
    4. unpow2N/A

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \color{blue}{\left(\frac{1}{240} \cdot {x}^{2}\right)}\right)\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left({x}^{2} \cdot \color{blue}{\frac{1}{240}}\right)\right)\right)\right)\right) \]
    8. unpow2N/A

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{\left(x \cdot \frac{1}{240}\right)}\right)\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{\left(x \cdot \frac{1}{240}\right)}\right)\right)\right)\right)\right) \]
    11. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{1}{240}}\right)\right)\right)\right)\right)\right) \]
  7. Simplified53.2%

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

Alternative 6: 51.8% accurate, 18.6× speedup?

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

\\
x \cdot 0.5 + x \cdot \left(x \cdot \left(x \cdot 0.041666666666666664\right)\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {x}^{2}\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{x}\right)\right)\right)\right) \]
    5. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right)\right) \]
  7. Simplified53.2%

    \[\leadsto \color{blue}{x \cdot \left(0.5 + 0.041666666666666664 \cdot \left(x \cdot x\right)\right)} \]
  8. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto x \cdot \left(\frac{1}{24} \cdot \left(x \cdot x\right) + \color{blue}{\frac{1}{2}}\right) \]
    2. distribute-lft-inN/A

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{1}{24} \cdot \left(x \cdot x\right)\right)\right), \left(\color{blue}{\frac{1}{2}} \cdot x\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \left(\left(\frac{1}{24} \cdot x\right) \cdot x\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \left(x \cdot \left(\frac{1}{24} \cdot x\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\frac{1}{24} \cdot x\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(x \cdot \frac{1}{24}\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \left(\frac{1}{2} \cdot x\right)\right) \]
    11. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \frac{1}{24}\right)\right)\right), \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right)\right) \]
  9. Applied egg-rr53.2%

    \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(x \cdot 0.041666666666666664\right)\right) + 0.5 \cdot x} \]
  10. Final simplification53.2%

    \[\leadsto x \cdot 0.5 + x \cdot \left(x \cdot \left(x \cdot 0.041666666666666664\right)\right) \]
  11. Add Preprocessing

Alternative 7: 51.8% accurate, 22.8× speedup?

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

\\
x \cdot \left(0.5 + 0.041666666666666664 \cdot \left(x \cdot x\right)\right)
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{x \cdot \left(\frac{1}{2} + \frac{1}{24} \cdot {x}^{2}\right)} \]
  6. Step-by-step derivation
    1. *-lowering-*.f64N/A

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

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

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

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \left(x \cdot \color{blue}{x}\right)\right)\right)\right) \]
    5. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right)\right) \]
  7. Simplified53.2%

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

Alternative 8: 51.9% accurate, 68.3× speedup?

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

\\
x \cdot 0.5
\end{array}
Derivation
  1. Initial program 51.5%

    \[\frac{1 - \cos x}{\sin x} \]
  2. Step-by-step derivation
    1. hang-p0-tanN/A

      \[\leadsto \tan \left(\frac{x}{2}\right) \]
    2. tan-lowering-tan.f64N/A

      \[\leadsto \mathsf{tan.f64}\left(\left(\frac{x}{2}\right)\right) \]
    3. /-lowering-/.f64100.0%

      \[\leadsto \mathsf{tan.f64}\left(\mathsf{/.f64}\left(x, 2\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\tan \left(\frac{x}{2}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
  6. Step-by-step derivation
    1. *-lowering-*.f6453.2%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
  7. Simplified53.2%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  8. Final simplification53.2%

    \[\leadsto x \cdot 0.5 \]
  9. Add Preprocessing

Developer Target 1: 100.0% accurate, 2.0× speedup?

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

\\
\tan \left(\frac{x}{2}\right)
\end{array}

Reproduce

?
herbie shell --seed 2024155 
(FPCore (x)
  :name "tanhf (example 3.4)"
  :precision binary64

  :alt
  (! :herbie-platform default (tan (/ x 2)))

  (/ (- 1.0 (cos x)) (sin x)))