Average Error: 20.1 → 20.1
Time: 17.2s
Precision: binary64
Cost: 26240
\[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
\[{a}^{2} + {\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (pow (* a (cos (* PI (/ angle 180.0)))) 2.0)
  (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))
(FPCore (a b angle)
 :precision binary64
 (+ (pow a 2.0) (pow (* b (sin (* angle (* PI 0.005555555555555556)))) 2.0)))
double code(double a, double b, double angle) {
	return pow((a * cos((((double) M_PI) * (angle / 180.0)))), 2.0) + pow((b * sin((((double) M_PI) * (angle / 180.0)))), 2.0);
}
double code(double a, double b, double angle) {
	return pow(a, 2.0) + pow((b * sin((angle * (((double) M_PI) * 0.005555555555555556)))), 2.0);
}
public static double code(double a, double b, double angle) {
	return Math.pow((a * Math.cos((Math.PI * (angle / 180.0)))), 2.0) + Math.pow((b * Math.sin((Math.PI * (angle / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
	return Math.pow(a, 2.0) + Math.pow((b * Math.sin((angle * (Math.PI * 0.005555555555555556)))), 2.0);
}
def code(a, b, angle):
	return math.pow((a * math.cos((math.pi * (angle / 180.0)))), 2.0) + math.pow((b * math.sin((math.pi * (angle / 180.0)))), 2.0)
def code(a, b, angle):
	return math.pow(a, 2.0) + math.pow((b * math.sin((angle * (math.pi * 0.005555555555555556)))), 2.0)
function code(a, b, angle)
	return Float64((Float64(a * cos(Float64(pi * Float64(angle / 180.0)))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle / 180.0)))) ^ 2.0))
end
function code(a, b, angle)
	return Float64((a ^ 2.0) + (Float64(b * sin(Float64(angle * Float64(pi * 0.005555555555555556)))) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((a * cos((pi * (angle / 180.0)))) ^ 2.0) + ((b * sin((pi * (angle / 180.0)))) ^ 2.0);
end
function tmp = code(a, b, angle)
	tmp = (a ^ 2.0) + ((b * sin((angle * (pi * 0.005555555555555556)))) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Cos[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
code[a_, b_, angle_] := N[(N[Power[a, 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
{a}^{2} + {\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 20.1

    \[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  2. Taylor expanded in angle around 0 20.1

    \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Taylor expanded in angle around inf 20.1

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \color{blue}{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} \]
  4. Simplified20.1

    \[\leadsto {\left(a \cdot 1\right)}^{2} + {\left(b \cdot \color{blue}{\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}\right)}^{2} \]
  5. Final simplification20.1

    \[\leadsto {a}^{2} + {\left(b \cdot \sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} \]

Alternatives

Alternative 1
Error21.2
Cost26372
\[\begin{array}{l} \mathbf{if}\;angle \leq 0.049:\\ \;\;\;\;{a}^{2} + {\left(b \cdot \mathsf{expm1}\left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(b \cdot 0\right)}^{2}\\ \end{array} \]
Alternative 2
Error20.2
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} \]
Alternative 3
Error21.8
Cost20104
\[\begin{array}{l} t_0 := {a}^{2} + {\left(b \cdot 0\right)}^{2}\\ \mathbf{if}\;angle \leq -4.8 \cdot 10^{+47}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;angle \leq 1.8761682864304604 \cdot 10^{+31}:\\ \;\;\;\;{a}^{2} + {\left(b \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error21.8
Cost20104
\[\begin{array}{l} t_0 := {a}^{2} + {\left(b \cdot 0\right)}^{2}\\ \mathbf{if}\;angle \leq -4.8 \cdot 10^{+47}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;angle \leq 1.8761682864304604 \cdot 10^{+31}:\\ \;\;\;\;{a}^{2} + {\left(b \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error21.8
Cost20104
\[\begin{array}{l} t_0 := {a}^{2} + {\left(b \cdot 0\right)}^{2}\\ \mathbf{if}\;angle \leq -4.8 \cdot 10^{+47}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;angle \leq 1.8761682864304604 \cdot 10^{+31}:\\ \;\;\;\;{a}^{2} + {\left(angle \cdot \left(b \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error32.0
Cost13248
\[{a}^{2} + {\left(b \cdot 0\right)}^{2} \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (a b angle)
  :name "ab-angle->ABCF C"
  :precision binary64
  (+ (pow (* a (cos (* PI (/ angle 180.0)))) 2.0) (pow (* b (sin (* PI (/ angle 180.0)))) 2.0)))