| Alternative 1 | |
|---|---|
| Error | 31.6 |
| Cost | 46212 |
(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-300)
(*
(* 2.0 (- (pow a 2.0)))
(*
(- (sin (* PI (* angle -0.005555555555555556))))
(cos (* 0.005555555555555556 (* angle PI)))))
(*
(*
(sin (* angle (* 0.005555555555555556 PI)))
(- (cos (* PI (+ 1.0 (* angle 0.005555555555555556))))))
(* 2.0 (pow b 2.0)))))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-300) {
tmp = (2.0 * -pow(a, 2.0)) * (-sin((((double) M_PI) * (angle * -0.005555555555555556))) * cos((0.005555555555555556 * (angle * ((double) M_PI)))));
} else {
tmp = (sin((angle * (0.005555555555555556 * ((double) M_PI)))) * -cos((((double) M_PI) * (1.0 + (angle * 0.005555555555555556))))) * (2.0 * pow(b, 2.0));
}
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-300) {
tmp = (2.0 * -Math.pow(a, 2.0)) * (-Math.sin((Math.PI * (angle * -0.005555555555555556))) * Math.cos((0.005555555555555556 * (angle * Math.PI))));
} else {
tmp = (Math.sin((angle * (0.005555555555555556 * Math.PI))) * -Math.cos((Math.PI * (1.0 + (angle * 0.005555555555555556))))) * (2.0 * Math.pow(b, 2.0));
}
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-300: tmp = (2.0 * -math.pow(a, 2.0)) * (-math.sin((math.pi * (angle * -0.005555555555555556))) * math.cos((0.005555555555555556 * (angle * math.pi)))) else: tmp = (math.sin((angle * (0.005555555555555556 * math.pi))) * -math.cos((math.pi * (1.0 + (angle * 0.005555555555555556))))) * (2.0 * math.pow(b, 2.0)) 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-300) tmp = Float64(Float64(2.0 * Float64(-(a ^ 2.0))) * Float64(Float64(-sin(Float64(pi * Float64(angle * -0.005555555555555556)))) * cos(Float64(0.005555555555555556 * Float64(angle * pi))))); else tmp = Float64(Float64(sin(Float64(angle * Float64(0.005555555555555556 * pi))) * Float64(-cos(Float64(pi * Float64(1.0 + Float64(angle * 0.005555555555555556)))))) * Float64(2.0 * (b ^ 2.0))); 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-300) tmp = (2.0 * -(a ^ 2.0)) * (-sin((pi * (angle * -0.005555555555555556))) * cos((0.005555555555555556 * (angle * pi)))); else tmp = (sin((angle * (0.005555555555555556 * pi))) * -cos((pi * (1.0 + (angle * 0.005555555555555556))))) * (2.0 * (b ^ 2.0)); 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-300], N[(N[(2.0 * (-N[Power[a, 2.0], $MachinePrecision])), $MachinePrecision] * N[((-N[Sin[N[(Pi * N[(angle * -0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) * N[Cos[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[N[(angle * N[(0.005555555555555556 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Cos[N[(Pi * N[(1.0 + N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] * N[(2.0 * N[Power[b, 2.0], $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^{-300}:\\
\;\;\;\;\left(2 \cdot \left(-{a}^{2}\right)\right) \cdot \left(\left(-\sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \left(-\cos \left(\pi \cdot \left(1 + angle \cdot 0.005555555555555556\right)\right)\right)\right) \cdot \left(2 \cdot {b}^{2}\right)\\
\end{array}
Results
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -4.99999999999999996e-300Initial program 33.9
Simplified33.9
[Start]33.9 | \[ \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 [=>]33.9 | \[ \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 [=>]33.9 | \[ \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 34.0
Applied egg-rr33.9
Taylor expanded in b around 0 34.1
Simplified34.1
[Start]34.1 | \[ \left(2 \cdot \left(-1 \cdot {a}^{2}\right)\right) \cdot \left(\left(-\sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]34.1 | \[ \left(2 \cdot \color{blue}{\left({a}^{2} \cdot -1\right)}\right) \cdot \left(\left(-\sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)
\] |
rational.json-simplify-8 [<=]34.1 | \[ \left(2 \cdot \color{blue}{\left(-{a}^{2}\right)}\right) \cdot \left(\left(-\sin \left(\pi \cdot \left(angle \cdot -0.005555555555555556\right)\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)
\] |
if -4.99999999999999996e-300 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 29.4
Simplified29.4
[Start]29.4 | \[ \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.4 | \[ \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.4 | \[ \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 b around inf 29.5
Simplified29.5
[Start]29.5 | \[ 2 \cdot \left({b}^{2} \cdot \left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)
\] |
|---|---|
rational.json-simplify-43 [=>]29.5 | \[ \color{blue}{{b}^{2} \cdot \left(\left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot 2\right)}
\] |
rational.json-simplify-43 [=>]29.5 | \[ \color{blue}{\left(\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot \left(2 \cdot {b}^{2}\right)}
\] |
rational.json-simplify-2 [=>]29.5 | \[ \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)} \cdot \left(2 \cdot {b}^{2}\right)
\] |
rational.json-simplify-2 [=>]29.5 | \[ \left(\sin \left(0.005555555555555556 \cdot \color{blue}{\left(\pi \cdot angle\right)}\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot \left(2 \cdot {b}^{2}\right)
\] |
rational.json-simplify-43 [<=]29.5 | \[ \left(\sin \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)} \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right) \cdot \left(2 \cdot {b}^{2}\right)
\] |
rational.json-simplify-2 [=>]29.5 | \[ \left(\sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \color{blue}{\left(\pi \cdot angle\right)}\right)\right) \cdot \left(2 \cdot {b}^{2}\right)
\] |
rational.json-simplify-43 [<=]29.5 | \[ \left(\sin \left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right) \cdot \cos \color{blue}{\left(angle \cdot \left(0.005555555555555556 \cdot \pi\right)\right)}\right) \cdot \left(2 \cdot {b}^{2}\right)
\] |
Applied egg-rr29.7
Final simplification31.6
| Alternative 1 | |
|---|---|
| Error | 31.6 |
| Cost | 46212 |
| Alternative 2 | |
|---|---|
| Error | 31.4 |
| Cost | 46084 |
| Alternative 3 | |
|---|---|
| Error | 31.5 |
| Cost | 46084 |
| Alternative 4 | |
|---|---|
| Error | 31.5 |
| Cost | 46084 |
| Alternative 5 | |
|---|---|
| Error | 31.6 |
| Cost | 46084 |
| Alternative 6 | |
|---|---|
| Error | 31.4 |
| Cost | 39488 |
| Alternative 7 | |
|---|---|
| Error | 31.2 |
| Cost | 39488 |
| Alternative 8 | |
|---|---|
| Error | 31.2 |
| Cost | 39488 |
| Alternative 9 | |
|---|---|
| Error | 31.3 |
| Cost | 39488 |
| Alternative 10 | |
|---|---|
| Error | 31.3 |
| Cost | 39488 |
| Alternative 11 | |
|---|---|
| Error | 31.4 |
| Cost | 39488 |
| Alternative 12 | |
|---|---|
| Error | 31.4 |
| Cost | 39488 |
| Alternative 13 | |
|---|---|
| Error | 32.4 |
| Cost | 33092 |
| Alternative 14 | |
|---|---|
| Error | 32.2 |
| Cost | 26496 |
| Alternative 15 | |
|---|---|
| Error | 37.5 |
| Cost | 20040 |
| Alternative 16 | |
|---|---|
| Error | 34.2 |
| Cost | 19840 |
| Alternative 17 | |
|---|---|
| Error | 34.2 |
| Cost | 19840 |
| Alternative 18 | |
|---|---|
| Error | 34.1 |
| Cost | 19840 |
| Alternative 19 | |
|---|---|
| Error | 38.4 |
| Cost | 13512 |
| Alternative 20 | |
|---|---|
| Error | 38.3 |
| Cost | 13512 |
| Alternative 21 | |
|---|---|
| Error | 38.4 |
| Cost | 13512 |
| Alternative 22 | |
|---|---|
| Error | 43.4 |
| Cost | 13248 |
| Alternative 23 | |
|---|---|
| Error | 43.4 |
| Cost | 13248 |
| Alternative 24 | |
|---|---|
| Error | 43.4 |
| Cost | 13248 |
herbie shell --seed 2023074
(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)))))