| Alternative 1 | |
|---|---|
| Error | 21.3 |
| Cost | 26368 |
\[\left(\left(b + a\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\right)\right)\right) \cdot \left(b - a\right)
\]
(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
(let* ((t_0 (sin (* 0.011111111111111112 (* angle PI)))))
(if (<= (/ angle 180.0) -20.0)
(/ (* (* (+ b a) (- b a)) (* t_0 (- b a))) (- b a))
(if (<= (/ angle 180.0) 2.5e-23)
(* (- b a) (* (+ b a) (* angle (* 0.011111111111111112 PI))))
(* t_0 (- (* b b) (* a a)))))))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 t_0 = sin((0.011111111111111112 * (angle * ((double) M_PI))));
double tmp;
if ((angle / 180.0) <= -20.0) {
tmp = (((b + a) * (b - a)) * (t_0 * (b - a))) / (b - a);
} else if ((angle / 180.0) <= 2.5e-23) {
tmp = (b - a) * ((b + a) * (angle * (0.011111111111111112 * ((double) M_PI))));
} else {
tmp = t_0 * ((b * b) - (a * a));
}
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 t_0 = Math.sin((0.011111111111111112 * (angle * Math.PI)));
double tmp;
if ((angle / 180.0) <= -20.0) {
tmp = (((b + a) * (b - a)) * (t_0 * (b - a))) / (b - a);
} else if ((angle / 180.0) <= 2.5e-23) {
tmp = (b - a) * ((b + a) * (angle * (0.011111111111111112 * Math.PI)));
} else {
tmp = t_0 * ((b * b) - (a * a));
}
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): t_0 = math.sin((0.011111111111111112 * (angle * math.pi))) tmp = 0 if (angle / 180.0) <= -20.0: tmp = (((b + a) * (b - a)) * (t_0 * (b - a))) / (b - a) elif (angle / 180.0) <= 2.5e-23: tmp = (b - a) * ((b + a) * (angle * (0.011111111111111112 * math.pi))) else: tmp = t_0 * ((b * b) - (a * a)) 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) t_0 = sin(Float64(0.011111111111111112 * Float64(angle * pi))) tmp = 0.0 if (Float64(angle / 180.0) <= -20.0) tmp = Float64(Float64(Float64(Float64(b + a) * Float64(b - a)) * Float64(t_0 * Float64(b - a))) / Float64(b - a)); elseif (Float64(angle / 180.0) <= 2.5e-23) tmp = Float64(Float64(b - a) * Float64(Float64(b + a) * Float64(angle * Float64(0.011111111111111112 * pi)))); else tmp = Float64(t_0 * Float64(Float64(b * b) - Float64(a * a))); 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) t_0 = sin((0.011111111111111112 * (angle * pi))); tmp = 0.0; if ((angle / 180.0) <= -20.0) tmp = (((b + a) * (b - a)) * (t_0 * (b - a))) / (b - a); elseif ((angle / 180.0) <= 2.5e-23) tmp = (b - a) * ((b + a) * (angle * (0.011111111111111112 * pi))); else tmp = t_0 * ((b * b) - (a * a)); 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_] := Block[{t$95$0 = N[Sin[N[(0.011111111111111112 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(angle / 180.0), $MachinePrecision], -20.0], N[(N[(N[(N[(b + a), $MachinePrecision] * N[(b - a), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(b - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(angle / 180.0), $MachinePrecision], 2.5e-23], N[(N[(b - a), $MachinePrecision] * N[(N[(b + a), $MachinePrecision] * N[(angle * N[(0.011111111111111112 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(b * b), $MachinePrecision] - N[(a * a), $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}
t_0 := \sin \left(0.011111111111111112 \cdot \left(angle \cdot \pi\right)\right)\\
\mathbf{if}\;\frac{angle}{180} \leq -20:\\
\;\;\;\;\frac{\left(\left(b + a\right) \cdot \left(b - a\right)\right) \cdot \left(t_0 \cdot \left(b - a\right)\right)}{b - a}\\
\mathbf{elif}\;\frac{angle}{180} \leq 2.5 \cdot 10^{-23}:\\
\;\;\;\;\left(b - a\right) \cdot \left(\left(b + a\right) \cdot \left(angle \cdot \left(0.011111111111111112 \cdot \pi\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \left(b \cdot b - a \cdot a\right)\\
\end{array}
Results
if (/.f64 angle 180) < -20Initial program 50.9
Simplified50.9
Applied egg-rr50.9
Taylor expanded in a around 0 50.9
Applied egg-rr50.9
Applied egg-rr52.6
if -20 < (/.f64 angle 180) < 2.5000000000000001e-23Initial program 17.9
Simplified17.8
Applied egg-rr9.8
Taylor expanded in a around 0 0.3
Applied egg-rr0.3
Taylor expanded in angle around 0 0.6
Simplified0.6
if 2.5000000000000001e-23 < (/.f64 angle 180) Initial program 46.0
Simplified46.0
Applied egg-rr51.7
Applied egg-rr45.9
Taylor expanded in b around 0 46.0
Simplified46.0
Final simplification21.8
| Alternative 1 | |
|---|---|
| Error | 21.3 |
| Cost | 26368 |
| Alternative 2 | |
|---|---|
| Error | 21.4 |
| Cost | 14088 |
| Alternative 3 | |
|---|---|
| Error | 22.8 |
| Cost | 13640 |
| Alternative 4 | |
|---|---|
| Error | 22.7 |
| Cost | 13640 |
| Alternative 5 | |
|---|---|
| Error | 22.7 |
| Cost | 13576 |
| Alternative 6 | |
|---|---|
| Error | 22.7 |
| Cost | 13576 |
| Alternative 7 | |
|---|---|
| Error | 29.4 |
| Cost | 7432 |
| Alternative 8 | |
|---|---|
| Error | 24.9 |
| Cost | 7300 |
| Alternative 9 | |
|---|---|
| Error | 24.8 |
| Cost | 7300 |
| Alternative 10 | |
|---|---|
| Error | 38.7 |
| Cost | 7176 |
| Alternative 11 | |
|---|---|
| Error | 38.6 |
| Cost | 7176 |
| Alternative 12 | |
|---|---|
| Error | 34.1 |
| Cost | 7176 |
| Alternative 13 | |
|---|---|
| Error | 34.1 |
| Cost | 7176 |
| Alternative 14 | |
|---|---|
| Error | 34.1 |
| Cost | 7176 |
| Alternative 15 | |
|---|---|
| Error | 43.3 |
| Cost | 6912 |

herbie shell --seed 2022228
(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)))))