Math FPCore C Fortran Java Python Julia MATLAB Wolfram TeX \[\frac{x - \sin x}{x - \tan x}
\]
↓
\[\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.5\\
\end{array}
\]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x)))) ↓
(FPCore (x)
:precision binary64
(let* ((t_0 (/ (- x (sin x)) (- x (tan x))))) (if (<= t_0 2.0) t_0 -0.5))) double code(double x) {
return (x - sin(x)) / (x - tan(x));
}
↓
double code(double x) {
double t_0 = (x - sin(x)) / (x - tan(x));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = -0.5;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x - sin(x)) / (x - tan(x))
end function
↓
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (x - sin(x)) / (x - tan(x))
if (t_0 <= 2.0d0) then
tmp = t_0
else
tmp = -0.5d0
end if
code = tmp
end function
public static double code(double x) {
return (x - Math.sin(x)) / (x - Math.tan(x));
}
↓
public static double code(double x) {
double t_0 = (x - Math.sin(x)) / (x - Math.tan(x));
double tmp;
if (t_0 <= 2.0) {
tmp = t_0;
} else {
tmp = -0.5;
}
return tmp;
}
def code(x):
return (x - math.sin(x)) / (x - math.tan(x))
↓
def code(x):
t_0 = (x - math.sin(x)) / (x - math.tan(x))
tmp = 0
if t_0 <= 2.0:
tmp = t_0
else:
tmp = -0.5
return tmp
function code(x)
return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
↓
function code(x)
t_0 = Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
tmp = 0.0
if (t_0 <= 2.0)
tmp = t_0;
else
tmp = -0.5;
end
return tmp
end
function tmp = code(x)
tmp = (x - sin(x)) / (x - tan(x));
end
↓
function tmp_2 = code(x)
t_0 = (x - sin(x)) / (x - tan(x));
tmp = 0.0;
if (t_0 <= 2.0)
tmp = t_0;
else
tmp = -0.5;
end
tmp_2 = tmp;
end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[x_] := Block[{t$95$0 = N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2.0], t$95$0, -0.5]]
\frac{x - \sin x}{x - \tan x}
↓
\begin{array}{l}
t_0 := \frac{x - \sin x}{x - \tan x}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-0.5\\
\end{array}
Alternatives Alternative 1 Accuracy 98.8% Cost 7624
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.8:\\
\;\;\;\;1 - \frac{\sin x}{x}\\
\mathbf{elif}\;x \leq 2.95:\\
\;\;\;\;-0.5 + \left(\left(1 + \left(x \cdot x\right) \cdot \mathsf{fma}\left(x, x \cdot -0.009642857142857142, 0.225\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 2 Accuracy 98.8% Cost 6852
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.8:\\
\;\;\;\;1 - \frac{\sin x}{x}\\
\mathbf{elif}\;x \leq 2.95:\\
\;\;\;\;-0.5 + \left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 3 Accuracy 98.8% Cost 1096
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.9:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.95:\\
\;\;\;\;-0.5 + \left(x \cdot x\right) \cdot \left(0.225 + x \cdot \left(x \cdot -0.009642857142857142\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 4 Accuracy 98.7% Cost 712
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.6:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 2.6:\\
\;\;\;\;-0.5 + \left(x \cdot x\right) \cdot 0.225\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 5 Accuracy 98.3% Cost 328
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.58:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.55:\\
\;\;\;\;-0.5\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
Alternative 6 Accuracy 51.0% Cost 64
\[-0.5
\]