Average Error: 20.3 → 20.3
Time: 18.7s
Precision: binary64
Cost: 52160
\[{\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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{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 (expm1 (log1p (sin (* angle (* PI 0.005555555555555556)))))) 2.0)
  (pow (* b (cos (/ angle (/ 180.0 PI)))) 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 * expm1(log1p(sin((angle * (((double) M_PI) * 0.005555555555555556)))))), 2.0) + pow((b * cos((angle / (180.0 / ((double) M_PI))))), 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.expm1(Math.log1p(Math.sin((angle * (Math.PI * 0.005555555555555556)))))), 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(((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.expm1(math.log1p(math.sin((angle * (math.pi * 0.005555555555555556)))))), 2.0) + math.pow((b * math.cos((angle / (180.0 / math.pi)))), 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 * expm1(log1p(sin(Float64(angle * Float64(pi * 0.005555555555555556)))))) ^ 2.0) + (Float64(b * cos(Float64(angle / Float64(180.0 / pi)))) ^ 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[(Exp[N[Log[1 + N[Sin[N[(angle * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(angle / N[(180.0 / Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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 \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 20.3

    \[{\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.3

    \[\leadsto \color{blue}{{\left(a \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2}} \]
    Proof
    (+.f64 (pow.f64 (*.f64 a (sin.f64 (/.f64 angle (/.f64 180 (PI.f64))))) 2) (pow.f64 (*.f64 b (cos.f64 (/.f64 angle (/.f64 180 (PI.f64))))) 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 180) (PI.f64))))) 2) (pow.f64 (*.f64 b (cos.f64 (/.f64 angle (/.f64 180 (PI.f64))))) 2)): 3 points increase in error, 0 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 180) (PI.f64))))) 2)): 0 points increase in error, 3 points decrease in error
  3. Applied egg-rr20.3

    \[\leadsto {\left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)}\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2} \]
  4. Final simplification20.3

    \[\leadsto {\left(a \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2} \]

Alternatives

Alternative 1
Error20.3
Cost39360
\[\begin{array}{l} t_0 := angle \cdot \frac{\pi}{180}\\ {\left(a \cdot \sin t_0\right)}^{2} + {\left(b \cdot \cos t_0\right)}^{2} \end{array} \]
Alternative 2
Error20.3
Cost39360
\[{\left(a \cdot \sin \left(\frac{angle}{\frac{180}{\pi}}\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
Alternative 3
Error20.4
Cost26240
\[{b}^{2} + {\left(a \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
Alternative 4
Error20.4
Cost26240
\[{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} + {b}^{2} \]
Alternative 5
Error20.5
Cost20425
\[\begin{array}{l} \mathbf{if}\;angle \leq -3.3 \lor \neg \left(angle \leq 9.5 \cdot 10^{-8}\right):\\ \;\;\;\;{b}^{2} + \frac{a \cdot a}{2} \cdot \left(1 - \cos \left(\pi \cdot \left(angle \cdot 0.011111111111111112\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{2} + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \end{array} \]
Alternative 6
Error25.9
Cost19840
\[{b}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(a \cdot \pi\right)\right)}^{2} \]
Alternative 7
Error25.8
Cost19840
\[{b}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right)}^{2} \]
Alternative 8
Error25.8
Cost19840
\[{b}^{2} + {\left(angle \cdot \left(0.005555555555555556 \cdot \left(a \cdot \pi\right)\right)\right)}^{2} \]
Alternative 9
Error25.8
Cost19840
\[{b}^{2} + {\left(a \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2} \]

Error

Reproduce

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