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

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 20.7

    \[{\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. Applied egg-rr20.7

    \[\leadsto {\left(a \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right)\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Applied egg-rr20.7

    \[\leadsto {\left(a \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{{\left(\sqrt[3]{\cos \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)}\right)}^{3}}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Taylor expanded in angle around 0 20.7

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

    \[\leadsto {\left(a \cdot \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\sqrt[3]{\cos \color{blue}{\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}}\right)}^{3}\right)\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    Proof
    (*.f64 angle (*.f64 (PI.f64) 1/180)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 angle (PI.f64)) 1/180)): 45 points increase in error, 32 points decrease in error
    (Rewrite<= *-commutative_binary64 (*.f64 1/180 (*.f64 angle (PI.f64)))): 0 points increase in error, 0 points decrease in error
  6. Final simplification20.7

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

Alternatives

Alternative 1
Error20.7
Cost39488
\[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{1}{\frac{180}{angle \cdot \pi}}\right)\right)}^{2} \]
Alternative 2
Error20.7
Cost39360
\[{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
Alternative 3
Error20.7
Cost39360
\[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right)}^{2} \]
Alternative 4
Error20.7
Cost39360
\[{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2} \]
Alternative 5
Error20.7
Cost39360
\[{\left(a \cdot \cos \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
Alternative 6
Error20.8
Cost26368
\[{\left(b \cdot \sin \left(\frac{1}{\frac{180}{angle \cdot \pi}}\right)\right)}^{2} + {a}^{2} \]
Alternative 7
Error20.7
Cost26240
\[{\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {a}^{2} \]
Alternative 8
Error20.7
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right)}^{2} \]
Alternative 9
Error22.4
Cost20424
\[\begin{array}{l} \mathbf{if}\;angle \leq -6.361841837595009 \cdot 10^{+72}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;angle \leq 1.3240795603042202 \cdot 10^{+47}:\\ \;\;\;\;\mathsf{fma}\left(angle \cdot b, \left(\pi \cdot 0.005555555555555556\right) \cdot \left(b \cdot \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right)\right), a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot a\\ \end{array} \]
Alternative 10
Error22.4
Cost14152
\[\begin{array}{l} \mathbf{if}\;angle \leq -6.361841837595009 \cdot 10^{+72}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;angle \leq 1.3240795603042202 \cdot 10^{+47}:\\ \;\;\;\;a \cdot a + \left(angle \cdot b\right) \cdot \left(\left(\pi \cdot 0.005555555555555556\right) \cdot \left(angle \cdot \left(b \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot a\\ \end{array} \]
Alternative 11
Error22.5
Cost13768
\[\begin{array}{l} \mathbf{if}\;angle \leq -6.361841837595009 \cdot 10^{+72}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;angle \leq 1.3240795603042202 \cdot 10^{+47}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;a \cdot a\\ \end{array} \]
Alternative 12
Error22.4
Cost13768
\[\begin{array}{l} \mathbf{if}\;angle \leq -6.361841837595009 \cdot 10^{+72}:\\ \;\;\;\;a \cdot a\\ \mathbf{elif}\;angle \leq 1.3240795603042202 \cdot 10^{+47}:\\ \;\;\;\;a \cdot a + {\left(b \cdot \left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;a \cdot a\\ \end{array} \]
Alternative 13
Error32.4
Cost192
\[a \cdot a \]

Error

Reproduce

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