Average Error: 31.7 → 0.7
Time: 18.4s
Precision: binary64
Cost: 65160
\[\frac{x - \sin x}{x - \tan x} \]
\[\begin{array}{l} t_0 := x + \tan x\\ t_1 := \tan x - x\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\log \left(e^{\sqrt[3]{{\sin x}^{4}}}\right)} \cdot \frac{\sqrt[3]{\sin x}}{t_0} - \frac{x}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_1} - \frac{x}{t_1}\\ \end{array} \]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (- x (tan x))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ x (tan x))) (t_1 (- (tan x) x)))
   (if (<= x -1.35e-8)
     (/ (- x (sin x)) (- x (tan x)))
     (if (<= x 2.1e-8)
       (-
        (* (sqrt (log (exp (cbrt (pow (sin x) 4.0))))) (/ (cbrt (sin x)) t_0))
        (/ x t_0))
       (- (/ (sin x) t_1) (/ x t_1))))))
double code(double x) {
	return (x - sin(x)) / (x - tan(x));
}
double code(double x) {
	double t_0 = x + tan(x);
	double t_1 = tan(x) - x;
	double tmp;
	if (x <= -1.35e-8) {
		tmp = (x - sin(x)) / (x - tan(x));
	} else if (x <= 2.1e-8) {
		tmp = (sqrt(log(exp(cbrt(pow(sin(x), 4.0))))) * (cbrt(sin(x)) / t_0)) - (x / t_0);
	} else {
		tmp = (sin(x) / t_1) - (x / t_1);
	}
	return tmp;
}
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.tan(x);
	double t_1 = Math.tan(x) - x;
	double tmp;
	if (x <= -1.35e-8) {
		tmp = (x - Math.sin(x)) / (x - Math.tan(x));
	} else if (x <= 2.1e-8) {
		tmp = (Math.sqrt(Math.log(Math.exp(Math.cbrt(Math.pow(Math.sin(x), 4.0))))) * (Math.cbrt(Math.sin(x)) / t_0)) - (x / t_0);
	} else {
		tmp = (Math.sin(x) / t_1) - (x / t_1);
	}
	return tmp;
}
function code(x)
	return Float64(Float64(x - sin(x)) / Float64(x - tan(x)))
end
function code(x)
	t_0 = Float64(x + tan(x))
	t_1 = Float64(tan(x) - x)
	tmp = 0.0
	if (x <= -1.35e-8)
		tmp = Float64(Float64(x - sin(x)) / Float64(x - tan(x)));
	elseif (x <= 2.1e-8)
		tmp = Float64(Float64(sqrt(log(exp(cbrt((sin(x) ^ 4.0))))) * Float64(cbrt(sin(x)) / t_0)) - Float64(x / t_0));
	else
		tmp = Float64(Float64(sin(x) / t_1) - Float64(x / t_1));
	end
	return 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[(x + N[Tan[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Tan[x], $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[x, -1.35e-8], N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[(x - N[Tan[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1e-8], N[(N[(N[Sqrt[N[Log[N[Exp[N[Power[N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Power[N[Sin[x], $MachinePrecision], 1/3], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] - N[(x / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[x], $MachinePrecision] / t$95$1), $MachinePrecision] - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x - \sin x}{x - \tan x}
\begin{array}{l}
t_0 := x + \tan x\\
t_1 := \tan x - x\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{-8}:\\
\;\;\;\;\frac{x - \sin x}{x - \tan x}\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\log \left(e^{\sqrt[3]{{\sin x}^{4}}}\right)} \cdot \frac{\sqrt[3]{\sin x}}{t_0} - \frac{x}{t_0}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -1.35000000000000001e-8

    1. Initial program 0.5

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

    if -1.35000000000000001e-8 < x < 2.09999999999999994e-8

    1. Initial program 64.0

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Simplified64.0

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
      Proof
      (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (-.f64 (sin.f64 x) x)) (*.f64 -1 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (sin.f64 x) x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (sin.f64 x) x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (sin.f64 x)) x)) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (sin.f64 x))) x) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 (sin.f64 x)))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 x (sin.f64 x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (tan.f64 x)) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (tan.f64 x))) x)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 (tan.f64 x))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= sub-neg_binary64 (-.f64 x (tan.f64 x)))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr63.0

      \[\leadsto \frac{\sin x - x}{\color{blue}{\mathsf{fma}\left(\sqrt{-x}, \sqrt{-x}, \tan x\right)}} \]
    4. Applied egg-rr29.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\sqrt[3]{{\sin x}^{2}}}{1}, \frac{\sqrt[3]{\sin x}}{x + \tan x}, -\frac{x}{x + \tan x}\right)} \]
    5. Simplified30.0

      \[\leadsto \color{blue}{\sqrt[3]{{\sin x}^{2}} \cdot \frac{\sqrt[3]{\sin x}}{x + \tan x} - \frac{x}{x + \tan x}} \]
      Proof
      (-.f64 (*.f64 (cbrt.f64 (pow.f64 (sin.f64 x) 2)) (/.f64 (cbrt.f64 (sin.f64 x)) (+.f64 x (tan.f64 x)))) (/.f64 x (+.f64 x (tan.f64 x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> fma-neg_binary64 (fma.f64 (cbrt.f64 (pow.f64 (sin.f64 x) 2)) (/.f64 (cbrt.f64 (sin.f64 x)) (+.f64 x (tan.f64 x))) (neg.f64 (/.f64 x (+.f64 x (tan.f64 x)))))): 31 points increase in error, 27 points decrease in error
      (fma.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 (cbrt.f64 (pow.f64 (sin.f64 x) 2)) 1)) (/.f64 (cbrt.f64 (sin.f64 x)) (+.f64 x (tan.f64 x))) (neg.f64 (/.f64 x (+.f64 x (tan.f64 x))))): 0 points increase in error, 0 points decrease in error
    6. Applied egg-rr14.4

      \[\leadsto \color{blue}{\sqrt{\sqrt[3]{{\sin x}^{4}}}} \cdot \frac{\sqrt[3]{\sin x}}{x + \tan x} - \frac{x}{x + \tan x} \]
    7. Applied egg-rr1.0

      \[\leadsto \sqrt{\color{blue}{\log \left(e^{\sqrt[3]{{\sin x}^{4}}}\right)}} \cdot \frac{\sqrt[3]{\sin x}}{x + \tan x} - \frac{x}{x + \tan x} \]

    if 2.09999999999999994e-8 < x

    1. Initial program 0.5

      \[\frac{x - \sin x}{x - \tan x} \]
    2. Simplified0.5

      \[\leadsto \color{blue}{\frac{\sin x - x}{\tan x - x}} \]
      Proof
      (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (-.f64 (sin.f64 x) x) (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (-.f64 (sin.f64 x) x)) (*.f64 -1 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (sin.f64 x) x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (sin.f64 x) x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (sin.f64 x)) x)) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (sin.f64 x))) x) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 (sin.f64 x)))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 x (sin.f64 x))) (*.f64 -1 (-.f64 (tan.f64 x) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 (tan.f64 x) x)))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 (tan.f64 x)) x))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 (tan.f64 x))) x)): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= +-commutative_binary64 (+.f64 x (neg.f64 (tan.f64 x))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 x (sin.f64 x)) (Rewrite<= sub-neg_binary64 (-.f64 x (tan.f64 x)))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr0.4

      \[\leadsto \color{blue}{\frac{\sin x}{\tan x - x} - \frac{x}{\tan x - x}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\ \;\;\;\;\sqrt{\log \left(e^{\sqrt[3]{{\sin x}^{4}}}\right)} \cdot \frac{\sqrt[3]{\sin x}}{x + \tan x} - \frac{x}{x + \tan x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{\tan x - x} - \frac{x}{\tan x - x}\\ \end{array} \]

Alternatives

Alternative 1
Error1.9
Cost58760
\[\begin{array}{l} t_0 := \sqrt[3]{\sin x}\\ t_1 := x + \tan x\\ t_2 := \tan x - x\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-8}:\\ \;\;\;\;\frac{t_0}{t_1} \cdot \log \left(e^{{t_0}^{2}}\right) - \frac{x}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_2} - \frac{x}{t_2}\\ \end{array} \]
Alternative 2
Error7.3
Cost52360
\[\begin{array}{l} t_0 := x + \tan x\\ t_1 := \tan x - x\\ \mathbf{if}\;x \leq -5 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sqrt[3]{\sin x}}{t_0} \cdot \sqrt{\sqrt[3]{{\sin x}^{4}}} - \frac{x}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_1} - \frac{x}{t_1}\\ \end{array} \]
Alternative 3
Error7.7
Cost46024
\[\begin{array}{l} t_0 := x + \tan x\\ t_1 := \tan x - x\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-8}:\\ \;\;\;\;\frac{\sqrt[3]{\sin x}}{t_0} \cdot {\left({\sin x}^{4}\right)}^{0.16666666666666666} - \frac{x}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_1} - \frac{x}{t_1}\\ \end{array} \]
Alternative 4
Error13.2
Cost39432
\[\begin{array}{l} t_0 := \tan x - x\\ \mathbf{if}\;x \leq -2 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\left(x + \sqrt[3]{\sin x} \cdot \sqrt[3]{{\sin x}^{2}}\right) \cdot \frac{-1}{x + \tan x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_0} - \frac{x}{t_0}\\ \end{array} \]
Alternative 5
Error15.0
Cost26696
\[\begin{array}{l} t_0 := \tan x - x\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{x + \tan x} \cdot \left(\sqrt[3]{x \cdot x} \cdot \sqrt[3]{x} - \sin x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_0} - \frac{x}{t_0}\\ \end{array} \]
Alternative 6
Error25.8
Cost26628
\[\begin{array}{l} t_0 := \frac{x - \sin x}{x - \tan x}\\ \mathbf{if}\;t_0 \leq 2:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-\sin x\right) - x}{x + \tan x}\\ \end{array} \]
Alternative 7
Error25.8
Cost20168
\[\begin{array}{l} t_0 := \tan x - x\\ \mathbf{if}\;x \leq -2 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\left(-\sin x\right) - x}{x + \tan x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin x}{t_0} - \frac{x}{t_0}\\ \end{array} \]
Alternative 8
Error31.7
Cost13248
\[\frac{x - \sin x}{x - \tan x} \]

Error

Reproduce

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