ab-angle->ABCF A

Percentage Accurate: 79.5% → 79.5%
Time: 5.3s
Alternatives: 12
Speedup: 1.0×

Specification

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

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

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 12 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.5% accurate, 1.0× speedup?

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

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

Alternative 1: 79.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (pow (* a (sin (* (/ angle 180.0) PI))) 2.0)
  (pow (* b (cos (* 0.005555555555555556 (* angle 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((0.005555555555555556 * (angle * ((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((0.005555555555555556 * (angle * 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((0.005555555555555556 * (angle * 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(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((b * cos((0.005555555555555556 * (angle * 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[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[{\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. Taylor expanded in angle around inf

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
  3. Applied rewrites79.5%

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

Alternative 2: 79.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := 0.005555555555555556 \cdot \left(angle \cdot \pi\right)\\
{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2}
\end{array}
\end{array}
Derivation
  1. Initial program 79.5%

    \[{\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. Taylor expanded in angle around inf

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
  3. Applied rewrites79.5%

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} \]
  4. Taylor expanded in angle around inf

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

    \[\leadsto {\left(a \cdot \color{blue}{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
  6. Add Preprocessing

Alternative 3: 79.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;angle \leq 0.00385:\\ \;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot 2\right) \cdot a + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2}\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (if (<= angle 0.00385)
   (+
    (pow (* a (* 0.005555555555555556 (* angle PI))) 2.0)
    (pow (* b 1.0) 2.0))
   (+ (* (* a 2.0) a) (pow (* b (cos (* (/ angle 180.0) PI))) 2.0))))
double code(double a, double b, double angle) {
	double tmp;
	if (angle <= 0.00385) {
		tmp = pow((a * (0.005555555555555556 * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
	} else {
		tmp = ((a * 2.0) * a) + pow((b * cos(((angle / 180.0) * ((double) M_PI)))), 2.0);
	}
	return tmp;
}
public static double code(double a, double b, double angle) {
	double tmp;
	if (angle <= 0.00385) {
		tmp = Math.pow((a * (0.005555555555555556 * (angle * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
	} else {
		tmp = ((a * 2.0) * a) + Math.pow((b * Math.cos(((angle / 180.0) * Math.PI))), 2.0);
	}
	return tmp;
}
def code(a, b, angle):
	tmp = 0
	if angle <= 0.00385:
		tmp = math.pow((a * (0.005555555555555556 * (angle * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
	else:
		tmp = ((a * 2.0) * a) + math.pow((b * math.cos(((angle / 180.0) * math.pi))), 2.0)
	return tmp
function code(a, b, angle)
	tmp = 0.0
	if (angle <= 0.00385)
		tmp = Float64((Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0));
	else
		tmp = Float64(Float64(Float64(a * 2.0) * a) + (Float64(b * cos(Float64(Float64(angle / 180.0) * pi))) ^ 2.0));
	end
	return tmp
end
function tmp_2 = code(a, b, angle)
	tmp = 0.0;
	if (angle <= 0.00385)
		tmp = ((a * (0.005555555555555556 * (angle * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0);
	else
		tmp = ((a * 2.0) * a) + ((b * cos(((angle / 180.0) * pi))) ^ 2.0);
	end
	tmp_2 = tmp;
end
code[a_, b_, angle_] := If[LessEqual[angle, 0.00385], N[(N[Power[N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * 2.0), $MachinePrecision] * a), $MachinePrecision] + N[Power[N[(b * N[Cos[N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;angle \leq 0.00385:\\
\;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if angle < 0.0038500000000000001

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

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

      \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{1}\right)}^{2} \]
    4. Taylor expanded in angle around 0

      \[\leadsto {\left(a \cdot \color{blue}{\left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} + {\left(b \cdot 1\right)}^{2} \]
    5. Applied rewrites74.2%

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

    if 0.0038500000000000001 < angle

    1. Initial program 79.5%

      \[{\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. Applied rewrites56.4%

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

      \[\leadsto \color{blue}{\left(a \cdot 2\right) \cdot a} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 79.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (+ (pow (* a (sin (* (/ angle 180.0) PI))) 2.0) (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
	return pow((a * sin(((angle / 180.0) * ((double) M_PI)))), 2.0) + pow((b * 1.0), 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 * 1.0), 2.0);
}
def code(a, b, angle):
	return math.pow((a * math.sin(((angle / 180.0) * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle)
	return Float64((Float64(a * sin(Float64(Float64(angle / 180.0) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((a * sin(((angle / 180.0) * pi))) ^ 2.0) + ((b * 1.0) ^ 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 * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[{\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. Taylor expanded in angle around 0

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

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

Alternative 5: 79.4% accurate, 1.5× speedup?

\[\begin{array}{l} \\ {\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (pow (* a (sin (* (* 0.005555555555555556 angle) PI))) 2.0)
  (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
	return pow((a * sin(((0.005555555555555556 * angle) * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
	return Math.pow((a * Math.sin(((0.005555555555555556 * angle) * Math.PI))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle):
	return math.pow((a * math.sin(((0.005555555555555556 * angle) * math.pi))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle)
	return Float64((Float64(a * sin(Float64(Float64(0.005555555555555556 * angle) * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((a * sin(((0.005555555555555556 * angle) * pi))) ^ 2.0) + ((b * 1.0) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(0.005555555555555556 * angle), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(a \cdot \sin \left(\left(0.005555555555555556 \cdot angle\right) \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Derivation
  1. Initial program 79.5%

    \[{\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. Taylor expanded in angle around 0

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

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{1}\right)}^{2} \]
  4. Taylor expanded in angle around 0

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

    \[\leadsto {\left(a \cdot \sin \left(\color{blue}{\left(0.005555555555555556 \cdot angle\right)} \cdot \pi\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2} \]
  6. Add Preprocessing

Alternative 6: 76.5% accurate, 1.5× speedup?

\[\begin{array}{l} \\ {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (+
  (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0)
  (pow (* b 1.0) 2.0)))
double code(double a, double b, double angle) {
	return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow((b * 1.0), 2.0);
}
public static double code(double a, double b, double angle) {
	return Math.pow((a * Math.sin((0.005555555555555556 * (angle * Math.PI)))), 2.0) + Math.pow((b * 1.0), 2.0);
}
def code(a, b, angle):
	return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow((b * 1.0), 2.0)
function code(a, b, angle)
	return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0))
end
function tmp = code(a, b, angle)
	tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + ((b * 1.0) ^ 2.0);
end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}
\end{array}
Derivation
  1. Initial program 79.5%

    \[{\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. Taylor expanded in angle around inf

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{\cos \left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} \]
  3. Applied rewrites79.5%

    \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{\cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} \]
  4. Taylor expanded in angle around inf

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

    \[\leadsto {\left(a \cdot \color{blue}{\sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)}\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} \]
  6. Taylor expanded in angle around 0

    \[\leadsto {\left(a \cdot \sin \left(\frac{1}{180} \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot \color{blue}{1}\right)}^{2} \]
  7. Applied rewrites79.4%

    \[\leadsto {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot \color{blue}{1}\right)}^{2} \]
  8. Add Preprocessing

Alternative 7: 76.1% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\ \mathbf{if}\;angle \leq 520000000000:\\ \;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (fma a 2.0 (* b 2.0))))
   (if (<= angle 520000000000.0)
     (+
      (pow (* a (* 0.005555555555555556 (* angle PI))) 2.0)
      (pow (* b 1.0) 2.0))
     (* t_0 t_0))))
double code(double a, double b, double angle) {
	double t_0 = fma(a, 2.0, (b * 2.0));
	double tmp;
	if (angle <= 520000000000.0) {
		tmp = pow((a * (0.005555555555555556 * (angle * ((double) M_PI)))), 2.0) + pow((b * 1.0), 2.0);
	} else {
		tmp = t_0 * t_0;
	}
	return tmp;
}
function code(a, b, angle)
	t_0 = fma(a, 2.0, Float64(b * 2.0))
	tmp = 0.0
	if (angle <= 520000000000.0)
		tmp = Float64((Float64(a * Float64(0.005555555555555556 * Float64(angle * pi))) ^ 2.0) + (Float64(b * 1.0) ^ 2.0));
	else
		tmp = Float64(t_0 * t_0);
	end
	return tmp
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(a * 2.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[angle, 520000000000.0], N[(N[Power[N[(a * N[(0.005555555555555556 * N[(angle * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * 1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\
\mathbf{if}\;angle \leq 520000000000:\\
\;\;\;\;{\left(a \cdot \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot 1\right)}^{2}\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if angle < 5.2e11

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

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

      \[\leadsto {\left(a \cdot \sin \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} + {\left(b \cdot \color{blue}{1}\right)}^{2} \]
    4. Taylor expanded in angle around 0

      \[\leadsto {\left(a \cdot \color{blue}{\left(\frac{1}{180} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right)}\right)}^{2} + {\left(b \cdot 1\right)}^{2} \]
    5. Applied rewrites74.2%

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

    if 5.2e11 < angle

    1. Initial program 79.5%

      \[{\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. Applied rewrites56.4%

      \[\leadsto \color{blue}{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right) \cdot a} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} \]
    3. Applied rewrites49.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 2, b \cdot 2\right) \cdot \mathsf{fma}\left(a, 2, b \cdot 2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 68.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{angle}{180} \cdot \pi\\ \mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 10^{+303}:\\ \;\;\;\;b \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.005555555555555556, {a}^{2} \cdot \left(angle \cdot \pi\right), {b}^{2}\right)\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (* (/ angle 180.0) PI)))
   (if (<= (+ (pow (* a (sin t_0)) 2.0) (pow (* b (cos t_0)) 2.0)) 1e+303)
     (* b b)
     (fma 0.005555555555555556 (* (pow a 2.0) (* angle PI)) (pow b 2.0)))))
double code(double a, double b, double angle) {
	double t_0 = (angle / 180.0) * ((double) M_PI);
	double tmp;
	if ((pow((a * sin(t_0)), 2.0) + pow((b * cos(t_0)), 2.0)) <= 1e+303) {
		tmp = b * b;
	} else {
		tmp = fma(0.005555555555555556, (pow(a, 2.0) * (angle * ((double) M_PI))), pow(b, 2.0));
	}
	return tmp;
}
function code(a, b, angle)
	t_0 = Float64(Float64(angle / 180.0) * pi)
	tmp = 0.0
	if (Float64((Float64(a * sin(t_0)) ^ 2.0) + (Float64(b * cos(t_0)) ^ 2.0)) <= 1e+303)
		tmp = Float64(b * b);
	else
		tmp = fma(0.005555555555555556, Float64((a ^ 2.0) * Float64(angle * pi)), (b ^ 2.0));
	end
	return tmp
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(a * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$0], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 1e+303], N[(b * b), $MachinePrecision], N[(0.005555555555555556 * N[(N[Power[a, 2.0], $MachinePrecision] * N[(angle * Pi), $MachinePrecision]), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 10^{+303}:\\
\;\;\;\;b \cdot b\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.005555555555555556, {a}^{2} \cdot \left(angle \cdot \pi\right), {b}^{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 1e303

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{b}^{2}} \]
    3. Applied rewrites57.3%

      \[\leadsto \color{blue}{{b}^{2}} \]
    4. Applied rewrites3.9%

      \[\leadsto \color{blue}{b} \]
    5. Applied rewrites57.3%

      \[\leadsto b \cdot \color{blue}{b} \]

    if 1e303 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)))

    1. Initial program 79.5%

      \[{\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. Applied rewrites56.4%

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

      \[\leadsto \color{blue}{\frac{1}{180} \cdot \left({a}^{2} \cdot \left(angle \cdot \mathsf{PI}\left(\right)\right)\right) + {b}^{2}} \]
    4. Applied rewrites52.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.005555555555555556, {a}^{2} \cdot \left(angle \cdot \pi\right), {b}^{2}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 59.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\ t_1 := \frac{angle}{180} \cdot \pi\\ \mathbf{if}\;{\left(a \cdot \sin t\_1\right)}^{2} + {\left(b \cdot \cos t\_1\right)}^{2} \leq 4 \cdot 10^{+306}:\\ \;\;\;\;b \cdot b\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot t\_0\\ \end{array} \end{array} \]
(FPCore (a b angle)
 :precision binary64
 (let* ((t_0 (fma a 2.0 (* b 2.0))) (t_1 (* (/ angle 180.0) PI)))
   (if (<= (+ (pow (* a (sin t_1)) 2.0) (pow (* b (cos t_1)) 2.0)) 4e+306)
     (* b b)
     (* t_0 t_0))))
double code(double a, double b, double angle) {
	double t_0 = fma(a, 2.0, (b * 2.0));
	double t_1 = (angle / 180.0) * ((double) M_PI);
	double tmp;
	if ((pow((a * sin(t_1)), 2.0) + pow((b * cos(t_1)), 2.0)) <= 4e+306) {
		tmp = b * b;
	} else {
		tmp = t_0 * t_0;
	}
	return tmp;
}
function code(a, b, angle)
	t_0 = fma(a, 2.0, Float64(b * 2.0))
	t_1 = Float64(Float64(angle / 180.0) * pi)
	tmp = 0.0
	if (Float64((Float64(a * sin(t_1)) ^ 2.0) + (Float64(b * cos(t_1)) ^ 2.0)) <= 4e+306)
		tmp = Float64(b * b);
	else
		tmp = Float64(t_0 * t_0);
	end
	return tmp
end
code[a_, b_, angle_] := Block[{t$95$0 = N[(a * 2.0 + N[(b * 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(angle / 180.0), $MachinePrecision] * Pi), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[(a * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 4e+306], N[(b * b), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, 2, b \cdot 2\right)\\
t_1 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_1\right)}^{2} + {\left(b \cdot \cos t\_1\right)}^{2} \leq 4 \cdot 10^{+306}:\\
\;\;\;\;b \cdot b\\

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 4.00000000000000007e306

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{b}^{2}} \]
    3. Applied rewrites57.3%

      \[\leadsto \color{blue}{{b}^{2}} \]
    4. Applied rewrites3.9%

      \[\leadsto \color{blue}{b} \]
    5. Applied rewrites57.3%

      \[\leadsto b \cdot \color{blue}{b} \]

    if 4.00000000000000007e306 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)))

    1. Initial program 79.5%

      \[{\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. Applied rewrites56.4%

      \[\leadsto \color{blue}{\left(a \cdot \sin \left(\frac{angle \cdot \pi}{180}\right)\right) \cdot a} + {\left(b \cdot \cos \left(\frac{angle}{180} \cdot \pi\right)\right)}^{2} \]
    3. Applied rewrites49.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 2, b \cdot 2\right) \cdot \mathsf{fma}\left(a, 2, b \cdot 2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 58.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{angle}{180} \cdot \pi\\
\mathbf{if}\;{\left(a \cdot \sin t\_0\right)}^{2} + {\left(b \cdot \cos t\_0\right)}^{2} \leq 5 \cdot 10^{+307}:\\
\;\;\;\;b \cdot b\\

\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64))) < 5e307

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{b}^{2}} \]
    3. Applied rewrites57.3%

      \[\leadsto \color{blue}{{b}^{2}} \]
    4. Applied rewrites3.9%

      \[\leadsto \color{blue}{b} \]
    5. Applied rewrites57.3%

      \[\leadsto b \cdot \color{blue}{b} \]

    if 5e307 < (+.f64 (pow.f64 (*.f64 a (sin.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)) (pow.f64 (*.f64 b (cos.f64 (*.f64 (/.f64 angle #s(literal 180 binary64)) (PI.f64)))) #s(literal 2 binary64)))

    1. Initial program 79.5%

      \[{\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. Taylor expanded in angle around 0

      \[\leadsto \color{blue}{{b}^{2}} \]
    3. Applied rewrites57.3%

      \[\leadsto \color{blue}{{b}^{2}} \]
    4. Applied rewrites3.9%

      \[\leadsto \color{blue}{b} \]
    5. Applied rewrites57.3%

      \[\leadsto b \cdot \color{blue}{b} \]
    6. Applied rewrites24.8%

      \[\leadsto \left(b \cdot b\right) \cdot b \]
    7. Applied rewrites39.4%

      \[\leadsto \left(b \cdot b\right) \cdot \left(b \cdot \color{blue}{b}\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 57.3% accurate, 29.7× speedup?

\[\begin{array}{l} \\ b \cdot b \end{array} \]
(FPCore (a b angle) :precision binary64 (* b b))
double code(double a, double b, double angle) {
	return b * b;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, angle)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    code = b * b
end function
public static double code(double a, double b, double angle) {
	return b * b;
}
def code(a, b, angle):
	return b * b
function code(a, b, angle)
	return Float64(b * b)
end
function tmp = code(a, b, angle)
	tmp = b * b;
end
code[a_, b_, angle_] := N[(b * b), $MachinePrecision]
\begin{array}{l}

\\
b \cdot b
\end{array}
Derivation
  1. Initial program 79.5%

    \[{\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. Taylor expanded in angle around 0

    \[\leadsto \color{blue}{{b}^{2}} \]
  3. Applied rewrites57.3%

    \[\leadsto \color{blue}{{b}^{2}} \]
  4. Applied rewrites3.9%

    \[\leadsto \color{blue}{b} \]
  5. Applied rewrites57.3%

    \[\leadsto b \cdot \color{blue}{b} \]
  6. Add Preprocessing

Alternative 12: 3.9% accurate, 117.6× speedup?

\[\begin{array}{l} \\ b \end{array} \]
(FPCore (a b angle) :precision binary64 b)
double code(double a, double b, double angle) {
	return b;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, angle)
use fmin_fmax_functions
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: angle
    code = b
end function
public static double code(double a, double b, double angle) {
	return b;
}
def code(a, b, angle):
	return b
function code(a, b, angle)
	return b
end
function tmp = code(a, b, angle)
	tmp = b;
end
code[a_, b_, angle_] := b
\begin{array}{l}

\\
b
\end{array}
Derivation
  1. Initial program 79.5%

    \[{\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. Taylor expanded in angle around 0

    \[\leadsto \color{blue}{{b}^{2}} \]
  3. Applied rewrites57.3%

    \[\leadsto \color{blue}{{b}^{2}} \]
  4. Applied rewrites3.9%

    \[\leadsto \color{blue}{b} \]
  5. Add Preprocessing

Reproduce

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