?

Average Accuracy: 86.9% → 85.0%
Time: 11.0s
Precision: binary64
Cost: 7112

?

\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+14}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \end{array} \]
(FPCore (B x)
 :precision binary64
 (+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))
(FPCore (B x)
 :precision binary64
 (if (<= x -4e+14)
   (/ (- x) (tan B))
   (if (<= x 6.2e-27)
     (- (/ 1.0 (sin B)) (/ x B))
     (- (/ 1.0 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) {
	double tmp;
	if (x <= -4e+14) {
		tmp = -x / tan(B);
	} else if (x <= 6.2e-27) {
		tmp = (1.0 / sin(B)) - (x / B);
	} else {
		tmp = (1.0 / B) - (x / tan(B));
	}
	return tmp;
}
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
    real(8) :: tmp
    if (x <= (-4d+14)) then
        tmp = -x / tan(b)
    else if (x <= 6.2d-27) then
        tmp = (1.0d0 / sin(b)) - (x / b)
    else
        tmp = (1.0d0 / b) - (x / tan(b))
    end if
    code = tmp
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) {
	double tmp;
	if (x <= -4e+14) {
		tmp = -x / Math.tan(B);
	} else if (x <= 6.2e-27) {
		tmp = (1.0 / Math.sin(B)) - (x / B);
	} else {
		tmp = (1.0 / B) - (x / Math.tan(B));
	}
	return tmp;
}
def code(B, x):
	return -(x * (1.0 / math.tan(B))) + (1.0 / math.sin(B))
def code(B, x):
	tmp = 0
	if x <= -4e+14:
		tmp = -x / math.tan(B)
	elif x <= 6.2e-27:
		tmp = (1.0 / math.sin(B)) - (x / B)
	else:
		tmp = (1.0 / B) - (x / math.tan(B))
	return tmp
function code(B, x)
	return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(1.0 / sin(B)))
end
function code(B, x)
	tmp = 0.0
	if (x <= -4e+14)
		tmp = Float64(Float64(-x) / tan(B));
	elseif (x <= 6.2e-27)
		tmp = Float64(Float64(1.0 / sin(B)) - Float64(x / B));
	else
		tmp = Float64(Float64(1.0 / B) - Float64(x / tan(B)));
	end
	return tmp
end
function tmp = code(B, x)
	tmp = -(x * (1.0 / tan(B))) + (1.0 / sin(B));
end
function tmp_2 = code(B, x)
	tmp = 0.0;
	if (x <= -4e+14)
		tmp = -x / tan(B);
	elseif (x <= 6.2e-27)
		tmp = (1.0 / sin(B)) - (x / B);
	else
		tmp = (1.0 / B) - (x / tan(B));
	end
	tmp_2 = tmp;
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_] := If[LessEqual[x, -4e+14], N[((-x) / N[Tan[B], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.2e-27], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - N[(x / B), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / B), $MachinePrecision] - N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{1}{\sin B}
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+14}:\\
\;\;\;\;\frac{-x}{\tan B}\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\


\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 < -4e14

    1. Initial program 73.5%

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

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

      [Start]73.5

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

      +-commutative [=>]73.5

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

      unsub-neg [=>]73.5

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

      associate-*r/ [=>]73.7

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

      *-rgt-identity [=>]73.7

      \[ \frac{1}{\sin B} - \frac{\color{blue}{x}}{\tan B} \]
    3. Taylor expanded in x around inf 73.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{\cos B \cdot x}{\sin B}} \]
    4. Simplified73.6%

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

      [Start]73.6

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

      mul-1-neg [=>]73.6

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

      associate-*r/ [<=]73.6

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

      distribute-rgt-neg-in [=>]73.6

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

      distribute-neg-frac [=>]73.6

      \[ \cos B \cdot \color{blue}{\frac{-x}{\sin B}} \]
    5. Taylor expanded in B around inf 73.6%

      \[\leadsto \color{blue}{-1 \cdot \frac{\cos B \cdot x}{\sin B}} \]
    6. Simplified73.6%

      \[\leadsto \color{blue}{\frac{\left(-x\right) \cdot \cos B}{\sin B}} \]
      Proof

      [Start]73.6

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

      associate-*r/ [=>]73.6

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

      *-commutative [=>]73.6

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

      associate-*r* [=>]73.6

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

      neg-mul-1 [<=]73.6

      \[ \frac{\color{blue}{\left(-x\right)} \cdot \cos B}{\sin B} \]
    7. Applied egg-rr73.7%

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

      [Start]73.6

      \[ \frac{\left(-x\right) \cdot \cos B}{\sin B} \]

      associate-/l* [=>]73.6

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

      neg-sub0 [=>]73.6

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

      div-sub [=>]73.6

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

      quot-tan [=>]73.6

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

      quot-tan [=>]73.7

      \[ \frac{0}{\tan B} - \frac{x}{\color{blue}{\tan B}} \]
    8. Simplified73.7%

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

      [Start]73.7

      \[ \frac{0}{\tan B} - \frac{x}{\tan B} \]

      div-sub [<=]73.7

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

      neg-sub0 [<=]73.7

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

    if -4e14 < x < 6.1999999999999997e-27

    1. Initial program 99.8%

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

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

      [Start]99.8

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

      +-commutative [=>]99.8

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

      unsub-neg [=>]99.8

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

      associate-*r/ [=>]99.8

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

      *-rgt-identity [=>]99.8

      \[ \frac{1}{\sin B} - \frac{\color{blue}{x}}{\tan B} \]
    3. Taylor expanded in B around 0 98.2%

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

    if 6.1999999999999997e-27 < x

    1. Initial program 75.3%

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

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

      [Start]75.3

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

      +-commutative [=>]75.3

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

      unsub-neg [=>]75.3

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

      associate-*r/ [=>]75.4

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

      *-rgt-identity [=>]75.4

      \[ \frac{1}{\sin B} - \frac{\color{blue}{x}}{\tan B} \]
    3. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\sin B}\right)\right)} - \frac{x}{\tan B} \]
      Proof

      [Start]75.4

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

      log1p-expm1-u [=>]50.6

      \[ \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\sin B}\right)\right)} - \frac{x}{\tan B} \]
    4. Taylor expanded in B around 0 71.2%

      \[\leadsto \color{blue}{\frac{1}{B}} - \frac{x}{\tan B} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+14}:\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{1}{\sin B} - \frac{x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy87.0%
Cost13248
\[\frac{1}{\sin B} - \frac{x}{\tan B} \]
Alternative 2
Accuracy85.1%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-5} \lor \neg \left(x \leq 6.2 \cdot 10^{-27}\right):\\ \;\;\;\;\frac{1}{B} - \frac{x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 3
Accuracy85.0%
Cost6921
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{-x}{\tan B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sin B}\\ \end{array} \]
Alternative 4
Accuracy61.2%
Cost6856
\[\begin{array}{l} t_0 := \frac{1 - x}{B}\\ \mathbf{if}\;x \leq -2.95 \cdot 10^{-8}:\\ \;\;\;\;\frac{B \cdot 0.027777777777777776}{0.16666666666666666 + x \cdot -0.3333333333333333} + t_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-27}:\\ \;\;\;\;\frac{1}{\sin B}\\ \mathbf{else}:\\ \;\;\;\;t_0 + B \cdot 0.16666666666666666\\ \end{array} \]
Alternative 5
Accuracy38.2%
Cost576
\[\frac{1 - x}{B} + B \cdot 0.16666666666666666 \]
Alternative 6
Accuracy36.6%
Cost521
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-25} \lor \neg \left(x \leq 1\right):\\ \;\;\;\;\frac{-x}{B}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{B}\\ \end{array} \]
Alternative 7
Accuracy38.0%
Cost320
\[\frac{1 - x}{B} \]
Alternative 8
Accuracy26.2%
Cost192
\[\frac{1}{B} \]

Error

Reproduce?

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