| Alternative 1 | |
|---|---|
| Error | 30.7 |
| Cost | 39488 |
(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)) -1e-280)
(*
2.0
(* (pow a 2.0) (- (/ (sin (* PI (* angle 0.011111111111111112))) 2.0))))
(* (sin (* 0.011111111111111112 (* angle PI))) (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)) <= -1e-280) {
tmp = 2.0 * (pow(a, 2.0) * -(sin((((double) M_PI) * (angle * 0.011111111111111112))) / 2.0));
} else {
tmp = sin((0.011111111111111112 * (angle * ((double) M_PI)))) * 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)) <= -1e-280) {
tmp = 2.0 * (Math.pow(a, 2.0) * -(Math.sin((Math.PI * (angle * 0.011111111111111112))) / 2.0));
} else {
tmp = Math.sin((0.011111111111111112 * (angle * Math.PI))) * 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)) <= -1e-280: tmp = 2.0 * (math.pow(a, 2.0) * -(math.sin((math.pi * (angle * 0.011111111111111112))) / 2.0)) else: tmp = math.sin((0.011111111111111112 * (angle * math.pi))) * 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)) <= -1e-280) tmp = Float64(2.0 * Float64((a ^ 2.0) * Float64(-Float64(sin(Float64(pi * Float64(angle * 0.011111111111111112))) / 2.0)))); else tmp = Float64(sin(Float64(0.011111111111111112 * Float64(angle * pi))) * (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)) <= -1e-280) tmp = 2.0 * ((a ^ 2.0) * -(sin((pi * (angle * 0.011111111111111112))) / 2.0)); else tmp = sin((0.011111111111111112 * (angle * pi))) * (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], -1e-280], N[(2.0 * N[(N[Power[a, 2.0], $MachinePrecision] * (-N[(N[Sin[N[(Pi * N[(angle * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Power[b, 2.0], $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 -1 \cdot 10^{-280}:\\
\;\;\;\;2 \cdot \left({a}^{2} \cdot \left(-\frac{\sin \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right) \cdot {b}^{2}\\
\end{array}
Results
if (-.f64 (pow.f64 b 2) (pow.f64 a 2)) < -9.9999999999999996e-281Initial program 33.6
Simplified33.6
[Start]33.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 [=>]33.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 [=>]33.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 33.5
Simplified33.5
[Start]33.5 | \[ 2 \cdot \left(\left({b}^{2} - {a}^{2}\right) \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 [<=]33.5 | \[ 2 \cdot \color{blue}{\left(\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \left(\left({b}^{2} - {a}^{2}\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)\right)}
\] |
Taylor expanded in b around 0 33.7
Simplified33.7
[Start]33.7 | \[ 2 \cdot \left(-1 \cdot \left({a}^{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)\right)
\] |
|---|---|
rational.json-simplify-43 [=>]33.7 | \[ 2 \cdot \color{blue}{\left({a}^{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 -1\right)\right)}
\] |
rational.json-simplify-9 [=>]33.7 | \[ 2 \cdot \left({a}^{2} \cdot \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)}\right)
\] |
rational.json-simplify-2 [=>]33.7 | \[ 2 \cdot \left({a}^{2} \cdot \left(-\color{blue}{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)\right)
\] |
trig.json-simplify-41 [=>]33.7 | \[ 2 \cdot \left({a}^{2} \cdot \left(-\color{blue}{\frac{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right) + 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) + \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right) - 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}{2}}\right)\right)
\] |
if -9.9999999999999996e-281 < (-.f64 (pow.f64 b 2) (pow.f64 a 2)) Initial program 28.6
Simplified28.6
[Start]28.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 [=>]28.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 [=>]28.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)}
\] |
rational.json-simplify-2 [=>]28.6 | \[ \color{blue}{\left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \left(2 \cdot \left({b}^{2} - {a}^{2}\right)\right)}
\] |
rational.json-simplify-2 [=>]28.6 | \[ \left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right) \cdot \color{blue}{\left(\left({b}^{2} - {a}^{2}\right) \cdot 2\right)}
\] |
rational.json-simplify-43 [=>]28.6 | \[ \color{blue}{\left({b}^{2} - {a}^{2}\right) \cdot \left(2 \cdot \left(\sin \left(\pi \cdot \frac{angle}{180}\right) \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}
\] |
rational.json-simplify-43 [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \color{blue}{\left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)\right)}
\] |
rational.json-simplify-5 [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \color{blue}{\left(\pi \cdot \frac{angle}{180} - 0\right)}\right)\right)
\] |
metadata-eval [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \left(\pi \cdot \frac{angle}{180} - \color{blue}{\left(0 - 0\right)}\right)\right)\right)
\] |
rational.json-simplify-44 [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \color{blue}{\left(0 - \left(0 - \pi \cdot \frac{angle}{180}\right)\right)}\right)\right)
\] |
rational.json-simplify-12 [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \left(0 - \color{blue}{\left(-\pi \cdot \frac{angle}{180}\right)}\right)\right)\right)
\] |
rational.json-simplify-12 [<=]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \sin \color{blue}{\left(-\left(-\pi \cdot \frac{angle}{180}\right)\right)}\right)\right)
\] |
trig.json-simplify-24 [=>]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \color{blue}{\left(-\sin \left(-\pi \cdot \frac{angle}{180}\right)\right)}\right)\right)
\] |
rational.json-simplify-8 [=>]28.6 | \[ \left({b}^{2} - {a}^{2}\right) \cdot \left(\cos \left(\pi \cdot \frac{angle}{180}\right) \cdot \left(2 \cdot \color{blue}{\left(\sin \left(-\pi \cdot \frac{angle}{180}\right) \cdot -1\right)}\right)\right)
\] |
Taylor expanded in b around inf 28.8
Final simplification30.9
| Alternative 1 | |
|---|---|
| Error | 30.7 |
| Cost | 39488 |
| Alternative 2 | |
|---|---|
| Error | 30.9 |
| Cost | 32900 |
| Alternative 3 | |
|---|---|
| Error | 30.7 |
| Cost | 26240 |
| Alternative 4 | |
|---|---|
| Error | 35.2 |
| Cost | 19976 |
| Alternative 5 | |
|---|---|
| Error | 36.0 |
| Cost | 19912 |
| Alternative 6 | |
|---|---|
| Error | 36.0 |
| Cost | 19912 |
| Alternative 7 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 8 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 9 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 10 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 11 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 12 | |
|---|---|
| Error | 37.3 |
| Cost | 13512 |
| Alternative 13 | |
|---|---|
| Error | 37.4 |
| Cost | 13512 |
| Alternative 14 | |
|---|---|
| Error | 42.8 |
| Cost | 13248 |
herbie shell --seed 2023077
(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)))))