Average Error: 19.8 → 19.8
Time: 14.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 := 1 + 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\ {\left(a \cdot \mathsf{fma}\left(\cos t_0, \cos 1, \sin t_0 \cdot \sin 1\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\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 (+ 1.0 (* 0.005555555555555556 (* angle PI)))))
   (+
    (pow (* a (fma (cos t_0) (cos 1.0) (* (sin t_0) (sin 1.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) {
	double t_0 = 1.0 + (0.005555555555555556 * (angle * ((double) M_PI)));
	return pow((a * fma(cos(t_0), cos(1.0), (sin(t_0) * sin(1.0)))), 2.0) + pow((b * sin((((double) M_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)
	t_0 = Float64(1.0 + Float64(0.005555555555555556 * Float64(angle * pi)))
	return Float64((Float64(a * fma(cos(t_0), cos(1.0), Float64(sin(t_0) * sin(1.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_] := Block[{t$95$0 = N[(1.0 + N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[(N[Cos[t$95$0], $MachinePrecision] * N[Cos[1.0], $MachinePrecision] + N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[1.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]]
{\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 := 1 + 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
{\left(a \cdot \mathsf{fma}\left(\cos t_0, \cos 1, \sin t_0 \cdot \sin 1\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2}
\end{array}

Error

Derivation

  1. Initial program 19.8

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

    \[\leadsto {\left(a \cdot \cos \color{blue}{\left(e^{\left(3 \cdot \log \left(\left(\pi \cdot angle\right) \cdot 0.005555555555555556\right)\right) \cdot 0.3333333333333333}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  3. Applied egg-rr23.8

    \[\leadsto {\left(a \cdot \color{blue}{\left(\cos \left(e^{\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}\right) \cdot \cos 1 + \sin \left(e^{\mathsf{log1p}\left(angle \cdot \left(\pi \cdot 0.005555555555555556\right)\right)}\right) \cdot \sin 1\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Simplified19.8

    \[\leadsto {\left(a \cdot \color{blue}{\mathsf{fma}\left(\cos \left(1 + 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right), \cos 1, \sin \left(1 + 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right) \cdot \sin 1\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    Proof
    (fma.f64 (cos.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (*.f64 1/180 (Rewrite<= *-commutative_binary64 (*.f64 (PI.f64) angle))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 (PI.f64) angle) 1/180)))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (*.f64 (Rewrite=> *-commutative_binary64 (*.f64 angle (PI.f64))) 1/180))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite<= associate-*r*_binary64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 14 points increase in error, 15 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 76 points increase in error, 28 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) 1)))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 5 points increase in error, 1 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite=> sub-neg_binary64 (+.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) (neg.f64 1))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (+.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) (Rewrite=> metadata-eval -1)))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 1 (Rewrite=> +-commutative_binary64 (+.f64 -1 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (Rewrite=> associate-+r+_binary64 (+.f64 (+.f64 1 -1) (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (+.f64 (Rewrite=> metadata-eval 0) (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (Rewrite=> +-lft-identity_binary64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (*.f64 angle (PI.f64))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 1/180 (Rewrite<= *-commutative_binary64 (*.f64 (PI.f64) angle))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 (PI.f64) angle) 1/180)))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (*.f64 (Rewrite=> *-commutative_binary64 (*.f64 angle (PI.f64))) 1/180))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite<= associate-*r*_binary64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (sin.f64 1))): 5 points increase in error, 8 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite<= expm1-log1p_binary64 (expm1.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))))) (sin.f64 1))): 33 points increase in error, 25 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite<= expm1-def_binary64 (-.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) 1)))) (sin.f64 1))): 4 points increase in error, 2 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite=> sub-neg_binary64 (+.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) (neg.f64 1))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (+.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))) (Rewrite=> metadata-eval -1)))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 1 (Rewrite=> +-commutative_binary64 (+.f64 -1 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (Rewrite=> associate-+r+_binary64 (+.f64 (+.f64 1 -1) (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (+.f64 (Rewrite=> metadata-eval 0) (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (fma.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1) (*.f64 (sin.f64 (Rewrite=> +-lft-identity_binary64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180)))))) (sin.f64 1))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (cos.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (cos.f64 1)) (*.f64 (sin.f64 (exp.f64 (log1p.f64 (*.f64 angle (*.f64 (PI.f64) 1/180))))) (sin.f64 1)))): 9 points increase in error, 8 points decrease in error
  5. Final simplification19.8

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

Alternatives

Alternative 1
Error19.9
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
Alternative 2
Error19.9
Cost26240
\[{a}^{2} + {\left(b \cdot \sin \left(\pi \cdot \left(0.005555555555555556 \cdot angle\right)\right)\right)}^{2} \]
Alternative 3
Error19.9
Cost26240
\[{\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {a}^{2} \]
Alternative 4
Error22.4
Cost20360
\[\begin{array}{l} t_0 := {a}^{2} + {\left(angle \cdot \left(\left(1 + \pi \cdot b\right) + -1\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\\ \mathbf{if}\;angle \leq -1.9 \cdot 10^{+43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;angle \leq 32:\\ \;\;\;\;{a}^{2} + {\left(angle \cdot \left(b \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error23.4
Cost20096
\[{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(\left(1 + \pi \cdot b\right) + -1\right)\right)\right)}^{2} \]
Alternative 6
Error25.5
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(\pi \cdot b\right)\right)}^{2} \]
Alternative 7
Error25.4
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(\left(angle \cdot \pi\right) \cdot b\right)}^{2} \]
Alternative 8
Error25.4
Cost19840
\[{a}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(\pi \cdot \left(angle \cdot b\right)\right)}^{2} \]
Alternative 9
Error25.4
Cost19840
\[{a}^{2} + {\left(0.005555555555555556 \cdot \left(angle \cdot \left(\pi \cdot b\right)\right)\right)}^{2} \]
Alternative 10
Error25.4
Cost19840
\[{a}^{2} + {\left(angle \cdot \left(0.005555555555555556 \cdot \left(\pi \cdot b\right)\right)\right)}^{2} \]
Alternative 11
Error25.3
Cost19840
\[{a}^{2} + {\left(angle \cdot \left(b \cdot \left(0.005555555555555556 \cdot \pi\right)\right)\right)}^{2} \]

Error

Reproduce

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