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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 20.2

    \[{\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} \]
  2. Simplified20.1

    \[\leadsto \color{blue}{{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}} \]
    Proof
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 angle (/.f64 (PI.f64) 180)))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 angle (/.f64 (PI.f64) 180)))) 2)): 0 points increase in error, 0 points decrease in error
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 angle (PI.f64)) 180)))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 angle (/.f64 (PI.f64) 180)))) 2)): 15 points increase in error, 7 points decrease in error
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 angle 180) (PI.f64))))) 2) (pow.f64 (*.f64 b (cos.f64 (*.f64 angle (/.f64 (PI.f64) 180)))) 2)): 11 points increase in error, 17 points decrease in error
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2) (pow.f64 (*.f64 b (cos.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 angle (PI.f64)) 180)))) 2)): 8 points increase in error, 8 points decrease in error
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle 180) (PI.f64)))) 2) (pow.f64 (*.f64 b (cos.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 angle 180) (PI.f64))))) 2)): 9 points increase in error, 8 points decrease in error
  3. Taylor expanded in angle around 0 20.2

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

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

    \[\leadsto {\left(a \cdot \color{blue}{\sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)}\right)}^{2} + {\left(b \cdot 1\right)}^{2} \]
    Proof
    (sin.f64 (*.f64 (PI.f64) (*.f64 1/180 angle))): 0 points increase in error, 0 points decrease in error
    (sin.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 1/180 angle) (PI.f64)))): 0 points increase in error, 0 points decrease in error
    (sin.f64 (Rewrite<= associate-*r*_binary64 (*.f64 1/180 (*.f64 angle (PI.f64))))): 48 points increase in error, 43 points decrease in error
  6. Final simplification20.2

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

Alternatives

Alternative 1
Error20.2
Cost26240
\[{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)}^{2} \]
Alternative 2
Error20.2
Cost26240
\[{b}^{2} + {\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} \]
Alternative 3
Error23.6
Cost20096
\[{b}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(1 + a \cdot \pi\right) + -1\right)\right)\right)}^{2} \]
Alternative 4
Error25.7
Cost19840
\[{b}^{2} + {\left(a \cdot \left(\pi \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]
Alternative 5
Error25.7
Cost19840
\[{b}^{2} + {\left(\pi \cdot \left(a \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}^{2} \]

Error

Reproduce

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