\[\frac{1 - \cos x}{x \cdot x}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;{x}^{-2} \cdot \left(1 - \cos x\right)\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x \cdot x}\\
\end{array}
\]
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
↓
(FPCore (x)
:precision binary64
(if (<= x -0.033)
(* (pow x -2.0) (- 1.0 (cos x)))
(if (<= x 2e-5)
(+
0.5
(* (* x x) (+ (* (* x x) 0.001388888888888889) -0.041666666666666664)))
(* (tan (* x 0.5)) (/ (sin x) (* x x))))))double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
↓
double code(double x) {
double tmp;
if (x <= -0.033) {
tmp = pow(x, -2.0) * (1.0 - cos(x));
} else if (x <= 2e-5) {
tmp = 0.5 + ((x * x) * (((x * x) * 0.001388888888888889) + -0.041666666666666664));
} else {
tmp = tan((x * 0.5)) * (sin(x) / (x * x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / (x * x)
end function
↓
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-0.033d0)) then
tmp = (x ** (-2.0d0)) * (1.0d0 - cos(x))
else if (x <= 2d-5) then
tmp = 0.5d0 + ((x * x) * (((x * x) * 0.001388888888888889d0) + (-0.041666666666666664d0)))
else
tmp = tan((x * 0.5d0)) * (sin(x) / (x * x))
end if
code = tmp
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / (x * x);
}
↓
public static double code(double x) {
double tmp;
if (x <= -0.033) {
tmp = Math.pow(x, -2.0) * (1.0 - Math.cos(x));
} else if (x <= 2e-5) {
tmp = 0.5 + ((x * x) * (((x * x) * 0.001388888888888889) + -0.041666666666666664));
} else {
tmp = Math.tan((x * 0.5)) * (Math.sin(x) / (x * x));
}
return tmp;
}
def code(x):
return (1.0 - math.cos(x)) / (x * x)
↓
def code(x):
tmp = 0
if x <= -0.033:
tmp = math.pow(x, -2.0) * (1.0 - math.cos(x))
elif x <= 2e-5:
tmp = 0.5 + ((x * x) * (((x * x) * 0.001388888888888889) + -0.041666666666666664))
else:
tmp = math.tan((x * 0.5)) * (math.sin(x) / (x * x))
return tmp
function code(x)
return Float64(Float64(1.0 - cos(x)) / Float64(x * x))
end
↓
function code(x)
tmp = 0.0
if (x <= -0.033)
tmp = Float64((x ^ -2.0) * Float64(1.0 - cos(x)));
elseif (x <= 2e-5)
tmp = Float64(0.5 + Float64(Float64(x * x) * Float64(Float64(Float64(x * x) * 0.001388888888888889) + -0.041666666666666664)));
else
tmp = Float64(tan(Float64(x * 0.5)) * Float64(sin(x) / Float64(x * x)));
end
return tmp
end
function tmp = code(x)
tmp = (1.0 - cos(x)) / (x * x);
end
↓
function tmp_2 = code(x)
tmp = 0.0;
if (x <= -0.033)
tmp = (x ^ -2.0) * (1.0 - cos(x));
elseif (x <= 2e-5)
tmp = 0.5 + ((x * x) * (((x * x) * 0.001388888888888889) + -0.041666666666666664));
else
tmp = tan((x * 0.5)) * (sin(x) / (x * x));
end
tmp_2 = tmp;
end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
↓
code[x_] := If[LessEqual[x, -0.033], N[(N[Power[x, -2.0], $MachinePrecision] * N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-5], N[(0.5 + N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * 0.001388888888888889), $MachinePrecision] + -0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tan[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{1 - \cos x}{x \cdot x}
↓
\begin{array}{l}
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;{x}^{-2} \cdot \left(1 - \cos x\right)\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-5}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\tan \left(x \cdot 0.5\right) \cdot \frac{\sin x}{x \cdot x}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.4 |
|---|
| Cost | 13576 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;{x}^{-2} \cdot \left(1 - \cos x\right)\\
\mathbf{elif}\;x \leq 0.0285:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-2} - \frac{\cos x}{x \cdot x}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.4 |
|---|
| Cost | 13376 |
|---|
\[\frac{\tan \left(x \cdot 0.5\right)}{x \cdot \frac{x}{\sin x}}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 13316 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;{x}^{-2} \cdot \left(1 - \cos x\right)\\
\mathbf{elif}\;x \leq 0.0285:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot x} + \cos x \cdot \frac{-1}{x \cdot x}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.4 |
|---|
| Cost | 7496 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;\left(\cos x + -1\right) \cdot \frac{\frac{-1}{x}}{x}\\
\mathbf{elif}\;x \leq 0.0285:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot x} + \cos x \cdot \frac{-1}{x \cdot x}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.3 |
|---|
| Cost | 7241 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033 \lor \neg \left(x \leq 0.035\right):\\
\;\;\;\;\left(\cos x + -1\right) \cdot \frac{\frac{-1}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.5 |
|---|
| Cost | 7113 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.033 \lor \neg \left(x \leq 0.035\right):\\
\;\;\;\;\frac{1 - \cos x}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.4 |
|---|
| Cost | 7112 |
|---|
\[\begin{array}{l}
t_0 := 1 - \cos x\\
\mathbf{if}\;x \leq -0.033:\\
\;\;\;\;\frac{\frac{t_0}{x}}{x}\\
\mathbf{elif}\;x \leq 0.035:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot x}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 15.1 |
|---|
| Cost | 1097 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{+38} \lor \neg \left(x \leq 6.7 \cdot 10^{+38}\right):\\
\;\;\;\;\frac{0}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 0.001388888888888889 + -0.041666666666666664\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 13.7 |
|---|
| Cost | 896 |
|---|
\[\frac{\frac{-1}{x \cdot 0.16666666666666666 + 2 \cdot \frac{1}{x}}}{-x}
\]
| Alternative 10 |
|---|
| Error | 15.3 |
|---|
| Cost | 713 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \lor \neg \left(x \leq 3.5\right):\\
\;\;\;\;\frac{0}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 + \left(x \cdot x\right) \cdot -0.041666666666666664\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 30.8 |
|---|
| Cost | 64 |
|---|
\[0.5
\]