Average Error: 20.2 → 20.2
Time: 19.5s
Precision: binary64
Cost: 72064
\[{\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} \]
\[\begin{array}{l} t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\ {\left(a \cdot \left(\left(\left(1 + t_0 \cdot 0.5\right) + -1\right) + \log \left(\sqrt{e^{t_0}}\right)\right)\right)}^{2} + {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} \end{array} \]
(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
 (let* ((t_0 (cos (* PI (* angle 0.005555555555555556)))))
   (+
    (pow (* a (+ (+ (+ 1.0 (* t_0 0.5)) -1.0) (log (sqrt (exp t_0))))) 2.0)
    (pow (* (sin (* angle (* PI 0.005555555555555556))) b) 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) {
	double t_0 = cos((((double) M_PI) * (angle * 0.005555555555555556)));
	return pow((a * (((1.0 + (t_0 * 0.5)) + -1.0) + log(sqrt(exp(t_0))))), 2.0) + pow((sin((angle * (((double) M_PI) * 0.005555555555555556))) * b), 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) {
	double t_0 = Math.cos((Math.PI * (angle * 0.005555555555555556)));
	return Math.pow((a * (((1.0 + (t_0 * 0.5)) + -1.0) + Math.log(Math.sqrt(Math.exp(t_0))))), 2.0) + Math.pow((Math.sin((angle * (Math.PI * 0.005555555555555556))) * b), 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):
	t_0 = math.cos((math.pi * (angle * 0.005555555555555556)))
	return math.pow((a * (((1.0 + (t_0 * 0.5)) + -1.0) + math.log(math.sqrt(math.exp(t_0))))), 2.0) + math.pow((math.sin((angle * (math.pi * 0.005555555555555556))) * b), 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)
	t_0 = cos(Float64(pi * Float64(angle * 0.005555555555555556)))
	return Float64((Float64(a * Float64(Float64(Float64(1.0 + Float64(t_0 * 0.5)) + -1.0) + log(sqrt(exp(t_0))))) ^ 2.0) + (Float64(sin(Float64(angle * Float64(pi * 0.005555555555555556))) * b) ^ 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)
	t_0 = cos((pi * (angle * 0.005555555555555556)));
	tmp = ((a * (((1.0 + (t_0 * 0.5)) + -1.0) + log(sqrt(exp(t_0))))) ^ 2.0) + ((sin((angle * (pi * 0.005555555555555556))) * b) ^ 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_] := Block[{t$95$0 = N[Cos[N[(Pi * N[(angle * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(N[Power[N[(a * N[(N[(N[(1.0 + N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] + N[Log[N[Sqrt[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * b), $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}
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\\
{\left(a \cdot \left(\left(\left(1 + t_0 \cdot 0.5\right) + -1\right) + \log \left(\sqrt{e^{t_0}}\right)\right)\right)}^{2} + {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2}
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 20.2

    \[{\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 b around 0 20.2

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

    \[\leadsto {\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\color{blue}{\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}}^{2} \]
    Proof
    (*.f64 (sin.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))) b): 0 points increase in error, 0 points decrease in error
    (*.f64 (sin.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 angle (PI.f64)) 1/180))) b): 19 points increase in error, 33 points decrease in error
    (*.f64 (sin.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/180 (*.f64 angle (PI.f64))))) b): 0 points increase in error, 0 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 b (sin.f64 (*.f64 1/180 (*.f64 angle (PI.f64)))))): 0 points increase in error, 0 points decrease in error
  4. Applied egg-rr20.2

    \[\leadsto {\left(a \cdot \color{blue}{\left(\log \left(\sqrt{e^{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right) + \log \left(\sqrt{e^{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right)\right)}\right)}^{2} + {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} \]
  5. Applied egg-rr20.2

    \[\leadsto {\left(a \cdot \left(\color{blue}{\left(\left(1 + \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot 0.5\right) - 1\right)} + \log \left(\sqrt{e^{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right)\right)\right)}^{2} + {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} \]
  6. Final simplification20.2

    \[\leadsto {\left(a \cdot \left(\left(\left(1 + \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot 0.5\right) + -1\right) + \log \left(\sqrt{e^{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}}\right)\right)\right)}^{2} + {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} \]

Alternatives

Alternative 1
Error20.2
Cost52992
\[\begin{array}{l} t_0 := \cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot 0.5\\ {\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} + {\left(a \cdot \left(t_0 + \left(\left(1 + t_0\right) + -1\right)\right)\right)}^{2} \end{array} \]
Alternative 2
Error20.2
Cost26496
\[{a}^{2} + 3 \cdot \left(0.3333333333333333 \cdot {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2}\right) \]
Alternative 3
Error20.1
Cost26240
\[{\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2} + {a}^{2} \]
Alternative 4
Error26.1
Cost20096
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot \left(\left(angle \cdot b\right) \cdot \left(\pi \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)\right)\right) \]
Alternative 5
Error23.7
Cost20096
\[{a}^{2} + {\left(angle \cdot \left(\left(1 + \pi \cdot b\right) + -1\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
Alternative 6
Error26.2
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(\pi \cdot b\right)\right)}^{2} \]
Alternative 7
Error26.0
Cost19840
\[{a}^{2} + {\left(\pi \cdot \left(0.005555555555555556 \cdot \left(angle \cdot b\right)\right)\right)}^{2} \]

Error

Reproduce

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