?

Average Error: 0.2 → 0.2
Time: 12.7s
Precision: binary64
Cost: 13440

?

\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\frac{x - \frac{x}{x \cdot \cos B}}{-\tan B} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x) :precision binary64 (/ (- x (/ x (* x (cos B)))) (- (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 (x - (x / (x * cos(B)))) / -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 = (x - (x / (x * cos(b)))) / -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 (x - (x / (x * Math.cos(B)))) / -Math.tan(B);
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
def code(B, x):
	return (x - (x / (x * math.cos(B)))) / -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(x - Float64(x / Float64(x * cos(B)))) / Float64(-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 = (x - (x / (x * cos(B)))) / -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[(x - N[(x / N[(x * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Tan[B], $MachinePrecision])), $MachinePrecision]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\frac{x - \frac{x}{x \cdot \cos B}}{-\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.1

    \[\leadsto \color{blue}{\frac{1}{\sin B} - \frac{x}{\tan B}} \]
    Proof

    [Start]0.2

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

    +-commutative [=>]0.2

    \[ \color{blue}{\frac{1}{\sin B} + \left(-x \cdot \frac{1}{\tan B}\right)} \]

    unsub-neg [=>]0.2

    \[ \color{blue}{\frac{1}{\sin B} - x \cdot \frac{1}{\tan B}} \]

    associate-*r/ [=>]0.1

    \[ \frac{1}{\sin B} - \color{blue}{\frac{x \cdot 1}{\tan B}} \]

    *-rgt-identity [=>]0.1

    \[ \frac{1}{\sin B} - \frac{\color{blue}{x}}{\tan B} \]
  3. Applied egg-rr9.0

    \[\leadsto \color{blue}{\frac{\frac{\tan B}{x} - \sin B}{\sin B \cdot \frac{\tan B}{x}}} \]
  4. Simplified8.9

    \[\leadsto \color{blue}{\frac{\frac{\tan B}{x \cdot \sin B} + -1}{\frac{\tan B}{x}}} \]
    Proof

    [Start]9.0

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

    associate-/r* [=>]0.3

    \[ \color{blue}{\frac{\frac{\frac{\tan B}{x} - \sin B}{\sin B}}{\frac{\tan B}{x}}} \]

    div-sub [=>]0.3

    \[ \frac{\color{blue}{\frac{\frac{\tan B}{x}}{\sin B} - \frac{\sin B}{\sin B}}}{\frac{\tan B}{x}} \]

    *-inverses [=>]0.3

    \[ \frac{\frac{\frac{\tan B}{x}}{\sin B} - \color{blue}{1}}{\frac{\tan B}{x}} \]

    sub-neg [=>]0.3

    \[ \frac{\color{blue}{\frac{\frac{\tan B}{x}}{\sin B} + \left(-1\right)}}{\frac{\tan B}{x}} \]

    associate-/l/ [=>]8.9

    \[ \frac{\color{blue}{\frac{\tan B}{\sin B \cdot x}} + \left(-1\right)}{\frac{\tan B}{x}} \]

    *-commutative [<=]8.9

    \[ \frac{\frac{\tan B}{\color{blue}{x \cdot \sin B}} + \left(-1\right)}{\frac{\tan B}{x}} \]

    metadata-eval [=>]8.9

    \[ \frac{\frac{\tan B}{x \cdot \sin B} + \color{blue}{-1}}{\frac{\tan B}{x}} \]
  5. Taylor expanded in B around inf 0.4

    \[\leadsto \frac{\color{blue}{\frac{1}{\cos B \cdot x}} + -1}{\frac{\tan B}{x}} \]
  6. Applied egg-rr0.3

    \[\leadsto \color{blue}{\left(-\frac{x}{\tan B}\right) + \frac{1}{\cos B \cdot x} \cdot \frac{x}{\tan B}} \]
  7. Simplified0.2

    \[\leadsto \color{blue}{\frac{x - \frac{x}{x \cdot \cos B}}{-\tan B}} \]
    Proof

    [Start]0.3

    \[ \left(-\frac{x}{\tan B}\right) + \frac{1}{\cos B \cdot x} \cdot \frac{x}{\tan B} \]

    +-commutative [<=]0.3

    \[ \color{blue}{\frac{1}{\cos B \cdot x} \cdot \frac{x}{\tan B} + \left(-\frac{x}{\tan B}\right)} \]

    neg-mul-1 [=>]0.3

    \[ \frac{1}{\cos B \cdot x} \cdot \frac{x}{\tan B} + \color{blue}{-1 \cdot \frac{x}{\tan B}} \]

    distribute-rgt-in [<=]0.3

    \[ \color{blue}{\frac{x}{\tan B} \cdot \left(\frac{1}{\cos B \cdot x} + -1\right)} \]

    *-commutative [<=]0.3

    \[ \color{blue}{\left(\frac{1}{\cos B \cdot x} + -1\right) \cdot \frac{x}{\tan B}} \]

    associate-*r/ [=>]0.3

    \[ \color{blue}{\frac{\left(\frac{1}{\cos B \cdot x} + -1\right) \cdot x}{\tan B}} \]

    associate-*l/ [<=]9.4

    \[ \color{blue}{\frac{\frac{1}{\cos B \cdot x} + -1}{\tan B} \cdot x} \]

    remove-double-neg [<=]9.4

    \[ \frac{\frac{1}{\cos B \cdot x} + -1}{\tan B} \cdot \color{blue}{\left(-\left(-x\right)\right)} \]

    distribute-rgt-neg-in [<=]9.4

    \[ \color{blue}{-\frac{\frac{1}{\cos B \cdot x} + -1}{\tan B} \cdot \left(-x\right)} \]

    associate-/r/ [<=]0.4

    \[ -\color{blue}{\frac{\frac{1}{\cos B \cdot x} + -1}{\frac{\tan B}{-x}}} \]

    neg-mul-1 [=>]0.4

    \[ \color{blue}{-1 \cdot \frac{\frac{1}{\cos B \cdot x} + -1}{\frac{\tan B}{-x}}} \]

    associate-/r/ [=>]9.4

    \[ -1 \cdot \color{blue}{\left(\frac{\frac{1}{\cos B \cdot x} + -1}{\tan B} \cdot \left(-x\right)\right)} \]

    metadata-eval [<=]9.4

    \[ \color{blue}{\frac{1}{-1}} \cdot \left(\frac{\frac{1}{\cos B \cdot x} + -1}{\tan B} \cdot \left(-x\right)\right) \]

    associate-*l/ [=>]0.3

    \[ \frac{1}{-1} \cdot \color{blue}{\frac{\left(\frac{1}{\cos B \cdot x} + -1\right) \cdot \left(-x\right)}{\tan B}} \]

    times-frac [<=]0.3

    \[ \color{blue}{\frac{1 \cdot \left(\left(\frac{1}{\cos B \cdot x} + -1\right) \cdot \left(-x\right)\right)}{-1 \cdot \tan B}} \]
  8. Final simplification0.2

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

Alternatives

Alternative 1
Error0.1
Cost13248
\[\frac{1}{\sin B} - \frac{x}{\tan B} \]
Alternative 2
Error0.2
Cost13248
\[\frac{\frac{1}{\cos B} - x}{\tan B} \]
Alternative 3
Error1.1
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -1.75 \lor \neg \left(x \leq 1.82 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{1 - x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \end{array} \]
Alternative 4
Error1.8
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.1\right):\\ \;\;\;\;\frac{-1}{\frac{\tan B}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 5
Error1.2
Cost6985
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-6} \lor \neg \left(x \leq 1.2 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{1 - x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 6
Error18.1
Cost6857
\[\begin{array}{l} \mathbf{if}\;B \leq -0.026 \lor \neg \left(B \leq 0.066\right):\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;B \cdot \left(0.16666666666666666 + x \cdot 0.3333333333333333\right) + \frac{1 - x}{B}\\ \end{array} \]
Alternative 7
Error36.4
Cost521
\[\begin{array}{l} \mathbf{if}\;x \leq -1460000000 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]
Alternative 8
Error35.5
Cost320
\[\frac{1 - x}{B} \]
Alternative 9
Error61.9
Cost192
\[B \cdot 0.16666666666666666 \]
Alternative 10
Error44.7
Cost192
\[\frac{1}{B} \]

Error

Reproduce?

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