Average Error: 0.2 → 0.2
Time: 10.4s
Precision: binary64
Cost: 19648
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\frac{\frac{\tan B}{\sin B} - x}{\tan B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x) :precision binary64 (/ (- (/ (tan B) (sin B)) x) (tan B)))
double code(double B, double x) {
	return -(x * (1.0 / tan(B))) + (1.0 / sin(B));
}
double code(double B, double x) {
	return ((tan(B) / sin(B)) - x) / tan(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 = ((tan(b) / sin(b)) - x) / tan(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 ((Math.tan(B) / Math.sin(B)) - x) / Math.tan(B);
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
def code(B, x):
	return ((math.tan(B) / math.sin(B)) - x) / math.tan(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(Float64(tan(B) / sin(B)) - x) / tan(B))
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
function tmp = code(B, x)
	tmp = ((tan(B) / sin(B)) - x) / tan(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[(N[(N[Tan[B], $MachinePrecision] / N[Sin[B], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[Tan[B], $MachinePrecision]), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\frac{\frac{\tan B}{\sin B} - x}{\tan 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))))): 14 points increase in error, 4 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-rr1.2

    \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{1}{\sin B} - \frac{x}{\tan B}}\right)}^{3}} \]
  4. Applied egg-rr0.2

    \[\leadsto \color{blue}{\frac{\frac{\tan B - \sin B \cdot x}{\sin B}}{\tan B}} \]
  5. Applied egg-rr0.2

    \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B} + \left(-\frac{\sin B}{\frac{\sin B}{x}}\right)}}{\tan B} \]
  6. Simplified0.2

    \[\leadsto \frac{\color{blue}{\frac{\tan B}{\sin B} - x}}{\tan B} \]
    Proof
    (-.f64 (/.f64 (tan.f64 B) (sin.f64 B)) x): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (tan.f64 B) (sin.f64 B)) (Rewrite<= *-lft-identity_binary64 (*.f64 1 x))): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (tan.f64 B) (sin.f64 B)) (*.f64 (Rewrite<= *-inverses_binary64 (/.f64 (sin.f64 B) (sin.f64 B))) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 (/.f64 (tan.f64 B) (sin.f64 B)) (Rewrite<= associate-/r/_binary64 (/.f64 (sin.f64 B) (/.f64 (sin.f64 B) x)))): 7 points increase in error, 5 points decrease in error
    (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (tan.f64 B) (sin.f64 B)) (neg.f64 (/.f64 (sin.f64 B) (/.f64 (sin.f64 B) x))))): 0 points increase in error, 0 points decrease in error
  7. Final simplification0.2

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

Alternatives

Alternative 1
Error0.2
Cost13248
\[\frac{1}{\sin B} - \frac{x}{\tan B} \]
Alternative 2
Error0.8
Cost7112
\[\begin{array}{l} t_0 := \frac{1 - x}{\tan B}\\ \mathbf{if}\;x \leq -1.15:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.1
Cost6984
\[\begin{array}{l} t_0 := \frac{1 - x}{\tan B}\\ \mathbf{if}\;x \leq -0.135:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.6
Cost6920
\[\begin{array}{l} t_0 := \frac{-x}{\tan B}\\ \mathbf{if}\;x \leq -1.86:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.05:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error19.2
Cost6856
\[\begin{array}{l} t_0 := \frac{1}{\sin B}\\ \mathbf{if}\;B \leq -1.9 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;B \leq 4 \cdot 10^{-36}:\\ \;\;\;\;\frac{1 - x}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error35.6
Cost704
\[\frac{1 - x}{B} + B \cdot \left(x \cdot 0.3333333333333333\right) \]
Alternative 7
Error36.6
Cost520
\[\begin{array}{l} t_0 := \frac{-x}{B}\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-14}:\\ \;\;\;\;\frac{1}{B}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error35.5
Cost320
\[\frac{1 - x}{B} \]
Alternative 9
Error61.9
Cost192
\[B \cdot 0.16666666666666666 \]
Alternative 10
Error44.5
Cost192
\[\frac{1}{B} \]

Error

Reproduce

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