sintan (problem 3.4.5)

Percentage Accurate: 3.1% → 98.6%
Time: 23.0s
Alternatives: 5
Speedup: 207.0×

Specification

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

\\
\frac{x - \sin x}{x - \tan 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 5 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: 3.1% accurate, 1.0× speedup?

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

\\
\frac{x - \sin x}{x - \tan x}
\end{array}

Alternative 1: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + x \cdot \left(x \cdot 0.225\right)\right)\right) - 0.5 \end{array} \]
(FPCore (x)
 :precision binary64
 (-
  (+
   (* -0.009642857142857142 (pow x 4.0))
   (+ (* 0.00024107142857142857 (pow x 6.0)) (* x (* x 0.225))))
  0.5))
double code(double x) {
	return ((-0.009642857142857142 * pow(x, 4.0)) + ((0.00024107142857142857 * pow(x, 6.0)) + (x * (x * 0.225)))) - 0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (((-0.009642857142857142d0) * (x ** 4.0d0)) + ((0.00024107142857142857d0 * (x ** 6.0d0)) + (x * (x * 0.225d0)))) - 0.5d0
end function
public static double code(double x) {
	return ((-0.009642857142857142 * Math.pow(x, 4.0)) + ((0.00024107142857142857 * Math.pow(x, 6.0)) + (x * (x * 0.225)))) - 0.5;
}
def code(x):
	return ((-0.009642857142857142 * math.pow(x, 4.0)) + ((0.00024107142857142857 * math.pow(x, 6.0)) + (x * (x * 0.225)))) - 0.5
function code(x)
	return Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(Float64(0.00024107142857142857 * (x ^ 6.0)) + Float64(x * Float64(x * 0.225)))) - 0.5)
end
function tmp = code(x)
	tmp = ((-0.009642857142857142 * (x ^ 4.0)) + ((0.00024107142857142857 * (x ^ 6.0)) + (x * (x * 0.225)))) - 0.5;
end
code[x_] := N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.00024107142857142857 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(x * 0.225), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + x \cdot \left(x \cdot 0.225\right)\right)\right) - 0.5
\end{array}
Derivation
  1. Initial program 3.2%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. /-rgt-identity3.2%

      \[\leadsto \frac{x - \sin x}{\color{blue}{\frac{x - \tan x}{1}}} \]
    2. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{\frac{x - \tan x}{\color{blue}{--1}}} \]
    3. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x} \cdot \left(--1\right)} \]
    4. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{1} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{\frac{-1}{-1}} \]
    6. times-frac3.2%

      \[\leadsto \color{blue}{\frac{\left(x - \sin x\right) \cdot -1}{\left(x - \tan x\right) \cdot -1}} \]
    7. *-commutative3.2%

      \[\leadsto \frac{\left(x - \sin x\right) \cdot -1}{\color{blue}{-1 \cdot \left(x - \tan x\right)}} \]
    8. *-commutative3.2%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    9. neg-mul-13.2%

      \[\leadsto \frac{\color{blue}{-\left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    10. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{0 - \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    11. associate-+l-3.2%

      \[\leadsto \frac{\color{blue}{\left(0 - x\right) + \sin x}}{-1 \cdot \left(x - \tan x\right)} \]
    12. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{\left(-x\right)} + \sin x}{-1 \cdot \left(x - \tan x\right)} \]
    13. +-commutative3.2%

      \[\leadsto \frac{\color{blue}{\sin x + \left(-x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    14. unsub-neg3.2%

      \[\leadsto \frac{\color{blue}{\sin x - x}}{-1 \cdot \left(x - \tan x\right)} \]
    15. neg-mul-13.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-\left(x - \tan x\right)}} \]
    16. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{0 - \left(x - \tan x\right)}} \]
    17. associate-+l-3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(0 - x\right) + \tan x}} \]
    18. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(-x\right)} + \tan x} \]
    19. +-commutative3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x + \left(-x\right)}} \]
    20. unsub-neg3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x - x}} \]
  3. Simplified3.2%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 98.9%

    \[\leadsto \color{blue}{\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot {x}^{2}\right)\right) - 0.5} \]
  5. Step-by-step derivation
    1. expm1-log1p-u98.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.225 \cdot {x}^{2}\right)\right)}\right)\right) - 0.5 \]
    2. expm1-udef98.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\left(e^{\mathsf{log1p}\left(0.225 \cdot {x}^{2}\right)} - 1\right)}\right)\right) - 0.5 \]
  6. Applied egg-rr98.9%

    \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\left(e^{\mathsf{log1p}\left(0.225 \cdot {x}^{2}\right)} - 1\right)}\right)\right) - 0.5 \]
  7. Step-by-step derivation
    1. expm1-def98.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.225 \cdot {x}^{2}\right)\right)}\right)\right) - 0.5 \]
    2. expm1-log1p-u98.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{0.225 \cdot {x}^{2}}\right)\right) - 0.5 \]
    3. unpow298.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - 0.5 \]
    4. associate-*r*98.9%

      \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\left(0.225 \cdot x\right) \cdot x}\right)\right) - 0.5 \]
  8. Applied egg-rr98.9%

    \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + \color{blue}{\left(0.225 \cdot x\right) \cdot x}\right)\right) - 0.5 \]
  9. Final simplification98.9%

    \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + x \cdot \left(x \cdot 0.225\right)\right)\right) - 0.5 \]

Alternative 2: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right) - 0.5 \end{array} \]
(FPCore (x)
 :precision binary64
 (- (+ (* -0.009642857142857142 (pow x 4.0)) (* 0.225 (pow x 2.0))) 0.5))
double code(double x) {
	return ((-0.009642857142857142 * pow(x, 4.0)) + (0.225 * pow(x, 2.0))) - 0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (((-0.009642857142857142d0) * (x ** 4.0d0)) + (0.225d0 * (x ** 2.0d0))) - 0.5d0
end function
public static double code(double x) {
	return ((-0.009642857142857142 * Math.pow(x, 4.0)) + (0.225 * Math.pow(x, 2.0))) - 0.5;
}
def code(x):
	return ((-0.009642857142857142 * math.pow(x, 4.0)) + (0.225 * math.pow(x, 2.0))) - 0.5
function code(x)
	return Float64(Float64(Float64(-0.009642857142857142 * (x ^ 4.0)) + Float64(0.225 * (x ^ 2.0))) - 0.5)
end
function tmp = code(x)
	tmp = ((-0.009642857142857142 * (x ^ 4.0)) + (0.225 * (x ^ 2.0))) - 0.5;
end
code[x_] := N[(N[(N[(-0.009642857142857142 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.225 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]
\begin{array}{l}

\\
\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right) - 0.5
\end{array}
Derivation
  1. Initial program 3.2%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. /-rgt-identity3.2%

      \[\leadsto \frac{x - \sin x}{\color{blue}{\frac{x - \tan x}{1}}} \]
    2. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{\frac{x - \tan x}{\color{blue}{--1}}} \]
    3. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x} \cdot \left(--1\right)} \]
    4. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{1} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{\frac{-1}{-1}} \]
    6. times-frac3.2%

      \[\leadsto \color{blue}{\frac{\left(x - \sin x\right) \cdot -1}{\left(x - \tan x\right) \cdot -1}} \]
    7. *-commutative3.2%

      \[\leadsto \frac{\left(x - \sin x\right) \cdot -1}{\color{blue}{-1 \cdot \left(x - \tan x\right)}} \]
    8. *-commutative3.2%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    9. neg-mul-13.2%

      \[\leadsto \frac{\color{blue}{-\left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    10. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{0 - \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    11. associate-+l-3.2%

      \[\leadsto \frac{\color{blue}{\left(0 - x\right) + \sin x}}{-1 \cdot \left(x - \tan x\right)} \]
    12. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{\left(-x\right)} + \sin x}{-1 \cdot \left(x - \tan x\right)} \]
    13. +-commutative3.2%

      \[\leadsto \frac{\color{blue}{\sin x + \left(-x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    14. unsub-neg3.2%

      \[\leadsto \frac{\color{blue}{\sin x - x}}{-1 \cdot \left(x - \tan x\right)} \]
    15. neg-mul-13.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-\left(x - \tan x\right)}} \]
    16. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{0 - \left(x - \tan x\right)}} \]
    17. associate-+l-3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(0 - x\right) + \tan x}} \]
    18. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(-x\right)} + \tan x} \]
    19. +-commutative3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x + \left(-x\right)}} \]
    20. unsub-neg3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x - x}} \]
  3. Simplified3.2%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 98.6%

    \[\leadsto \color{blue}{\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right) - 0.5} \]
  5. Final simplification98.6%

    \[\leadsto \left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right) - 0.5 \]

Alternative 3: 98.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 3 \cdot \log \left(1 + {x}^{2} \cdot 0.075\right) - 0.5 \end{array} \]
(FPCore (x)
 :precision binary64
 (- (* 3.0 (log (+ 1.0 (* (pow x 2.0) 0.075)))) 0.5))
double code(double x) {
	return (3.0 * log((1.0 + (pow(x, 2.0) * 0.075)))) - 0.5;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (3.0d0 * log((1.0d0 + ((x ** 2.0d0) * 0.075d0)))) - 0.5d0
end function
public static double code(double x) {
	return (3.0 * Math.log((1.0 + (Math.pow(x, 2.0) * 0.075)))) - 0.5;
}
def code(x):
	return (3.0 * math.log((1.0 + (math.pow(x, 2.0) * 0.075)))) - 0.5
function code(x)
	return Float64(Float64(3.0 * log(Float64(1.0 + Float64((x ^ 2.0) * 0.075)))) - 0.5)
end
function tmp = code(x)
	tmp = (3.0 * log((1.0 + ((x ^ 2.0) * 0.075)))) - 0.5;
end
code[x_] := N[(N[(3.0 * N[Log[N[(1.0 + N[(N[Power[x, 2.0], $MachinePrecision] * 0.075), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]
\begin{array}{l}

\\
3 \cdot \log \left(1 + {x}^{2} \cdot 0.075\right) - 0.5
\end{array}
Derivation
  1. Initial program 3.2%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. /-rgt-identity3.2%

      \[\leadsto \frac{x - \sin x}{\color{blue}{\frac{x - \tan x}{1}}} \]
    2. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{\frac{x - \tan x}{\color{blue}{--1}}} \]
    3. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x} \cdot \left(--1\right)} \]
    4. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{1} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{\frac{-1}{-1}} \]
    6. times-frac3.2%

      \[\leadsto \color{blue}{\frac{\left(x - \sin x\right) \cdot -1}{\left(x - \tan x\right) \cdot -1}} \]
    7. *-commutative3.2%

      \[\leadsto \frac{\left(x - \sin x\right) \cdot -1}{\color{blue}{-1 \cdot \left(x - \tan x\right)}} \]
    8. *-commutative3.2%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    9. neg-mul-13.2%

      \[\leadsto \frac{\color{blue}{-\left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    10. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{0 - \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    11. associate-+l-3.2%

      \[\leadsto \frac{\color{blue}{\left(0 - x\right) + \sin x}}{-1 \cdot \left(x - \tan x\right)} \]
    12. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{\left(-x\right)} + \sin x}{-1 \cdot \left(x - \tan x\right)} \]
    13. +-commutative3.2%

      \[\leadsto \frac{\color{blue}{\sin x + \left(-x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    14. unsub-neg3.2%

      \[\leadsto \frac{\color{blue}{\sin x - x}}{-1 \cdot \left(x - \tan x\right)} \]
    15. neg-mul-13.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-\left(x - \tan x\right)}} \]
    16. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{0 - \left(x - \tan x\right)}} \]
    17. associate-+l-3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(0 - x\right) + \tan x}} \]
    18. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(-x\right)} + \tan x} \]
    19. +-commutative3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x + \left(-x\right)}} \]
    20. unsub-neg3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x - x}} \]
  3. Simplified3.2%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 98.9%

    \[\leadsto \color{blue}{\left(-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot {x}^{2}\right)\right) - 0.5} \]
  5. Step-by-step derivation
    1. add-log-exp98.8%

      \[\leadsto \color{blue}{\log \left(e^{-0.009642857142857142 \cdot {x}^{4} + \left(0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot {x}^{2}\right)}\right)} - 0.5 \]
    2. fma-def98.8%

      \[\leadsto \log \left(e^{\color{blue}{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.00024107142857142857 \cdot {x}^{6} + 0.225 \cdot {x}^{2}\right)}}\right) - 0.5 \]
    3. +-commutative98.8%

      \[\leadsto \log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \color{blue}{0.225 \cdot {x}^{2} + 0.00024107142857142857 \cdot {x}^{6}}\right)}\right) - 0.5 \]
    4. fma-def98.8%

      \[\leadsto \log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \color{blue}{\mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)}\right)}\right) - 0.5 \]
  6. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\log \left(e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}\right)} - 0.5 \]
  7. Step-by-step derivation
    1. add-cube-cbrt98.8%

      \[\leadsto \log \color{blue}{\left(\left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}} \cdot \sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right) \cdot \sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)} - 0.5 \]
    2. log-prod98.8%

      \[\leadsto \color{blue}{\left(\log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}} \cdot \sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right) + \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)\right)} - 0.5 \]
    3. pow298.8%

      \[\leadsto \left(\log \color{blue}{\left({\left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)}^{2}\right)} + \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)\right) - 0.5 \]
  8. Applied egg-rr98.8%

    \[\leadsto \color{blue}{\left(\log \left({\left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)}^{2}\right) + \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)\right)} - 0.5 \]
  9. Step-by-step derivation
    1. log-pow98.8%

      \[\leadsto \left(\color{blue}{2 \cdot \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)} + \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)\right) - 0.5 \]
    2. distribute-lft1-in98.8%

      \[\leadsto \color{blue}{\left(2 + 1\right) \cdot \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right)} - 0.5 \]
    3. metadata-eval98.8%

      \[\leadsto \color{blue}{3} \cdot \log \left(\sqrt[3]{e^{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)\right)}}\right) - 0.5 \]
    4. fma-def98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{\color{blue}{-0.009642857142857142 \cdot {x}^{4} + \mathsf{fma}\left(0.225, {x}^{2}, 0.00024107142857142857 \cdot {x}^{6}\right)}}}\right) - 0.5 \]
    5. fma-def98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{-0.009642857142857142 \cdot {x}^{4} + \color{blue}{\left(0.225 \cdot {x}^{2} + 0.00024107142857142857 \cdot {x}^{6}\right)}}}\right) - 0.5 \]
    6. associate-+l+98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{\color{blue}{\left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right) + 0.00024107142857142857 \cdot {x}^{6}}}}\right) - 0.5 \]
    7. +-commutative98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{\color{blue}{0.00024107142857142857 \cdot {x}^{6} + \left(-0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right)}}}\right) - 0.5 \]
    8. fma-def98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{\color{blue}{\mathsf{fma}\left(0.00024107142857142857, {x}^{6}, -0.009642857142857142 \cdot {x}^{4} + 0.225 \cdot {x}^{2}\right)}}}\right) - 0.5 \]
    9. fma-def98.8%

      \[\leadsto 3 \cdot \log \left(\sqrt[3]{e^{\mathsf{fma}\left(0.00024107142857142857, {x}^{6}, \color{blue}{\mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.225 \cdot {x}^{2}\right)}\right)}}\right) - 0.5 \]
  10. Simplified98.8%

    \[\leadsto \color{blue}{3 \cdot \log \left(\sqrt[3]{e^{\mathsf{fma}\left(0.00024107142857142857, {x}^{6}, \mathsf{fma}\left(-0.009642857142857142, {x}^{4}, 0.225 \cdot {x}^{2}\right)\right)}}\right)} - 0.5 \]
  11. Taylor expanded in x around 0 98.6%

    \[\leadsto 3 \cdot \log \color{blue}{\left(1 + 0.075 \cdot {x}^{2}\right)} - 0.5 \]
  12. Step-by-step derivation
    1. *-commutative98.6%

      \[\leadsto 3 \cdot \log \left(1 + \color{blue}{{x}^{2} \cdot 0.075}\right) - 0.5 \]
  13. Simplified98.6%

    \[\leadsto 3 \cdot \log \color{blue}{\left(1 + {x}^{2} \cdot 0.075\right)} - 0.5 \]
  14. Final simplification98.6%

    \[\leadsto 3 \cdot \log \left(1 + {x}^{2} \cdot 0.075\right) - 0.5 \]

Alternative 4: 98.3% accurate, 2.0× speedup?

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

\\
0.225 \cdot {x}^{2} - 0.5
\end{array}
Derivation
  1. Initial program 3.2%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. /-rgt-identity3.2%

      \[\leadsto \frac{x - \sin x}{\color{blue}{\frac{x - \tan x}{1}}} \]
    2. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{\frac{x - \tan x}{\color{blue}{--1}}} \]
    3. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x} \cdot \left(--1\right)} \]
    4. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{1} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{\frac{-1}{-1}} \]
    6. times-frac3.2%

      \[\leadsto \color{blue}{\frac{\left(x - \sin x\right) \cdot -1}{\left(x - \tan x\right) \cdot -1}} \]
    7. *-commutative3.2%

      \[\leadsto \frac{\left(x - \sin x\right) \cdot -1}{\color{blue}{-1 \cdot \left(x - \tan x\right)}} \]
    8. *-commutative3.2%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    9. neg-mul-13.2%

      \[\leadsto \frac{\color{blue}{-\left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    10. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{0 - \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    11. associate-+l-3.2%

      \[\leadsto \frac{\color{blue}{\left(0 - x\right) + \sin x}}{-1 \cdot \left(x - \tan x\right)} \]
    12. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{\left(-x\right)} + \sin x}{-1 \cdot \left(x - \tan x\right)} \]
    13. +-commutative3.2%

      \[\leadsto \frac{\color{blue}{\sin x + \left(-x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    14. unsub-neg3.2%

      \[\leadsto \frac{\color{blue}{\sin x - x}}{-1 \cdot \left(x - \tan x\right)} \]
    15. neg-mul-13.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-\left(x - \tan x\right)}} \]
    16. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{0 - \left(x - \tan x\right)}} \]
    17. associate-+l-3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(0 - x\right) + \tan x}} \]
    18. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(-x\right)} + \tan x} \]
    19. +-commutative3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x + \left(-x\right)}} \]
    20. unsub-neg3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x - x}} \]
  3. Simplified3.2%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 98.5%

    \[\leadsto \color{blue}{0.225 \cdot {x}^{2} - 0.5} \]
  5. Final simplification98.5%

    \[\leadsto 0.225 \cdot {x}^{2} - 0.5 \]

Alternative 5: 97.6% accurate, 207.0× speedup?

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

\\
-0.5
\end{array}
Derivation
  1. Initial program 3.2%

    \[\frac{x - \sin x}{x - \tan x} \]
  2. Step-by-step derivation
    1. /-rgt-identity3.2%

      \[\leadsto \frac{x - \sin x}{\color{blue}{\frac{x - \tan x}{1}}} \]
    2. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{\frac{x - \tan x}{\color{blue}{--1}}} \]
    3. associate-/r/3.2%

      \[\leadsto \color{blue}{\frac{x - \sin x}{x - \tan x} \cdot \left(--1\right)} \]
    4. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{1} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{x - \sin x}{x - \tan x} \cdot \color{blue}{\frac{-1}{-1}} \]
    6. times-frac3.2%

      \[\leadsto \color{blue}{\frac{\left(x - \sin x\right) \cdot -1}{\left(x - \tan x\right) \cdot -1}} \]
    7. *-commutative3.2%

      \[\leadsto \frac{\left(x - \sin x\right) \cdot -1}{\color{blue}{-1 \cdot \left(x - \tan x\right)}} \]
    8. *-commutative3.2%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    9. neg-mul-13.2%

      \[\leadsto \frac{\color{blue}{-\left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    10. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{0 - \left(x - \sin x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    11. associate-+l-3.2%

      \[\leadsto \frac{\color{blue}{\left(0 - x\right) + \sin x}}{-1 \cdot \left(x - \tan x\right)} \]
    12. neg-sub03.2%

      \[\leadsto \frac{\color{blue}{\left(-x\right)} + \sin x}{-1 \cdot \left(x - \tan x\right)} \]
    13. +-commutative3.2%

      \[\leadsto \frac{\color{blue}{\sin x + \left(-x\right)}}{-1 \cdot \left(x - \tan x\right)} \]
    14. unsub-neg3.2%

      \[\leadsto \frac{\color{blue}{\sin x - x}}{-1 \cdot \left(x - \tan x\right)} \]
    15. neg-mul-13.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{-\left(x - \tan x\right)}} \]
    16. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{0 - \left(x - \tan x\right)}} \]
    17. associate-+l-3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(0 - x\right) + \tan x}} \]
    18. neg-sub03.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\left(-x\right)} + \tan x} \]
    19. +-commutative3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x + \left(-x\right)}} \]
    20. unsub-neg3.2%

      \[\leadsto \frac{\sin x - x}{\color{blue}{\tan x - x}} \]
  3. Simplified3.2%

    \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
  4. Taylor expanded in x around 0 97.7%

    \[\leadsto \color{blue}{-0.5} \]
  5. Final simplification97.7%

    \[\leadsto -0.5 \]

Developer target: 99.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left|x\right| \leq 1:\\ \;\;\;\;\left(\left(-0.5 + \frac{9 \cdot {x}^{2}}{40}\right) + \frac{-27 \cdot {x}^{4}}{2800}\right) + \frac{27 \cdot {x}^{6}}{112000}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (fabs x) 1.0)
   (+
    (+ (+ -0.5 (/ (* 9.0 (pow x 2.0)) 40.0)) (/ (* -27.0 (pow x 4.0)) 2800.0))
    (/ (* 27.0 (pow x 6.0)) 112000.0))
   (/ (- x (sin x)) (- x (tan x)))))
double code(double x) {
	double tmp;
	if (fabs(x) <= 1.0) {
		tmp = ((-0.5 + ((9.0 * pow(x, 2.0)) / 40.0)) + ((-27.0 * pow(x, 4.0)) / 2800.0)) + ((27.0 * pow(x, 6.0)) / 112000.0);
	} else {
		tmp = (x - sin(x)) / (x - tan(x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (abs(x) <= 1.0d0) then
        tmp = (((-0.5d0) + ((9.0d0 * (x ** 2.0d0)) / 40.0d0)) + (((-27.0d0) * (x ** 4.0d0)) / 2800.0d0)) + ((27.0d0 * (x ** 6.0d0)) / 112000.0d0)
    else
        tmp = (x - sin(x)) / (x - tan(x))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (Math.abs(x) <= 1.0) {
		tmp = ((-0.5 + ((9.0 * Math.pow(x, 2.0)) / 40.0)) + ((-27.0 * Math.pow(x, 4.0)) / 2800.0)) + ((27.0 * Math.pow(x, 6.0)) / 112000.0);
	} else {
		tmp = (x - Math.sin(x)) / (x - Math.tan(x));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if math.fabs(x) <= 1.0:
		tmp = ((-0.5 + ((9.0 * math.pow(x, 2.0)) / 40.0)) + ((-27.0 * math.pow(x, 4.0)) / 2800.0)) + ((27.0 * math.pow(x, 6.0)) / 112000.0)
	else:
		tmp = (x - math.sin(x)) / (x - math.tan(x))
	return tmp
function code(x)
	tmp = 0.0
	if (abs(x) <= 1.0)
		tmp = Float64(Float64(Float64(-0.5 + Float64(Float64(9.0 * (x ^ 2.0)) / 40.0)) + Float64(Float64(-27.0 * (x ^ 4.0)) / 2800.0)) + Float64(Float64(27.0 * (x ^ 6.0)) / 112000.0));
	else
		tmp = Float64(Float64(x - sin(x)) / Float64(x - tan(x)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (abs(x) <= 1.0)
		tmp = ((-0.5 + ((9.0 * (x ^ 2.0)) / 40.0)) + ((-27.0 * (x ^ 4.0)) / 2800.0)) + ((27.0 * (x ^ 6.0)) / 112000.0);
	else
		tmp = (x - sin(x)) / (x - tan(x));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.0], N[(N[(N[(-0.5 + N[(N[(9.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] / 40.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-27.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] / 2800.0), $MachinePrecision]), $MachinePrecision] + N[(N[(27.0 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] / 112000.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1:\\
\;\;\;\;\left(\left(-0.5 + \frac{9 \cdot {x}^{2}}{40}\right) + \frac{-27 \cdot {x}^{4}}{2800}\right) + \frac{27 \cdot {x}^{6}}{112000}\\

\mathbf{else}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023333 
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  :pre (and (<= -100000.0 x) (<= x 100000.0))

  :herbie-target
  (if (<= (fabs x) 1.0) (+ (+ (+ -0.5 (/ (* 9.0 (pow x 2.0)) 40.0)) (/ (* -27.0 (pow x 4.0)) 2800.0)) (/ (* 27.0 (pow x 6.0)) 112000.0)) (/ (- x (sin x)) (- x (tan x))))

  (/ (- x (sin x)) (- x (tan x))))