| Alternative 1 | |
|---|---|
| Error | 31.9 |
| Cost | 46148 |
(FPCore (a b angle) :precision binary64 (* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))
(FPCore (a b angle)
:precision binary64
(if (<= (- (pow b 2.0) (pow a 2.0)) -5e-311)
(*
(* (sin (* 0.005555555555555556 (* angle PI))) (- (pow a 2.0)))
(* 2.0 (cos (* PI (/ angle 180.0)))))
(*
(cos (* PI (- 1.0 (* 0.005555555555555556 angle))))
(* -2.0 (* (pow b 2.0) (sin (* angle (* PI 0.005555555555555556))))))))double code(double a, double b, double angle) {
return ((2.0 * (pow(b, 2.0) - pow(a, 2.0))) * sin((((double) M_PI) * (angle / 180.0)))) * cos((((double) M_PI) * (angle / 180.0)));
}
double code(double a, double b, double angle) {
double tmp;
if ((pow(b, 2.0) - pow(a, 2.0)) <= -5e-311) {
tmp = (sin((0.005555555555555556 * (angle * ((double) M_PI)))) * -pow(a, 2.0)) * (2.0 * cos((((double) M_PI) * (angle / 180.0))));
} else {
tmp = cos((((double) M_PI) * (1.0 - (0.005555555555555556 * angle)))) * (-2.0 * (pow(b, 2.0) * sin((angle * (((double) M_PI) * 0.005555555555555556)))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
return ((2.0 * (Math.pow(b, 2.0) - Math.pow(a, 2.0))) * Math.sin((Math.PI * (angle / 180.0)))) * Math.cos((Math.PI * (angle / 180.0)));
}
public static double code(double a, double b, double angle) {
double tmp;
if ((Math.pow(b, 2.0) - Math.pow(a, 2.0)) <= -5e-311) {
tmp = (Math.sin((0.005555555555555556 * (angle * Math.PI))) * -Math.pow(a, 2.0)) * (2.0 * Math.cos((Math.PI * (angle / 180.0))));
} else {
tmp = Math.cos((Math.PI * (1.0 - (0.005555555555555556 * angle)))) * (-2.0 * (Math.pow(b, 2.0) * Math.sin((angle * (Math.PI * 0.005555555555555556)))));
}
return tmp;
}
def code(a, b, angle): return ((2.0 * (math.pow(b, 2.0) - math.pow(a, 2.0))) * math.sin((math.pi * (angle / 180.0)))) * math.cos((math.pi * (angle / 180.0)))
def code(a, b, angle): tmp = 0 if (math.pow(b, 2.0) - math.pow(a, 2.0)) <= -5e-311: tmp = (math.sin((0.005555555555555556 * (angle * math.pi))) * -math.pow(a, 2.0)) * (2.0 * math.cos((math.pi * (angle / 180.0)))) else: tmp = math.cos((math.pi * (1.0 - (0.005555555555555556 * angle)))) * (-2.0 * (math.pow(b, 2.0) * math.sin((angle * (math.pi * 0.005555555555555556))))) return tmp
function code(a, b, angle) return Float64(Float64(Float64(2.0 * Float64((b ^ 2.0) - (a ^ 2.0))) * sin(Float64(pi * Float64(angle / 180.0)))) * cos(Float64(pi * Float64(angle / 180.0)))) end
function code(a, b, angle) tmp = 0.0 if (Float64((b ^ 2.0) - (a ^ 2.0)) <= -5e-311) tmp = Float64(Float64(sin(Float64(0.005555555555555556 * Float64(angle * pi))) * Float64(-(a ^ 2.0))) * Float64(2.0 * cos(Float64(pi * Float64(angle / 180.0))))); else tmp = Float64(cos(Float64(pi * Float64(1.0 - Float64(0.005555555555555556 * angle)))) * Float64(-2.0 * Float64((b ^ 2.0) * sin(Float64(angle * Float64(pi * 0.005555555555555556)))))); end return tmp end
function tmp = code(a, b, angle) tmp = ((2.0 * ((b ^ 2.0) - (a ^ 2.0))) * sin((pi * (angle / 180.0)))) * cos((pi * (angle / 180.0))); end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (((b ^ 2.0) - (a ^ 2.0)) <= -5e-311) tmp = (sin((0.005555555555555556 * (angle * pi))) * -(a ^ 2.0)) * (2.0 * cos((pi * (angle / 180.0)))); else tmp = cos((pi * (1.0 - (0.005555555555555556 * angle)))) * (-2.0 * ((b ^ 2.0) * sin((angle * (pi * 0.005555555555555556))))); end tmp_2 = tmp; end
code[a_, b_, angle_] := N[(N[(N[(2.0 * N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[a_, b_, angle_] := If[LessEqual[N[(N[Power[b, 2.0], $MachinePrecision] - N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision], -5e-311], N[(N[(N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Power[a, 2.0], $MachinePrecision])), $MachinePrecision] * N[(2.0 * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(Pi * N[(1.0 - N[(0.005555555555555556 * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-2.0 * N[(N[Power[b, 2.0], $MachinePrecision] * N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\begin{array}{l}
\mathbf{if}\;{b}^{2} - {a}^{2} \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(-{a}^{2}\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\pi \cdot \left(1 - 0.005555555555555556 \cdot angle\right)\right) \cdot \left(-2 \cdot \left({b}^{2} \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\\
\end{array}
Results
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -5.00000000000023e-311Initial program 34.5
Simplified34.4
[Start]34.5 | \[ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]34.5 | \[ \color{blue}{\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational.json-simplify-2 [=>]34.5 | \[ \cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \color{blue}{\left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right)\right)}
\] |
rational.json-simplify-43 [=>]34.4 | \[ \cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \color{blue}{\left(2 \cdot \left(\left({b}^{2} - {a}^{2}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}
\] |
rational.json-simplify-2 [=>]34.4 | \[ \cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \color{blue}{\left(\left(\left({b}^{2} - {a}^{2}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot 2\right)}
\] |
rational.json-simplify-43 [=>]34.4 | \[ \color{blue}{\left(\left({b}^{2} - {a}^{2}\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
Taylor expanded in b around 0 34.7
Simplified34.7
[Start]34.7 | \[ \left(-1 \cdot \left({a}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right) \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]34.7 | \[ \left(-1 \cdot \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot {a}^{2}\right)}\right) \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)
\] |
rational.json-simplify-43 [=>]34.7 | \[ \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left({a}^{2} \cdot -1\right)\right)} \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)
\] |
rational.json-simplify-9 [=>]34.7 | \[ \left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \color{blue}{\left(-{a}^{2}\right)}\right) \cdot \left(2 \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)
\] |
if -5.00000000000023e-311 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 29.6
Simplified29.6
[Start]29.6 | \[ \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]29.6 | \[ \color{blue}{\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
rational.json-simplify-43 [=>]29.6 | \[ \color{blue}{\left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right) \cdot \left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}
\] |
Taylor expanded in angle around inf 29.7
Applied egg-rr29.8
Taylor expanded in b around inf 29.9
Simplified29.9
[Start]29.9 | \[ -2 \cdot \left({b}^{2} \cdot \left(\cos \left(\left(1 - 0.005555555555555556 \cdot angle\right) \cdot \pi\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]29.9 | \[ -2 \cdot \left({b}^{2} \cdot \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(\left(1 - 0.005555555555555556 \cdot angle\right) \cdot \pi\right)\right)}\right)
\] |
rational.json-simplify-43 [<=]29.9 | \[ -2 \cdot \color{blue}{\left(\cos \left(\left(1 - 0.005555555555555556 \cdot angle\right) \cdot \pi\right) \cdot \left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)}
\] |
rational.json-simplify-43 [=>]29.9 | \[ \color{blue}{\cos \left(\left(1 - 0.005555555555555556 \cdot angle\right) \cdot \pi\right) \cdot \left(\left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot -2\right)}
\] |
rational.json-simplify-2 [=>]29.9 | \[ \cos \color{blue}{\left(\pi \cdot \left(1 - 0.005555555555555556 \cdot angle\right)\right)} \cdot \left(\left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot -2\right)
\] |
rational.json-simplify-2 [=>]29.9 | \[ \cos \left(\pi \cdot \left(1 - 0.005555555555555556 \cdot angle\right)\right) \cdot \color{blue}{\left(-2 \cdot \left({b}^{2} \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)}
\] |
rational.json-simplify-43 [=>]29.9 | \[ \cos \left(\pi \cdot \left(1 - 0.005555555555555556 \cdot angle\right)\right) \cdot \left(-2 \cdot \left({b}^{2} \cdot \sin \color{blue}{\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}\right)\right)
\] |
Final simplification32.0
| Alternative 1 | |
|---|---|
| Error | 31.9 |
| Cost | 46148 |
| Alternative 2 | |
|---|---|
| Error | 31.9 |
| Cost | 46148 |
| Alternative 3 | |
|---|---|
| Error | 31.7 |
| Cost | 39488 |
| Alternative 4 | |
|---|---|
| Error | 31.8 |
| Cost | 39488 |
| Alternative 5 | |
|---|---|
| Error | 31.7 |
| Cost | 39488 |
| Alternative 6 | |
|---|---|
| Error | 33.0 |
| Cost | 33092 |
| Alternative 7 | |
|---|---|
| Error | 33.8 |
| Cost | 33028 |
| Alternative 8 | |
|---|---|
| Error | 33.0 |
| Cost | 32964 |
| Alternative 9 | |
|---|---|
| Error | 32.9 |
| Cost | 26624 |
| Alternative 10 | |
|---|---|
| Error | 32.8 |
| Cost | 26496 |
| Alternative 11 | |
|---|---|
| Error | 32.8 |
| Cost | 26496 |
| Alternative 12 | |
|---|---|
| Error | 37.4 |
| Cost | 20040 |
| Alternative 13 | |
|---|---|
| Error | 37.3 |
| Cost | 20040 |
| Alternative 14 | |
|---|---|
| Error | 37.4 |
| Cost | 20040 |
| Alternative 15 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 16 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 17 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 18 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 19 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 20 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 21 | |
|---|---|
| Error | 44.0 |
| Cost | 13248 |
herbie shell --seed 2023065
(FPCore (a b angle)
:name "ab-angle->ABCF B"
:precision binary64
(* (* (* 2.0 (- (pow b 2.0) (pow a 2.0))) (sin (* PI (/ angle 180.0)))) (cos (* PI (/ angle 180.0)))))