
(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}
(FPCore (a b angle) :precision binary64 (+ (pow (* a (sin (/ (* PI 0.005555555555555556) (/ 1.0 angle)))) 2.0) (pow b 2.0)))
double code(double a, double b, double angle) {
return pow((a * sin(((((double) M_PI) * 0.005555555555555556) / (1.0 / angle)))), 2.0) + pow(b, 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow((a * Math.sin(((Math.PI * 0.005555555555555556) / (1.0 / angle)))), 2.0) + Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow((a * math.sin(((math.pi * 0.005555555555555556) / (1.0 / angle)))), 2.0) + math.pow(b, 2.0)
function code(a, b, angle) return Float64((Float64(a * sin(Float64(Float64(pi * 0.005555555555555556) / Float64(1.0 / angle)))) ^ 2.0) + (b ^ 2.0)) end
function tmp = code(a, b, angle) tmp = ((a * sin(((pi * 0.005555555555555556) / (1.0 / angle)))) ^ 2.0) + (b ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[N[(a * N[Sin[N[(N[(Pi * 0.005555555555555556), $MachinePrecision] / N[(1.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(a \cdot \sin \left(\frac{\pi \cdot 0.005555555555555556}{\frac{1}{angle}}\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 79.4%
*-commutative79.4%
associate-*r/79.5%
associate-*l/79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r/79.4%
associate-*l/79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in angle around 0 79.8%
associate-*r/79.8%
associate-*l/79.7%
add-cbrt-cube50.9%
pow1/336.6%
pow336.6%
associate-*l/36.6%
associate-*r/36.6%
div-inv36.6%
metadata-eval36.6%
Applied egg-rr36.6%
unpow1/350.9%
rem-cbrt-cube79.8%
*-commutative79.8%
metadata-eval79.8%
div-inv79.8%
associate-/r/79.8%
div-inv79.8%
associate-/r*79.8%
div-inv79.8%
metadata-eval79.8%
Applied egg-rr79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* 0.005555555555555556 (* PI angle)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((0.005555555555555556 * (((double) M_PI) * angle)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((0.005555555555555556 * (Math.PI * angle)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((0.005555555555555556 * (math.pi * angle)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(0.005555555555555556 * Float64(pi * angle)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((0.005555555555555556 * (pi * angle)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(0.005555555555555556 * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(0.005555555555555556 \cdot \left(\pi \cdot angle\right)\right)\right)}^{2}
\end{array}
Initial program 79.4%
*-commutative79.4%
associate-*r/79.5%
associate-*l/79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r/79.4%
associate-*l/79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* angle (/ PI 180.0)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((angle * (((double) M_PI) / 180.0)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((angle * (Math.PI / 180.0)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((angle * (math.pi / 180.0)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(angle * Float64(pi / 180.0)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((angle * (pi / 180.0)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(angle * N[(Pi / 180.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(angle \cdot \frac{\pi}{180}\right)\right)}^{2}
\end{array}
Initial program 79.4%
*-commutative79.4%
associate-*r/79.5%
associate-*l/79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r/79.4%
associate-*l/79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in angle around 0 79.8%
Final simplification79.8%
(FPCore (a b angle) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (/ PI (/ 180.0 angle)))) 2.0)))
double code(double a, double b, double angle) {
return pow(b, 2.0) + pow((a * sin((((double) M_PI) / (180.0 / angle)))), 2.0);
}
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((Math.PI / (180.0 / angle)))), 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0) + math.pow((a * math.sin((math.pi / (180.0 / angle)))), 2.0)
function code(a, b, angle) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(pi / Float64(180.0 / angle)))) ^ 2.0)) end
function tmp = code(a, b, angle) tmp = (b ^ 2.0) + ((a * sin((pi / (180.0 / angle)))) ^ 2.0); end
code[a_, b_, angle_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(Pi / N[(180.0 / angle), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{b}^{2} + {\left(a \cdot \sin \left(\frac{\pi}{\frac{180}{angle}}\right)\right)}^{2}
\end{array}
Initial program 79.4%
*-commutative79.4%
associate-*r/79.5%
associate-*l/79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r/79.4%
associate-*l/79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in angle around 0 79.8%
associate-*r/79.8%
associate-*l/79.7%
*-commutative79.7%
clear-num79.8%
un-div-inv79.8%
Applied egg-rr79.8%
Final simplification79.8%
(FPCore (a b angle)
:precision binary64
(if (<= a 1.2e-75)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* 0.005555555555555556 (* angle (* 0.005555555555555556 (* a PI))))
(* angle (* a PI))))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 1.2e-75) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((0.005555555555555556 * (angle * (0.005555555555555556 * (a * ((double) M_PI))))) * (angle * (a * ((double) M_PI))));
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 1.2e-75) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((0.005555555555555556 * (angle * (0.005555555555555556 * (a * Math.PI)))) * (angle * (a * Math.PI)));
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 1.2e-75: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((0.005555555555555556 * (angle * (0.005555555555555556 * (a * math.pi)))) * (angle * (a * math.pi))) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 1.2e-75) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(0.005555555555555556 * Float64(angle * Float64(0.005555555555555556 * Float64(a * pi)))) * Float64(angle * Float64(a * pi)))); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 1.2e-75) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((0.005555555555555556 * (angle * (0.005555555555555556 * (a * pi)))) * (angle * (a * pi))); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 1.2e-75], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(0.005555555555555556 * N[(angle * N[(0.005555555555555556 * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(angle * N[(a * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.2 \cdot 10^{-75}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(0.005555555555555556 \cdot \left(angle \cdot \left(0.005555555555555556 \cdot \left(a \cdot \pi\right)\right)\right)\right) \cdot \left(angle \cdot \left(a \cdot \pi\right)\right)\\
\end{array}
\end{array}
if a < 1.2000000000000001e-75Initial program 81.4%
*-commutative81.4%
associate-*r/81.5%
associate-*l/81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r/81.5%
associate-*l/81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in angle around 0 82.0%
Taylor expanded in angle around 0 78.0%
*-commutative78.0%
associate-*l*77.9%
Simplified77.9%
Taylor expanded in angle around 0 64.9%
*-commutative64.9%
associate-*l*64.9%
unpow264.9%
unpow264.9%
unpow264.9%
swap-sqr64.9%
swap-sqr77.9%
unpow277.9%
associate-*r*77.9%
*-commutative77.9%
associate-*l*77.9%
Simplified77.9%
Taylor expanded in angle around 0 60.0%
if 1.2000000000000001e-75 < a Initial program 75.3%
*-commutative75.3%
associate-*r/75.4%
associate-*l/75.4%
*-commutative75.4%
*-commutative75.4%
associate-*r/75.3%
associate-*l/75.4%
*-commutative75.4%
Simplified75.4%
Taylor expanded in angle around 0 75.3%
Taylor expanded in angle around 0 70.7%
*-commutative70.7%
associate-*l*70.7%
Simplified70.7%
unpow270.7%
associate-*r*70.8%
*-commutative70.8%
associate-*l*70.8%
Applied egg-rr70.8%
Final simplification63.5%
(FPCore (a b angle) :precision binary64 (if (<= a 3.5e-68) (pow b 2.0) (+ (pow b 2.0) (pow (* (* PI angle) (* a 0.005555555555555556)) 2.0))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 3.5e-68) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + pow(((((double) M_PI) * angle) * (a * 0.005555555555555556)), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 3.5e-68) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + Math.pow(((Math.PI * angle) * (a * 0.005555555555555556)), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 3.5e-68: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + math.pow(((math.pi * angle) * (a * 0.005555555555555556)), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 3.5e-68) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + (Float64(Float64(pi * angle) * Float64(a * 0.005555555555555556)) ^ 2.0)); end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 3.5e-68) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (((pi * angle) * (a * 0.005555555555555556)) ^ 2.0); end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 3.5e-68], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(N[(Pi * angle), $MachinePrecision] * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 3.5 \cdot 10^{-68}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + {\left(\left(\pi \cdot angle\right) \cdot \left(a \cdot 0.005555555555555556\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 3.50000000000000013e-68Initial program 81.1%
*-commutative81.1%
associate-*r/81.2%
associate-*l/81.2%
*-commutative81.2%
*-commutative81.2%
associate-*r/81.1%
associate-*l/81.2%
*-commutative81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.6%
Taylor expanded in angle around 0 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 64.6%
*-commutative64.6%
associate-*l*64.6%
unpow264.6%
unpow264.6%
unpow264.6%
swap-sqr64.6%
swap-sqr77.6%
unpow277.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 59.7%
if 3.50000000000000013e-68 < a Initial program 76.0%
*-commutative76.0%
associate-*r/76.1%
associate-*l/76.1%
*-commutative76.1%
*-commutative76.1%
associate-*r/76.0%
associate-*l/76.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in angle around 0 76.0%
Taylor expanded in angle around 0 71.4%
associate-*r*71.3%
Simplified71.3%
Final simplification63.5%
(FPCore (a b angle) :precision binary64 (if (<= a 2.9e-75) (pow b 2.0) (fma b b (* (pow (* a (* PI angle)) 2.0) 3.08641975308642e-5))))
double code(double a, double b, double angle) {
double tmp;
if (a <= 2.9e-75) {
tmp = pow(b, 2.0);
} else {
tmp = fma(b, b, (pow((a * (((double) M_PI) * angle)), 2.0) * 3.08641975308642e-5));
}
return tmp;
}
function code(a, b, angle) tmp = 0.0 if (a <= 2.9e-75) tmp = b ^ 2.0; else tmp = fma(b, b, Float64((Float64(a * Float64(pi * angle)) ^ 2.0) * 3.08641975308642e-5)); end return tmp end
code[a_, b_, angle_] := If[LessEqual[a, 2.9e-75], N[Power[b, 2.0], $MachinePrecision], N[(b * b + N[(N[Power[N[(a * N[(Pi * angle), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.9 \cdot 10^{-75}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, b, {\left(a \cdot \left(\pi \cdot angle\right)\right)}^{2} \cdot 3.08641975308642 \cdot 10^{-5}\right)\\
\end{array}
\end{array}
if a < 2.9000000000000002e-75Initial program 81.4%
*-commutative81.4%
associate-*r/81.5%
associate-*l/81.6%
*-commutative81.6%
*-commutative81.6%
associate-*r/81.5%
associate-*l/81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in angle around 0 82.0%
Taylor expanded in angle around 0 78.0%
*-commutative78.0%
associate-*l*77.9%
Simplified77.9%
Taylor expanded in angle around 0 64.9%
*-commutative64.9%
associate-*l*64.9%
unpow264.9%
unpow264.9%
unpow264.9%
swap-sqr64.9%
swap-sqr77.9%
unpow277.9%
associate-*r*77.9%
*-commutative77.9%
associate-*l*77.9%
Simplified77.9%
Taylor expanded in angle around 0 60.0%
if 2.9000000000000002e-75 < a Initial program 75.3%
*-commutative75.3%
associate-*r/75.4%
associate-*l/75.4%
*-commutative75.4%
*-commutative75.4%
associate-*r/75.3%
associate-*l/75.4%
*-commutative75.4%
Simplified75.4%
Taylor expanded in angle around 0 75.3%
Taylor expanded in angle around 0 70.7%
*-commutative70.7%
associate-*l*70.7%
Simplified70.7%
Taylor expanded in angle around 0 56.6%
*-commutative56.6%
associate-*l*56.6%
unpow256.6%
unpow256.6%
unpow256.6%
swap-sqr56.6%
swap-sqr70.7%
unpow270.7%
associate-*r*70.8%
*-commutative70.8%
associate-*l*70.8%
Simplified70.8%
+-commutative70.8%
*-rgt-identity70.8%
pow270.8%
fma-def70.8%
*-commutative70.8%
associate-*r*70.8%
Applied egg-rr70.8%
Final simplification63.5%
(FPCore (a b angle) :precision binary64 (if (<= a 6.5e-69) (pow b 2.0) (pow (hypot b (* 0.005555555555555556 (* PI (* a angle)))) 2.0)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 6.5e-69) {
tmp = pow(b, 2.0);
} else {
tmp = pow(hypot(b, (0.005555555555555556 * (((double) M_PI) * (a * angle)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 6.5e-69) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(Math.hypot(b, (0.005555555555555556 * (Math.PI * (a * angle)))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 6.5e-69: tmp = math.pow(b, 2.0) else: tmp = math.pow(math.hypot(b, (0.005555555555555556 * (math.pi * (a * angle)))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 6.5e-69) tmp = b ^ 2.0; else tmp = hypot(b, Float64(0.005555555555555556 * Float64(pi * Float64(a * angle)))) ^ 2.0; end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 6.5e-69) tmp = b ^ 2.0; else tmp = hypot(b, (0.005555555555555556 * (pi * (a * angle)))) ^ 2.0; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 6.5e-69], N[Power[b, 2.0], $MachinePrecision], N[Power[N[Sqrt[b ^ 2 + N[(0.005555555555555556 * N[(Pi * N[(a * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.5 \cdot 10^{-69}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, 0.005555555555555556 \cdot \left(\pi \cdot \left(a \cdot angle\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 6.49999999999999951e-69Initial program 81.1%
*-commutative81.1%
associate-*r/81.2%
associate-*l/81.2%
*-commutative81.2%
*-commutative81.2%
associate-*r/81.1%
associate-*l/81.2%
*-commutative81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.6%
Taylor expanded in angle around 0 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 64.6%
*-commutative64.6%
associate-*l*64.6%
unpow264.6%
unpow264.6%
unpow264.6%
swap-sqr64.6%
swap-sqr77.6%
unpow277.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 59.7%
if 6.49999999999999951e-69 < a Initial program 76.0%
*-commutative76.0%
associate-*r/76.1%
associate-*l/76.1%
*-commutative76.1%
*-commutative76.1%
associate-*r/76.0%
associate-*l/76.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in angle around 0 76.0%
Taylor expanded in angle around 0 71.4%
*-commutative71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in angle around 0 57.1%
*-commutative57.1%
associate-*l*57.1%
unpow257.1%
unpow257.1%
unpow257.1%
swap-sqr57.1%
swap-sqr71.4%
unpow271.4%
associate-*r*71.5%
*-commutative71.5%
associate-*l*71.4%
Simplified71.4%
expm1-log1p-u70.4%
expm1-udef57.3%
Applied egg-rr57.3%
expm1-def70.4%
expm1-log1p71.4%
associate-*l*71.4%
Simplified71.4%
Final simplification63.5%
(FPCore (a b angle) :precision binary64 (if (<= a 4.4e-66) (pow b 2.0) (pow (hypot b (* 0.005555555555555556 (* a (* PI angle)))) 2.0)))
double code(double a, double b, double angle) {
double tmp;
if (a <= 4.4e-66) {
tmp = pow(b, 2.0);
} else {
tmp = pow(hypot(b, (0.005555555555555556 * (a * (((double) M_PI) * angle)))), 2.0);
}
return tmp;
}
public static double code(double a, double b, double angle) {
double tmp;
if (a <= 4.4e-66) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(Math.hypot(b, (0.005555555555555556 * (a * (Math.PI * angle)))), 2.0);
}
return tmp;
}
def code(a, b, angle): tmp = 0 if a <= 4.4e-66: tmp = math.pow(b, 2.0) else: tmp = math.pow(math.hypot(b, (0.005555555555555556 * (a * (math.pi * angle)))), 2.0) return tmp
function code(a, b, angle) tmp = 0.0 if (a <= 4.4e-66) tmp = b ^ 2.0; else tmp = hypot(b, Float64(0.005555555555555556 * Float64(a * Float64(pi * angle)))) ^ 2.0; end return tmp end
function tmp_2 = code(a, b, angle) tmp = 0.0; if (a <= 4.4e-66) tmp = b ^ 2.0; else tmp = hypot(b, (0.005555555555555556 * (a * (pi * angle)))) ^ 2.0; end tmp_2 = tmp; end
code[a_, b_, angle_] := If[LessEqual[a, 4.4e-66], N[Power[b, 2.0], $MachinePrecision], N[Power[N[Sqrt[b ^ 2 + N[(0.005555555555555556 * N[(a * N[(Pi * angle), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision], 2.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.4 \cdot 10^{-66}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, 0.005555555555555556 \cdot \left(a \cdot \left(\pi \cdot angle\right)\right)\right)\right)}^{2}\\
\end{array}
\end{array}
if a < 4.4000000000000002e-66Initial program 81.1%
*-commutative81.1%
associate-*r/81.2%
associate-*l/81.2%
*-commutative81.2%
*-commutative81.2%
associate-*r/81.1%
associate-*l/81.2%
*-commutative81.2%
Simplified81.2%
Taylor expanded in angle around 0 81.6%
Taylor expanded in angle around 0 77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 64.6%
*-commutative64.6%
associate-*l*64.6%
unpow264.6%
unpow264.6%
unpow264.6%
swap-sqr64.6%
swap-sqr77.6%
unpow277.6%
associate-*r*77.6%
*-commutative77.6%
associate-*l*77.6%
Simplified77.6%
Taylor expanded in angle around 0 59.7%
if 4.4000000000000002e-66 < a Initial program 76.0%
*-commutative76.0%
associate-*r/76.1%
associate-*l/76.1%
*-commutative76.1%
*-commutative76.1%
associate-*r/76.0%
associate-*l/76.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in angle around 0 76.0%
Taylor expanded in angle around 0 71.4%
*-commutative71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in angle around 0 57.1%
*-commutative57.1%
associate-*l*57.1%
unpow257.1%
unpow257.1%
unpow257.1%
swap-sqr57.1%
swap-sqr71.4%
unpow271.4%
associate-*r*71.5%
*-commutative71.5%
associate-*l*71.4%
Simplified71.4%
add-sqr-sqrt71.4%
pow271.4%
Applied egg-rr71.4%
Final simplification63.5%
(FPCore (a b angle) :precision binary64 (pow b 2.0))
double code(double a, double b, double angle) {
return pow(b, 2.0);
}
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
public static double code(double a, double b, double angle) {
return Math.pow(b, 2.0);
}
def code(a, b, angle): return math.pow(b, 2.0)
function code(a, b, angle) return b ^ 2.0 end
function tmp = code(a, b, angle) tmp = b ^ 2.0; end
code[a_, b_, angle_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
\\
{b}^{2}
\end{array}
Initial program 79.4%
*-commutative79.4%
associate-*r/79.5%
associate-*l/79.6%
*-commutative79.6%
*-commutative79.6%
associate-*r/79.4%
associate-*l/79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in angle around 0 79.8%
Taylor expanded in angle around 0 75.6%
*-commutative75.6%
associate-*l*75.6%
Simplified75.6%
Taylor expanded in angle around 0 62.2%
*-commutative62.2%
associate-*l*62.2%
unpow262.2%
unpow262.2%
unpow262.2%
swap-sqr62.2%
swap-sqr75.6%
unpow275.6%
associate-*r*75.6%
*-commutative75.6%
associate-*l*75.6%
Simplified75.6%
Taylor expanded in angle around 0 52.9%
Final simplification52.9%
herbie shell --seed 2024011
(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)))