Average Error: 0.2 → 0.2
Time: 13.3s
Precision: binary64
Cost: 13248
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\frac{1 - x \cdot \cos B}{\sin B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x) :precision binary64 (/ (- 1.0 (* x (cos B))) (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 - (x * cos(B))) / 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 - (x * cos(b))) / 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 - (x * Math.cos(B))) / 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 - (x * math.cos(B))) / 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(x * cos(B))) / 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 - (x * cos(B))) / 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[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\frac{1 - x \cdot \cos B}{\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))))): 35 points increase in error, 9 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. Applied egg-rr0.2

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

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

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

Alternatives

Alternative 1
Error1.0
Cost13252
\[\begin{array}{l} \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;\frac{\tan B - x}{\tan B}\\ \mathbf{elif}\;x \leq 622.0381124410854:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{B} + -1\right) - \frac{x}{\tan B}\\ \end{array} \]
Alternative 2
Error0.2
Cost13248
\[\frac{1}{\sin B} - \frac{x}{\tan B} \]
Alternative 3
Error1.0
Cost7240
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;1 - t_0\\ \mathbf{elif}\;x \leq 622.0381124410854:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{B} + -1\right) - t_0\\ \end{array} \]
Alternative 4
Error1.0
Cost7112
\[\begin{array}{l} t_0 := \frac{x}{\tan B}\\ \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;1 - t_0\\ \mathbf{elif}\;x \leq 622.0381124410854:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - t_0\\ \end{array} \]
Alternative 5
Error1.1
Cost6984
\[\begin{array}{l} \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;1 - \frac{x}{\tan B}\\ \mathbf{elif}\;x \leq 622.0381124410854:\\ \;\;\;\;\frac{1 - x}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \end{array} \]
Alternative 6
Error1.9
Cost6920
\[\begin{array}{l} t_0 := \frac{-x}{\tan B}\\ \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.9811528645762814:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error1.9
Cost6920
\[\begin{array}{l} \mathbf{if}\;x \leq -648305768939.0497:\\ \;\;\;\;1 - \frac{x}{\tan B}\\ \mathbf{elif}\;x \leq 0.9811528645762814:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \end{array} \]
Alternative 8
Error19.4
Cost6856
\[\begin{array}{l} t_0 := \frac{1}{\sin B}\\ \mathbf{if}\;B \leq -7.99763360581275:\\ \;\;\;\;t_0\\ \mathbf{elif}\;B \leq 1.906517941247706 \cdot 10^{-27}:\\ \;\;\;\;\frac{1 - x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error33.9
Cost1224
\[\begin{array}{l} \mathbf{if}\;B \leq -6484.3315407407235:\\ \;\;\;\;1\\ \mathbf{elif}\;B \leq 7.171363942527516 \cdot 10^{+58}:\\ \;\;\;\;\left(\frac{1}{B} + B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error34.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;B \leq -6484.3315407407235:\\ \;\;\;\;1\\ \mathbf{elif}\;B \leq 7.696352384136389 \cdot 10^{+96}:\\ \;\;\;\;\left(\frac{1}{B} + B \cdot \left(x \cdot 0.3333333333333333\right)\right) - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error36.6
Cost520
\[\begin{array}{l} t_0 := \frac{-x}{B}\\ \mathbf{if}\;x \leq -8.813665526574962 \cdot 10^{+20}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.9811528645762814:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error43.9
Cost324
\[\begin{array}{l} \mathbf{if}\;B \leq -6484.3315407407235:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]
Alternative 13
Error35.5
Cost320
\[\frac{1 - x}{B} \]
Alternative 14
Error60.4
Cost64
\[1 \]

Error

Reproduce

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