| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13248 |
\[\frac{1}{\sin B} - \frac{x}{\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}
Results
Initial program 0.2
Simplified0.1
[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}
\] |
Applied egg-rr9.0
Simplified8.9
[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}}
\] |
Taylor expanded in B around inf 0.4
Applied egg-rr0.3
Simplified0.2
[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}}
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 13248 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 13248 |
| Alternative 3 | |
|---|---|
| Error | 1.1 |
| Cost | 7113 |
| Alternative 4 | |
|---|---|
| Error | 1.8 |
| Cost | 6985 |
| Alternative 5 | |
|---|---|
| Error | 1.2 |
| Cost | 6985 |
| Alternative 6 | |
|---|---|
| Error | 18.1 |
| Cost | 6857 |
| Alternative 7 | |
|---|---|
| Error | 36.4 |
| Cost | 521 |
| Alternative 8 | |
|---|---|
| Error | 35.5 |
| Cost | 320 |
| Alternative 9 | |
|---|---|
| Error | 61.9 |
| Cost | 192 |
| Alternative 10 | |
|---|---|
| Error | 44.7 |
| Cost | 192 |
herbie shell --seed 2023025
(FPCore (B x)
:name "VandenBroeck and Keller, Equation (24)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (/ 1.0 (sin B))))