ab-angle->ABCF C

Percentage Accurate: 79.6% → 79.5%
Time: 18.3s
Alternatives: 14
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \frac{angle}{180}\\ {\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2} \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* PI (/ angle 180.0))))
   (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 79.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \pi \cdot \frac{angle}{180}\\ {\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2} \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* PI (/ angle 180.0))))
   (+ (pow (* a (cos t_0)) 2.0) (pow (* b (sin t_0)) 2.0))))
double code(double a, double b, double angle) {
	double t_0 = ((double) M_PI) * (angle / 180.0);
	return pow((a * cos(t_0)), 2.0) + pow((b * sin(t_0)), 2.0);
}
public static double code(double a, double b, double angle) {
	double t_0 = Math.PI * (angle / 180.0);
	return Math.pow((a * Math.cos(t_0)), 2.0) + Math.pow((b * Math.sin(t_0)), 2.0);
}
def code(a, b, angle):
	t_0 = math.pi * (angle / 180.0)
	return math.pow((a * math.cos(t_0)), 2.0) + math.pow((b * math.sin(t_0)), 2.0)
function code(a, b, angle)
	t_0 = Float64(pi * Float64(angle / 180.0))
	return Float64((Float64(a * cos(t_0)) ^ 2.0) + (Float64(b * sin(t_0)) ^ 2.0))
end
function tmp = code(a, b, angle)
	t_0 = pi * (angle / 180.0);
	tmp = ((a * cos(t_0)) ^ 2.0) + ((b * sin(t_0)) ^ 2.0);
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(Pi * N[(angle / 180.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[N[(a * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \pi \cdot \frac{angle}{180}\\
{\left(a \cdot \cos t\_0\right)}^{2} + {\left(b \cdot \sin t\_0\right)}^{2}
\end{array}
\end{array}

Alternative 1: 79.5% accurate, 0.7× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot e^{\log \left(\sqrt{\pi} \cdot angle\_m\right)}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (pow
   (* a (cos (* (/ (sqrt PI) 180.0) (exp (log (* (sqrt PI) angle_m))))))
   2.0)
  (pow (* b (sin (* PI (/ angle_m 180.0)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return pow((a * cos(((sqrt(((double) M_PI)) / 180.0) * exp(log((sqrt(((double) M_PI)) * angle_m)))))), 2.0) + pow((b * sin((((double) M_PI) * (angle_m / 180.0)))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return Math.pow((a * Math.cos(((Math.sqrt(Math.PI) / 180.0) * Math.exp(Math.log((Math.sqrt(Math.PI) * angle_m)))))), 2.0) + Math.pow((b * Math.sin((Math.PI * (angle_m / 180.0)))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return math.pow((a * math.cos(((math.sqrt(math.pi) / 180.0) * math.exp(math.log((math.sqrt(math.pi) * angle_m)))))), 2.0) + math.pow((b * math.sin((math.pi * (angle_m / 180.0)))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64((Float64(a * cos(Float64(Float64(sqrt(pi) / 180.0) * exp(log(Float64(sqrt(pi) * angle_m)))))) ^ 2.0) + (Float64(b * sin(Float64(pi * Float64(angle_m / 180.0)))) ^ 2.0))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = ((a * cos(((sqrt(pi) / 180.0) * exp(log((sqrt(pi) * angle_m)))))) ^ 2.0) + ((b * sin((pi * (angle_m / 180.0)))) ^ 2.0);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Cos[N[(N[(N[Sqrt[Pi], $MachinePrecision] / 180.0), $MachinePrecision] * N[Exp[N[Log[N[(N[Sqrt[Pi], $MachinePrecision] * angle$95$m), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
{\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot e^{\log \left(\sqrt{\pi} \cdot angle\_m\right)}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 82.3%

    \[{\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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. clear-numN/A

      \[\leadsto {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{\frac{180}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. un-div-invN/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{\frac{180}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{\frac{180}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    5. add-sqr-sqrtN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}}}{\frac{180}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. div-invN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}}{\color{blue}{180 \cdot \frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    7. times-fracN/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    8. lower-*.f64N/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{180}} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    10. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    11. lower-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    12. lower-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    13. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    14. lower-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    15. lower-/.f6482.3

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

    \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  5. Step-by-step derivation
    1. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. lift-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. lift-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\color{blue}{\frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. clear-numN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{\frac{1}{\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    5. inv-powN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{{\left(\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}\right)}^{-1}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. pow-to-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{e^{\log \left(\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}\right) \cdot -1}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    7. lower-exp.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{e^{\log \left(\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}\right) \cdot -1}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    8. lower-*.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\color{blue}{\log \left(\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}\right) \cdot -1}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-log.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\color{blue}{\log \left(\frac{\frac{1}{angle}}{\sqrt{\mathsf{PI}\left(\right)}}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    10. clear-numN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left(\frac{1}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    11. lift-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    12. lower-/.f6482.4

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot e^{\log \color{blue}{\left(\frac{1}{\frac{\sqrt{\pi}}{\frac{1}{angle}}}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
    13. lift-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    14. lift-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\color{blue}{\frac{1}{angle}}}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    15. associate-/r/N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{1} \cdot angle}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    16. /-rgt-identityN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}} \cdot angle}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    17. lower-*.f6482.4

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\sqrt{\pi} \cdot angle}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  6. Applied egg-rr82.4%

    \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \color{blue}{e^{\log \left(\frac{1}{\sqrt{\pi} \cdot angle}\right) \cdot -1}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  7. Step-by-step derivation
    1. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}} \cdot angle}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. lift-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}} \cdot angle}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. lift-*.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{\sqrt{\mathsf{PI}\left(\right)} \cdot angle}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. unpow1N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left(\frac{1}{\color{blue}{{\left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}^{1}}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    5. pow-flipN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left({\left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}^{\left(\mathsf{neg}\left(1\right)\right)}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. metadata-evalN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \left({\left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}^{\color{blue}{-1}}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    7. pow-to-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left(e^{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right) \cdot -1}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    8. pow-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left({\left(e^{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}\right)}^{-1}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. inv-powN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left(\frac{1}{e^{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    10. log-divN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\color{blue}{\left(\log 1 - \log \left(e^{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}\right)\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    11. rem-log-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\left(\log 1 - \color{blue}{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}\right) \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    12. log-divN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\color{blue}{\log \left(\frac{1}{\sqrt{\mathsf{PI}\left(\right)} \cdot angle}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    13. inv-powN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left({\left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right)}^{-1}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    14. pow-to-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\log \color{blue}{\left(e^{\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right) \cdot -1}\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    15. rem-log-expN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot e^{\color{blue}{\left(\log \left(\sqrt{\mathsf{PI}\left(\right)} \cdot angle\right) \cdot -1\right)} \cdot -1}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
  8. Applied egg-rr82.4%

    \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \color{blue}{e^{\log \left(\sqrt{\pi} \cdot angle\right)}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  9. Add Preprocessing

Alternative 2: 79.5% accurate, 0.9× speedup?

\[\begin{array}{l} angle_m = \left|angle\right| \\ {\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\frac{1}{angle\_m}}\right)\right)}^{2} \end{array} \]
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
 :precision binary64
 (+
  (pow (* b (sin (* PI (/ angle_m 180.0)))) 2.0)
  (pow (* a (cos (* (/ (sqrt PI) 180.0) (/ (sqrt PI) (/ 1.0 angle_m))))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
	return pow((b * sin((((double) M_PI) * (angle_m / 180.0)))), 2.0) + pow((a * cos(((sqrt(((double) M_PI)) / 180.0) * (sqrt(((double) M_PI)) / (1.0 / angle_m))))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
	return Math.pow((b * Math.sin((Math.PI * (angle_m / 180.0)))), 2.0) + Math.pow((a * Math.cos(((Math.sqrt(Math.PI) / 180.0) * (Math.sqrt(Math.PI) / (1.0 / angle_m))))), 2.0);
}
angle_m = math.fabs(angle)
def code(a, b, angle_m):
	return math.pow((b * math.sin((math.pi * (angle_m / 180.0)))), 2.0) + math.pow((a * math.cos(((math.sqrt(math.pi) / 180.0) * (math.sqrt(math.pi) / (1.0 / angle_m))))), 2.0)
angle_m = abs(angle)
function code(a, b, angle_m)
	return Float64((Float64(b * sin(Float64(pi * Float64(angle_m / 180.0)))) ^ 2.0) + (Float64(a * cos(Float64(Float64(sqrt(pi) / 180.0) * Float64(sqrt(pi) / Float64(1.0 / angle_m))))) ^ 2.0))
end
angle_m = abs(angle);
function tmp = code(a, b, angle_m)
	tmp = ((b * sin((pi * (angle_m / 180.0)))) ^ 2.0) + ((a * cos(((sqrt(pi) / 180.0) * (sqrt(pi) / (1.0 / angle_m))))) ^ 2.0);
end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := N[(N[Power[N[(b * N[Sin[N[(Pi * N[(angle$95$m / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(a * N[Cos[N[(N[(N[Sqrt[Pi], $MachinePrecision] / 180.0), $MachinePrecision] * N[(N[Sqrt[Pi], $MachinePrecision] / N[(1.0 / angle$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|

\\
{\left(b \cdot \sin \left(\pi \cdot \frac{angle\_m}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\frac{1}{angle\_m}}\right)\right)}^{2}
\end{array}
Derivation
  1. Initial program 79.6%

    \[{\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. Add Preprocessing
  3. Step-by-step derivation
    1. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\color{blue}{\mathsf{PI}\left(\right)} \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    2. clear-numN/A

      \[\leadsto {\left(a \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\frac{1}{\frac{180}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    3. un-div-invN/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\mathsf{PI}\left(\right)}{\frac{180}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    4. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\mathsf{PI}\left(\right)}}{\frac{180}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    5. add-sqr-sqrtN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}}}{\frac{180}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    6. div-invN/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)} \cdot \sqrt{\mathsf{PI}\left(\right)}}{\color{blue}{180 \cdot \frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    7. times-fracN/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    8. lower-*.f64N/A

      \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    9. lower-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{180}} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    10. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    11. lower-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}{180} \cdot \frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    12. lower-/.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \color{blue}{\frac{\sqrt{\mathsf{PI}\left(\right)}}{\frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    13. lift-PI.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\sqrt{\color{blue}{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    14. lower-sqrt.f64N/A

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\mathsf{PI}\left(\right)}}{180} \cdot \frac{\color{blue}{\sqrt{\mathsf{PI}\left(\right)}}}{\frac{1}{angle}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \frac{angle}{180}\right)\right)}^{2} \]
    15. lower-/.f6479.5

      \[\leadsto {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\color{blue}{\frac{1}{angle}}}\right)\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  4. Applied egg-rr79.5%

    \[\leadsto {\left(a \cdot \cos \color{blue}{\left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\frac{1}{angle}}\right)}\right)}^{2} + {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} \]
  5. Final simplification79.5%

    \[\leadsto {\left(b \cdot \sin \left(\pi \cdot \frac{angle}{180}\right)\right)}^{2} + {\left(a \cdot \cos \left(\frac{\sqrt{\pi}}{180} \cdot \frac{\sqrt{\pi}}{\frac{1}{angle}}\right)\right)}^{2} \]
  6. Add Preprocessing

Reproduce

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