
(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}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow (* b (cos (* 0.005555555555555556 (pow (sqrt (* angle PI)) 2.0)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow((b * cos((0.005555555555555556 * pow(sqrt((angle * ((double) M_PI))), 2.0)))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow((b * Math.cos((0.005555555555555556 * Math.pow(Math.sqrt((angle * Math.PI)), 2.0)))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow((b * math.cos((0.005555555555555556 * math.pow(math.sqrt((angle * math.pi)), 2.0)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(b * cos(Float64(0.005555555555555556 * (sqrt(Float64(angle * pi)) ^ 2.0)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = ((a * sin((angle * (pi / 180.0)))) ^ 2.0) + ((b * cos((0.005555555555555556 * (sqrt((angle * pi)) ^ 2.0)))) ^ 2.0); end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(0.005555555555555556 * N[Power[N[Sqrt[N[(angle * Pi), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot {\left(\sqrt{angle \cdot \pi}\right)}^{2}\right)\right)}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around inf 84.1%
add-sqr-sqrt35.8%
pow235.8%
Applied egg-rr35.8%
Final simplification35.8%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow (* b (cos (* 0.005555555555555556 (pow (cbrt (* angle PI)) 3.0)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow((b * cos((0.005555555555555556 * pow(cbrt((angle * ((double) M_PI))), 3.0)))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow((b * Math.cos((0.005555555555555556 * Math.pow(Math.cbrt((angle * Math.PI)), 3.0)))), 2.0);
}
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(b * cos(Float64(0.005555555555555556 * (cbrt(Float64(angle * pi)) ^ 3.0)))) ^ 2.0)) end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(b * N[Cos[N[(0.005555555555555556 * N[Power[N[Power[N[(angle * Pi), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot {\left(\sqrt[3]{angle \cdot \pi}\right)}^{3}\right)\right)}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around inf 84.1%
add-cube-cbrt84.1%
pow384.1%
Applied egg-rr84.1%
Final simplification84.1%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (pow (* b (cos (* angle (/ PI 180.0)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow((b * cos((angle * (((double) M_PI) / 180.0)))), 2.0);
}
angle = Math.abs(angle);
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 * Math.cos((angle * (Math.PI / 180.0)))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow((b * math.cos((angle * (math.pi / 180.0)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (Float64(b * cos(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + ((b * cos((angle * (pi / 180.0)))) ^ 2.0); end
NOTE: angle should be positive before calling this function 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 * N[Cos[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {\left(b \cdot \cos \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around inf 84.1%
Final simplification84.1%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* angle (/ PI 180.0)))) 2.0) (pow (* b (cos (* 0.005555555555555556 (* angle PI)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0) + pow((b * cos((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0);
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0) + Math.pow((b * Math.cos((0.005555555555555556 * (angle * Math.PI)))), 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0) + math.pow((b * math.cos((0.005555555555555556 * (angle * math.pi)))), 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0) + (Float64(b * cos(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = ((a * sin((angle * (pi / 180.0)))) ^ 2.0) + ((b * cos((0.005555555555555556 * (angle * pi)))) ^ 2.0); end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $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}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2} + {\left(b \cdot \cos \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around inf 84.1%
Final simplification84.1%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (* 0.005555555555555556 (* angle PI)))) 2.0) (pow b 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow((a * sin((0.005555555555555556 * (angle * ((double) M_PI))))), 2.0) + pow(b, 2.0);
}
angle = Math.abs(angle);
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, 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow((a * math.sin((0.005555555555555556 * (angle * math.pi)))), 2.0) + math.pow(b, 2.0)
angle = abs(angle) function code(a, b, angle) return Float64((Float64(a * sin(Float64(0.005555555555555556 * Float64(angle * pi)))) ^ 2.0) + (b ^ 2.0)) end
angle = abs(angle) function tmp = code(a, b, angle) tmp = ((a * sin((0.005555555555555556 * (angle * pi)))) ^ 2.0) + (b ^ 2.0); end
NOTE: angle should be positive before calling this function 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[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(angle \cdot \pi\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around 0 83.6%
Taylor expanded in angle around 0 83.6%
Final simplification83.6%
NOTE: angle should be positive before calling this function
(FPCore (a b angle)
:precision binary64
(if (<= a 4.6e-29)
(pow b 2.0)
(+
(pow b 2.0)
(* (* PI (* (* angle (* a PI)) (* a angle))) 3.08641975308642e-5))))angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 4.6e-29) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((((double) M_PI) * ((angle * (a * ((double) M_PI))) * (a * angle))) * 3.08641975308642e-5);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 4.6e-29) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((Math.PI * ((angle * (a * Math.PI)) * (a * angle))) * 3.08641975308642e-5);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 4.6e-29: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((math.pi * ((angle * (a * math.pi)) * (a * angle))) * 3.08641975308642e-5) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 4.6e-29) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(pi * Float64(Float64(angle * Float64(a * pi)) * Float64(a * angle))) * 3.08641975308642e-5)); end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 4.6e-29) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((pi * ((angle * (a * pi)) * (a * angle))) * 3.08641975308642e-5); end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 4.6e-29], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(Pi * N[(N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision] * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.6 \cdot 10^{-29}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(\pi \cdot \left(\left(angle \cdot \left(a \cdot \pi\right)\right) \cdot \left(a \cdot angle\right)\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\\
\end{array}
\end{array}
if a < 4.59999999999999982e-29Initial program 83.2%
unpow283.2%
swap-sqr83.2%
associate-*l/83.2%
associate-*r/83.3%
swap-sqr83.3%
unpow283.3%
associate-*l/83.2%
associate-*r/83.3%
Simplified83.3%
Taylor expanded in angle around 0 82.6%
Taylor expanded in angle around 0 76.4%
*-commutative76.4%
associate-*l*76.4%
Simplified76.4%
*-commutative76.4%
unpow-prod-down76.4%
associate-*r*76.5%
*-commutative76.5%
associate-*l*76.4%
metadata-eval76.4%
Applied egg-rr76.4%
Taylor expanded in angle around 0 68.6%
if 4.59999999999999982e-29 < a Initial program 85.6%
unpow285.6%
swap-sqr85.6%
associate-*l/85.8%
associate-*r/85.9%
swap-sqr85.9%
unpow285.9%
associate-*l/85.9%
associate-*r/86.0%
Simplified86.0%
Taylor expanded in angle around 0 86.0%
Taylor expanded in angle around 0 83.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
*-commutative83.3%
unpow-prod-down83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
metadata-eval83.4%
Applied egg-rr83.4%
unpow283.4%
*-commutative83.4%
associate-*r*83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
Applied egg-rr83.4%
Final simplification73.0%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1.05e-30) (pow b 2.0) (+ (pow b 2.0) (* 3.08641975308642e-5 (pow (* PI (* a angle)) 2.0)))))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e-30) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (3.08641975308642e-5 * pow((((double) M_PI) * (a * angle)), 2.0));
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.05e-30) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (3.08641975308642e-5 * Math.pow((Math.PI * (a * angle)), 2.0));
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 1.05e-30: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (3.08641975308642e-5 * math.pow((math.pi * (a * angle)), 2.0)) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1.05e-30) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(3.08641975308642e-5 * (Float64(pi * Float64(a * angle)) ^ 2.0))); end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.05e-30) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (3.08641975308642e-5 * ((pi * (a * angle)) ^ 2.0)); end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1.05e-30], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(3.08641975308642e-5 * N[Power[N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.05 \cdot 10^{-30}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + 3.08641975308642 \cdot 10^{-5} \cdot {\left(\pi \cdot \left(a \cdot angle\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 1.0500000000000001e-30Initial program 83.2%
unpow283.2%
swap-sqr83.2%
associate-*l/83.2%
associate-*r/83.3%
swap-sqr83.3%
unpow283.3%
associate-*l/83.2%
associate-*r/83.3%
Simplified83.3%
Taylor expanded in angle around 0 82.6%
Taylor expanded in angle around 0 76.4%
*-commutative76.4%
associate-*l*76.4%
Simplified76.4%
*-commutative76.4%
unpow-prod-down76.4%
associate-*r*76.5%
*-commutative76.5%
associate-*l*76.4%
metadata-eval76.4%
Applied egg-rr76.4%
Taylor expanded in angle around 0 68.6%
if 1.0500000000000001e-30 < a Initial program 85.6%
unpow285.6%
swap-sqr85.6%
associate-*l/85.8%
associate-*r/85.9%
swap-sqr85.9%
unpow285.9%
associate-*l/85.9%
associate-*r/86.0%
Simplified86.0%
Taylor expanded in angle around 0 86.0%
Taylor expanded in angle around 0 83.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
*-commutative83.3%
unpow-prod-down83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
metadata-eval83.4%
Applied egg-rr83.4%
Final simplification73.0%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 1.35e-29) (pow b 2.0) (fma b b (* 3.08641975308642e-5 (pow (* angle (* a PI)) 2.0)))))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.35e-29) {
tmp = pow(b, 2.0);
} else {
tmp = fma(b, b, (3.08641975308642e-5 * pow((angle * (a * ((double) M_PI))), 2.0)));
}
return tmp;
}
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 1.35e-29) tmp = b ^ 2.0; else tmp = fma(b, b, Float64(3.08641975308642e-5 * (Float64(angle * Float64(a * pi)) ^ 2.0))); end return tmp end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 1.35e-29], N[Power[b, 2.0], $MachinePrecision], N[(b * b + N[(3.08641975308642e-5 * N[Power[N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.35 \cdot 10^{-29}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, b, 3.08641975308642 \cdot 10^{-5} \cdot {\left(angle \cdot \left(a \cdot \pi\right)\right)}^{2}\right)\\
\end{array}
\end{array}
if a < 1.35000000000000011e-29Initial program 83.2%
unpow283.2%
swap-sqr83.2%
associate-*l/83.2%
associate-*r/83.3%
swap-sqr83.3%
unpow283.3%
associate-*l/83.2%
associate-*r/83.3%
Simplified83.3%
Taylor expanded in angle around 0 82.6%
Taylor expanded in angle around 0 76.4%
*-commutative76.4%
associate-*l*76.4%
Simplified76.4%
*-commutative76.4%
unpow-prod-down76.4%
associate-*r*76.5%
*-commutative76.5%
associate-*l*76.4%
metadata-eval76.4%
Applied egg-rr76.4%
Taylor expanded in angle around 0 68.6%
if 1.35000000000000011e-29 < a Initial program 85.6%
unpow285.6%
swap-sqr85.6%
associate-*l/85.8%
associate-*r/85.9%
swap-sqr85.9%
unpow285.9%
associate-*l/85.9%
associate-*r/86.0%
Simplified86.0%
Taylor expanded in angle around 0 86.0%
Taylor expanded in angle around 0 83.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
*-commutative83.3%
unpow-prod-down83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
metadata-eval83.4%
Applied egg-rr83.4%
+-commutative83.4%
*-rgt-identity83.4%
pow283.4%
fma-def83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
Applied egg-rr83.4%
Final simplification73.0%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (if (<= a 8e-31) (pow b 2.0) (pow (hypot b (* 0.005555555555555556 (* angle (* a PI)))) 2.0)))
angle = abs(angle);
double code(double a, double b, double angle) {
double tmp;
if (a <= 8e-31) {
tmp = pow(b, 2.0);
} else {
tmp = pow(hypot(b, (0.005555555555555556 * (angle * (a * ((double) M_PI))))), 2.0);
}
return tmp;
}
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 8e-31) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(Math.hypot(b, (0.005555555555555556 * (angle * (a * Math.PI)))), 2.0);
}
return tmp;
}
angle = abs(angle) def code(a, b, angle): tmp = 0 if a <= 8e-31: tmp = math.pow(b, 2.0) else: tmp = math.pow(math.hypot(b, (0.005555555555555556 * (angle * (a * math.pi)))), 2.0) return tmp
angle = abs(angle) function code(a, b, angle) tmp = 0.0 if (a <= 8e-31) tmp = b ^ 2.0; else tmp = hypot(b, Float64(0.005555555555555556 * Float64(angle * Float64(a * pi)))) ^ 2.0; end return tmp end
angle = abs(angle) function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 8e-31) tmp = b ^ 2.0; else tmp = hypot(b, (0.005555555555555556 * (angle * (a * pi)))) ^ 2.0; end tmp_2 = tmp; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := If[LessEqual[a, 8e-31], N[Power[b, 2.0], $MachinePrecision], N[Power[N[Sqrt[b ^ 2 + N[(0.005555555555555556 * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
angle = |angle|\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq 8 \cdot 10^{-31}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, 0.005555555555555556 \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 8.000000000000001e-31Initial program 83.2%
unpow283.2%
swap-sqr83.2%
associate-*l/83.2%
associate-*r/83.3%
swap-sqr83.3%
unpow283.3%
associate-*l/83.2%
associate-*r/83.3%
Simplified83.3%
Taylor expanded in angle around 0 82.6%
Taylor expanded in angle around 0 76.4%
*-commutative76.4%
associate-*l*76.4%
Simplified76.4%
*-commutative76.4%
unpow-prod-down76.4%
associate-*r*76.5%
*-commutative76.5%
associate-*l*76.4%
metadata-eval76.4%
Applied egg-rr76.4%
Taylor expanded in angle around 0 68.6%
if 8.000000000000001e-31 < a Initial program 85.6%
unpow285.6%
swap-sqr85.6%
associate-*l/85.8%
associate-*r/85.9%
swap-sqr85.9%
unpow285.9%
associate-*l/85.9%
associate-*r/86.0%
Simplified86.0%
Taylor expanded in angle around 0 86.0%
Taylor expanded in angle around 0 83.3%
*-commutative83.3%
associate-*l*83.3%
Simplified83.3%
*-commutative83.3%
unpow-prod-down83.4%
associate-*r*83.3%
*-commutative83.3%
associate-*l*83.4%
metadata-eval83.4%
Applied egg-rr83.4%
expm1-log1p-u81.9%
expm1-udef70.7%
Applied egg-rr70.7%
expm1-def81.8%
expm1-log1p83.3%
Simplified83.3%
Final simplification73.0%
NOTE: angle should be positive before calling this function (FPCore (a b angle) :precision binary64 (pow b 2.0))
angle = abs(angle);
double code(double a, double b, double angle) {
return pow(b, 2.0);
}
NOTE: angle should be positive before calling this function
real(8) function code(a, b, angle)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle
code = b ** 2.0d0
end function
angle = Math.abs(angle);
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0);
}
angle = abs(angle) def code(a, b, angle): return math.pow(b, 2.0)
angle = abs(angle) function code(a, b, angle) return b ^ 2.0 end
angle = abs(angle) function tmp = code(a, b, angle) tmp = b ^ 2.0; end
NOTE: angle should be positive before calling this function code[a_, b_, angle_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
angle = |angle|\\
\\
{b}^{2}
\end{array}
Initial program 83.9%
unpow283.9%
swap-sqr83.9%
associate-*l/84.0%
associate-*r/84.0%
swap-sqr84.0%
unpow284.0%
associate-*l/84.0%
associate-*r/84.1%
Simplified84.1%
Taylor expanded in angle around 0 83.6%
Taylor expanded in angle around 0 78.5%
*-commutative78.5%
associate-*l*78.5%
Simplified78.5%
*-commutative78.5%
unpow-prod-down78.5%
associate-*r*78.5%
*-commutative78.5%
associate-*l*78.5%
metadata-eval78.5%
Applied egg-rr78.5%
Taylor expanded in angle around 0 63.3%
Final simplification63.3%
herbie shell --seed 2023310
(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)))