?

Average Error: 31.4 → 0.2
Time: 28.7s
Precision: binary64
Cost: 26564

?

\[\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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x))) < 2

    1. Initial program 0.5

      \[\frac{x - \sin x}{x - \tan x} \]

    if 2 < (/.f64 (-.f64 x (sin.f64 x)) (-.f64 x (tan.f64 x)))

    1. Initial program 64.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Taylor expanded in x around 0 0.0

      \[\leadsto \color{blue}{-0.5} \]
  3. Recombined 2 regimes into one program.

Alternatives

Alternative 1
Error1.0
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.55:\\ \;\;\;\;-0.5\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error31.9
Cost64
\[-0.5 \]

Error

Reproduce?

herbie shell --seed 2023033 
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  :precision binary64
  (/ (- x (sin x)) (- x (tan x))))