?

Average Error: 20.7 → 21.1
Time: 17.1s
Precision: binary64
Cost: 20424

?

\[{\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} \mathbf{if}\;angle \leq -5.5 \cdot 10^{+14}:\\ \;\;\;\;{a}^{2} + \frac{1 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}}\\ \mathbf{elif}\;angle \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;{a}^{2} + {\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\ \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
 (if (<= angle -5.5e+14)
   (+
    (pow a 2.0)
    (/ (- 1.0 (cos (* (* PI angle) 0.011111111111111112))) (/ 2.0 (* b b))))
   (if (<= angle 5.5e-14)
     (+ (pow a 2.0) (* (pow (* PI (* b angle)) 2.0) 3.08641975308642e-5))
     (+
      (pow a 2.0)
      (*
       (/ b (/ 2.0 b))
       (- 1.0 (cos (* angle (* PI 0.011111111111111112)))))))))
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 tmp;
	if (angle <= -5.5e+14) {
		tmp = pow(a, 2.0) + ((1.0 - cos(((((double) M_PI) * angle) * 0.011111111111111112))) / (2.0 / (b * b)));
	} else if (angle <= 5.5e-14) {
		tmp = pow(a, 2.0) + (pow((((double) M_PI) * (b * angle)), 2.0) * 3.08641975308642e-5);
	} else {
		tmp = pow(a, 2.0) + ((b / (2.0 / b)) * (1.0 - cos((angle * (((double) M_PI) * 0.011111111111111112)))));
	}
	return tmp;
}
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 tmp;
	if (angle <= -5.5e+14) {
		tmp = Math.pow(a, 2.0) + ((1.0 - Math.cos(((Math.PI * angle) * 0.011111111111111112))) / (2.0 / (b * b)));
	} else if (angle <= 5.5e-14) {
		tmp = Math.pow(a, 2.0) + (Math.pow((Math.PI * (b * angle)), 2.0) * 3.08641975308642e-5);
	} else {
		tmp = Math.pow(a, 2.0) + ((b / (2.0 / b)) * (1.0 - Math.cos((angle * (Math.PI * 0.011111111111111112)))));
	}
	return tmp;
}
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):
	tmp = 0
	if angle <= -5.5e+14:
		tmp = math.pow(a, 2.0) + ((1.0 - math.cos(((math.pi * angle) * 0.011111111111111112))) / (2.0 / (b * b)))
	elif angle <= 5.5e-14:
		tmp = math.pow(a, 2.0) + (math.pow((math.pi * (b * angle)), 2.0) * 3.08641975308642e-5)
	else:
		tmp = math.pow(a, 2.0) + ((b / (2.0 / b)) * (1.0 - math.cos((angle * (math.pi * 0.011111111111111112)))))
	return tmp
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)
	tmp = 0.0
	if (angle <= -5.5e+14)
		tmp = Float64((a ^ 2.0) + Float64(Float64(1.0 - cos(Float64(Float64(pi * angle) * 0.011111111111111112))) / Float64(2.0 / Float64(b * b))));
	elseif (angle <= 5.5e-14)
		tmp = Float64((a ^ 2.0) + Float64((Float64(pi * Float64(b * angle)) ^ 2.0) * 3.08641975308642e-5));
	else
		tmp = Float64((a ^ 2.0) + Float64(Float64(b / Float64(2.0 / b)) * Float64(1.0 - cos(Float64(angle * Float64(pi * 0.011111111111111112))))));
	end
	return tmp
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_2 = code(a, b, angle)
	tmp = 0.0;
	if (angle <= -5.5e+14)
		tmp = (a ^ 2.0) + ((1.0 - cos(((pi * angle) * 0.011111111111111112))) / (2.0 / (b * b)));
	elseif (angle <= 5.5e-14)
		tmp = (a ^ 2.0) + (((pi * (b * angle)) ^ 2.0) * 3.08641975308642e-5);
	else
		tmp = (a ^ 2.0) + ((b / (2.0 / b)) * (1.0 - cos((angle * (pi * 0.011111111111111112)))));
	end
	tmp_2 = tmp;
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_] := If[LessEqual[angle, -5.5e+14], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[(1.0 - N[Cos[N[(N[(Pi * angle), $MachinePrecision] * 0.011111111111111112), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[angle, 5.5e-14], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[Power[N[(Pi * N[(b * angle), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 2.0], $MachinePrecision] + N[(N[(b / N[(2.0 / b), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Cos[N[(angle * N[(Pi * 0.011111111111111112), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;angle \leq -5.5 \cdot 10^{+14}:\\
\;\;\;\;{a}^{2} + \frac{1 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}}\\

\mathbf{elif}\;angle \leq 5.5 \cdot 10^{-14}:\\
\;\;\;\;{a}^{2} + {\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\

\mathbf{else}:\\
\;\;\;\;{a}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if angle < -5.5e14

    1. Initial program 46.9

      \[{\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 46.2

      \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. Applied egg-rr46.2

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\sin \left(\pi \cdot \left(angle \cdot 0.005555555555555556\right)\right) \cdot b\right)}^{2}\right)\right)} \]
    4. Applied egg-rr46.1

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{\left(b \cdot b\right) \cdot \left(\cos 0 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)}{2}} \]
    5. Simplified46.1

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{1 - \cos \left(\left(angle \cdot \pi\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}}} \]
      Proof

      [Start]46.1

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\left(b \cdot b\right) \cdot \left(\cos 0 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)}{2} \]

      *-commutative [=>]46.1

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\color{blue}{\left(\cos 0 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \cdot \left(b \cdot b\right)}}{2} \]

      associate-/l* [=>]46.1

      \[ {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{\cos 0 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}}} \]

      cos-0 [=>]46.1

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\color{blue}{1} - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}} \]

      *-commutative [=>]46.1

      \[ {\left(a \cdot 1\right)}^{2} + \frac{1 - \cos \left(\color{blue}{\left(angle \cdot \pi\right)} \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}} \]

    if -5.5e14 < angle < 5.49999999999999991e-14

    1. Initial program 0.5

      \[{\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 0.8

      \[\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 0 1.2

      \[\leadsto {\left(a \cdot 1\right)}^{2} + {\color{blue}{\left(0.005555555555555556 \cdot \left(angle \cdot \left(b \cdot \pi\right)\right)\right)}}^{2} \]
    4. Applied egg-rr1.3

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{{\left(b \cdot \left(angle \cdot \pi\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}} \]
    5. Applied egg-rr1.3

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\left({\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 1\right)} \cdot 3.08641975308642 \cdot 10^{-5} \]

    if 5.49999999999999991e-14 < angle

    1. Initial program 42.9

      \[{\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 42.8

      \[\leadsto {\left(a \cdot \color{blue}{1}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. Applied egg-rr43.7

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{\left(b \cdot b\right) \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)}{2}} \]
    4. Simplified43.7

      \[\leadsto {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)} \]
      Proof

      [Start]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\left(b \cdot b\right) \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)}{2} \]

      unpow2 [<=]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\color{blue}{{b}^{2}} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)}{2} \]

      associate-*l/ [<=]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{{b}^{2}}{2} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right)} \]

      unpow2 [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{\color{blue}{b \cdot b}}{2} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \]

      associate-/l* [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \color{blue}{\frac{b}{\frac{2}{b}}} \cdot \left(\cos \left(\left(\pi \cdot angle\right) \cdot 0\right) - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \]

      mul0-rgt [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(\cos \color{blue}{0} - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \]

      cos-0 [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(\color{blue}{1} - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)\right) \]

      *-commutative [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(\color{blue}{\left(angle \cdot \pi\right)} \cdot 0.011111111111111112\right)\right) \]

      associate-*l* [=>]43.7

      \[ {\left(a \cdot 1\right)}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \color{blue}{\left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification21.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;angle \leq -5.5 \cdot 10^{+14}:\\ \;\;\;\;{a}^{2} + \frac{1 - \cos \left(\left(\pi \cdot angle\right) \cdot 0.011111111111111112\right)}{\frac{2}{b \cdot b}}\\ \mathbf{elif}\;angle \leq 5.5 \cdot 10^{-14}:\\ \;\;\;\;{a}^{2} + {\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error20.7
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(\frac{\pi \cdot angle}{180}\right)\right)}^{2} \]
Alternative 2
Error20.6
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)}^{2} \]
Alternative 3
Error21.1
Cost20425
\[\begin{array}{l} \mathbf{if}\;angle \leq -5.5 \cdot 10^{+14} \lor \neg \left(angle \leq 5.5 \cdot 10^{-14}\right):\\ \;\;\;\;{a}^{2} + \frac{b}{\frac{2}{b}} \cdot \left(1 - \cos \left(angle \cdot \left(\pi \cdot 0.011111111111111112\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\ \end{array} \]
Alternative 4
Error24.0
Cost20360
\[\begin{array}{l} \mathbf{if}\;b \leq -3.5 \cdot 10^{+153}:\\ \;\;\;\;{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2}\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-38}:\\ \;\;\;\;{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot \left(angle \cdot \left(angle \cdot \left(b \cdot \left(b \cdot {\pi}^{2}\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{a}^{2} + {\left(b \cdot \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}\\ \end{array} \]
Alternative 5
Error26.6
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(b \cdot \pi\right)\right)}^{2} \]
Alternative 6
Error26.6
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(b \cdot \left(\pi \cdot angle\right)\right)}^{2} \]
Alternative 7
Error26.5
Cost19840
\[{a}^{2} + {\left(b \cdot \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} \]
Alternative 8
Error26.6
Cost19840
\[{a}^{2} + {\left(\pi \cdot \left(b \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5} \]

Error

Reproduce?

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