\[0.001 \leq x \land x \leq 1.5\]
\[\tan x - x
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\tan x - x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.05396825396825397, {x}^{7}, \mathsf{fma}\left(0.13333333333333333, {x}^{5}, 0.021869488536155203 \cdot {x}^{9}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot \left(-x\right), x, {x}^{3}\right) + \left({\tan x}^{3} - {x}^{3}\right)}{\mathsf{fma}\left(x, x, \tan x \cdot \left(x + \tan x\right)\right)}\\
\end{array}
\]
(FPCore (x) :precision binary64 (- (tan x) x))
↓
(FPCore (x)
:precision binary64
(if (<= (- (tan x) x) 2e-5)
(fma
0.3333333333333333
(pow x 3.0)
(fma
0.05396825396825397
(pow x 7.0)
(fma
0.13333333333333333
(pow x 5.0)
(* 0.021869488536155203 (pow x 9.0)))))
(/
(+ (fma (* x (- x)) x (pow x 3.0)) (- (pow (tan x) 3.0) (pow x 3.0)))
(fma x x (* (tan x) (+ x (tan x)))))))
double code(double x) {
return tan(x) - x;
}
↓
double code(double x) {
double tmp;
if ((tan(x) - x) <= 2e-5) {
tmp = fma(0.3333333333333333, pow(x, 3.0), fma(0.05396825396825397, pow(x, 7.0), fma(0.13333333333333333, pow(x, 5.0), (0.021869488536155203 * pow(x, 9.0)))));
} else {
tmp = (fma((x * -x), x, pow(x, 3.0)) + (pow(tan(x), 3.0) - pow(x, 3.0))) / fma(x, x, (tan(x) * (x + tan(x))));
}
return tmp;
}
function code(x)
return Float64(tan(x) - x)
end
↓
function code(x)
tmp = 0.0
if (Float64(tan(x) - x) <= 2e-5)
tmp = fma(0.3333333333333333, (x ^ 3.0), fma(0.05396825396825397, (x ^ 7.0), fma(0.13333333333333333, (x ^ 5.0), Float64(0.021869488536155203 * (x ^ 9.0)))));
else
tmp = Float64(Float64(fma(Float64(x * Float64(-x)), x, (x ^ 3.0)) + Float64((tan(x) ^ 3.0) - (x ^ 3.0))) / fma(x, x, Float64(tan(x) * Float64(x + tan(x)))));
end
return tmp
end
code[x_] := N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]
↓
code[x_] := If[LessEqual[N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision], 2e-5], N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision] + N[(0.05396825396825397 * N[Power[x, 7.0], $MachinePrecision] + N[(0.13333333333333333 * N[Power[x, 5.0], $MachinePrecision] + N[(0.021869488536155203 * N[Power[x, 9.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(x * (-x)), $MachinePrecision] * x + N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Tan[x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * x + N[(N[Tan[x], $MachinePrecision] * N[(x + N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\tan x - x
↓
\begin{array}{l}
\mathbf{if}\;\tan x - x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.05396825396825397, {x}^{7}, \mathsf{fma}\left(0.13333333333333333, {x}^{5}, 0.021869488536155203 \cdot {x}^{9}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot \left(-x\right), x, {x}^{3}\right) + \left({\tan x}^{3} - {x}^{3}\right)}{\mathsf{fma}\left(x, x, \tan x \cdot \left(x + \tan x\right)\right)}\\
\end{array}
Alternatives
Alternative 1 |
---|
Error | 2.7 |
---|
Cost | 52292 |
---|
\[\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(0.05396825396825397, {x}^{7}, \mathsf{fma}\left(0.13333333333333333, {x}^{5}, \mathsf{fma}\left(0.021869488536155203, {x}^{9}, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\]
Alternative 2 |
---|
Error | 2.7 |
---|
Cost | 52292 |
---|
\[\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(0.05396825396825397, {x}^{7}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.13333333333333333, {x}^{5}, 0.021869488536155203 \cdot {x}^{9}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\]
Alternative 3 |
---|
Error | 2.6 |
---|
Cost | 52292 |
---|
\[\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.05396825396825397, {x}^{7}, \mathsf{fma}\left(0.13333333333333333, {x}^{5}, 0.021869488536155203 \cdot {x}^{9}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\]
Alternative 4 |
---|
Error | 2.7 |
---|
Cost | 33476 |
---|
\[\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;0.05396825396825397 \cdot {x}^{7} + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.021869488536155203 \cdot {x}^{9} + 0.13333333333333333 \cdot {x}^{5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\]
Alternative 5 |
---|
Error | 4.4 |
---|
Cost | 26756 |
---|
\[\begin{array}{l}
t_0 := \tan x - x\\
\mathbf{if}\;t_0 \leq 8.5 \cdot 10^{-7}:\\
\;\;\;\;0.05396825396825397 \cdot {x}^{7} + \left(0.3333333333333333 \cdot {x}^{3} + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log t_0}\\
\end{array}
\]
Alternative 6 |
---|
Error | 8.7 |
---|
Cost | 19392 |
---|
\[e^{\log \left(\tan x - x\right)}
\]
Alternative 7 |
---|
Error | 8.7 |
---|
Cost | 13184 |
---|
\[{\left(\frac{1}{\tan x - x}\right)}^{-1}
\]
Alternative 8 |
---|
Error | 8.7 |
---|
Cost | 6592 |
---|
\[\tan x - x
\]
Alternative 9 |
---|
Error | 63.0 |
---|
Cost | 128 |
---|
\[-x
\]