Average Error: 0.2 → 0.2
Time: 10.2s
Precision: binary64
Cost: 13248
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\frac{1 - \cos B \cdot x}{\sin B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x) :precision binary64 (/ (- 1.0 (* (cos B) x)) (sin B)))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
double code(double B, double x) {
	return (1.0 - (cos(B) * x)) / sin(B);
}
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = -(x * (1.0d0 / tan(b))) + (1.0d0 / sin(b))
end function
real(8) function code(b, x)
    real(8), intent (in) :: b
    real(8), intent (in) :: x
    code = (1.0d0 - (cos(b) * x)) / sin(b)
end function
public static double code(double B, double x) {
	return -(x * (1.0 / Math.tan(B))) + (1.0 / Math.sin(B));
}
public static double code(double B, double x) {
	return (1.0 - (Math.cos(B) * x)) / Math.sin(B);
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
def code(B, x):
	return (1.0 - (math.cos(B) * x)) / math.sin(B)
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function code(B, x)
	return Float64(Float64(1.0 - Float64(cos(B) * x)) / sin(B))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
function tmp = code(B, x)
	tmp = (1.0 - (cos(B) * x)) / sin(B);
end
code[B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[B_, x_] := N[(N[(1.0 - N[(N[Cos[B], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\frac{1 - \cos B \cdot x}{\sin B}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.2

    \[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
  2. Simplified0.2

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    Proof
    (-.f64 (/.f64 1 (sin.f64 B)) (/.f64 x (tan.f64 B))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 1 (sin.f64 B)) (/.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 x 1)) (tan.f64 B))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 1 (sin.f64 B)) (Rewrite<= associate-*r/_binary64 (*.f64 x (/.f64 1 (tan.f64 B))))): 28 points increase in error, 5 points decrease in error
    (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 1 (sin.f64 B)) (neg.f64 (*.f64 x (/.f64 1 (tan.f64 B)))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (*.f64 x (/.f64 1 (tan.f64 B)))) (/.f64 1 (sin.f64 B)))): 0 points increase in error, 0 points decrease in error
  3. Taylor expanded in x around 0 0.2

    \[\leadsto \frac{1}{\sin B} - \color{blue}{\frac{\cos B \cdot x}{\sin B}} \]
  4. Applied egg-rr0.2

    \[\leadsto \color{blue}{\frac{1 - \cos B \cdot x}{\sin B}} \]
  5. Final simplification0.2

    \[\leadsto \frac{1 - \cos B \cdot x}{\sin B} \]

Alternatives

Alternative 1
Error1.3
Cost13448
\[\begin{array}{l} t_0 := x \cdot \frac{-\cos B}{\sin B}\\ \mathbf{if}\;x \leq -8579896924646503:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 104580880.11854258:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.2
Cost13448
\[\begin{array}{l} t_0 := \cos B \cdot \frac{-x}{\sin B}\\ \mathbf{if}\;x \leq -8579896924646503:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 104580880.11854258:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error9.5
Cost7368
\[\begin{array}{l} t_0 := \left(B \cdot 0.16666666666666666 + \frac{1}{B}\right) - \frac{x}{\tan B}\\ \mathbf{if}\;x \leq -2.8955616087334302 \cdot 10^{+38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.531076106404538 \cdot 10^{+53}:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error18.3
Cost6856
\[\begin{array}{l} t_0 := B \cdot 0.16666666666666666 + \frac{1 - x}{B}\\ \mathbf{if}\;x \leq -5.066143356299908 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8757986119390207 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error16.5
Cost6720
\[\frac{1 - x}{\sin B} \]
Alternative 6
Error35.5
Cost576
\[B \cdot 0.16666666666666666 + \frac{1 - x}{B} \]
Alternative 7
Error36.3
Cost520
\[\begin{array}{l} t_0 := \frac{-x}{B}\\ \mathbf{if}\;x \leq -20544.879071261556:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.02609633979704309:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error35.6
Cost320
\[\frac{1 - x}{B} \]
Alternative 9
Error44.6
Cost192
\[\frac{1}{B} \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (B x)
  :name "VandenBroeck and Keller, Equation (24)"
  :precision binary64
  (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))