
(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 7 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}
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow (* a (log1p (expm1 (sin (* angle_m (* PI 0.005555555555555556)))))) 2.0) (pow b 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow((a * log1p(expm1(sin((angle_m * (((double) M_PI) * 0.005555555555555556)))))), 2.0) + pow(b, 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow((a * Math.log1p(Math.expm1(Math.sin((angle_m * (Math.PI * 0.005555555555555556)))))), 2.0) + Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow((a * math.log1p(math.expm1(math.sin((angle_m * (math.pi * 0.005555555555555556)))))), 2.0) + math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((Float64(a * log1p(expm1(sin(Float64(angle_m * Float64(pi * 0.005555555555555556)))))) ^ 2.0) + (b ^ 2.0)) end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[N[(a * N[Log[1 + N[(Exp[N[Sin[N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{\left(a \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(angle_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)}^{2} + {b}^{2}
\end{array}
Initial program 76.9%
unpow276.9%
swap-sqr76.9%
*-commutative76.9%
associate-*r/76.8%
associate-*l/76.9%
*-commutative76.9%
swap-sqr76.9%
unpow276.9%
*-commutative76.9%
associate-*r/76.9%
associate-*l/77.0%
*-commutative77.0%
Simplified77.0%
associate-*r/76.9%
associate-*l/76.9%
add-log-exp66.7%
associate-/r/66.8%
div-inv66.8%
clear-num66.8%
div-inv66.8%
metadata-eval66.8%
Applied egg-rr66.8%
Taylor expanded in angle around 0 66.9%
rem-log-exp77.1%
Applied egg-rr77.1%
log1p-expm1-u77.1%
Applied egg-rr77.1%
Final simplification77.1%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (+ (pow b 2.0) (pow (* a (sin (* angle_m (* PI 0.005555555555555556)))) 2.0)))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(b, 2.0) + pow((a * sin((angle_m * (((double) M_PI) * 0.005555555555555556)))), 2.0);
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(b, 2.0) + Math.pow((a * Math.sin((angle_m * (Math.PI * 0.005555555555555556)))), 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(b, 2.0) + math.pow((a * math.sin((angle_m * (math.pi * 0.005555555555555556)))), 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return Float64((b ^ 2.0) + (Float64(a * sin(Float64(angle_m * Float64(pi * 0.005555555555555556)))) ^ 2.0)) end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = (b ^ 2.0) + ((a * sin((angle_m * (pi * 0.005555555555555556)))) ^ 2.0); end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[(N[Power[b, 2.0], $MachinePrecision] + N[Power[N[(a * N[Sin[N[(angle$95$m * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{b}^{2} + {\left(a \cdot \sin \left(angle_m \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)}^{2}
\end{array}
Initial program 76.9%
unpow276.9%
swap-sqr76.9%
*-commutative76.9%
associate-*r/76.8%
associate-*l/76.9%
*-commutative76.9%
swap-sqr76.9%
unpow276.9%
*-commutative76.9%
associate-*r/76.9%
associate-*l/77.0%
*-commutative77.0%
Simplified77.0%
associate-*r/76.9%
associate-*l/76.9%
add-log-exp66.7%
associate-/r/66.8%
div-inv66.8%
clear-num66.8%
div-inv66.8%
metadata-eval66.8%
Applied egg-rr66.8%
Taylor expanded in angle around 0 66.9%
rem-log-exp77.1%
Applied egg-rr77.1%
Final simplification77.1%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 2.4e-88)
(pow b 2.0)
(+
(pow b 2.0)
(*
angle_m
(*
(* a PI)
(*
angle_m
(* 0.005555555555555556 (* a (* PI 0.005555555555555556)))))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.4e-88) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (angle_m * ((a * ((double) M_PI)) * (angle_m * (0.005555555555555556 * (a * (((double) M_PI) * 0.005555555555555556))))));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.4e-88) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (angle_m * ((a * Math.PI) * (angle_m * (0.005555555555555556 * (a * (Math.PI * 0.005555555555555556))))));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 2.4e-88: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (angle_m * ((a * math.pi) * (angle_m * (0.005555555555555556 * (a * (math.pi * 0.005555555555555556)))))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 2.4e-88) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(angle_m * Float64(Float64(a * pi) * Float64(angle_m * Float64(0.005555555555555556 * Float64(a * Float64(pi * 0.005555555555555556))))))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 2.4e-88) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (angle_m * ((a * pi) * (angle_m * (0.005555555555555556 * (a * (pi * 0.005555555555555556)))))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 2.4e-88], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(angle$95$m * N[(N[(a * Pi), $MachinePrecision] * N[(angle$95$m * N[(0.005555555555555556 * N[(a * N[(Pi * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.4 \cdot 10^{-88}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + angle_m \cdot \left(\left(a \cdot \pi\right) \cdot \left(angle_m \cdot \left(0.005555555555555556 \cdot \left(a \cdot \left(\pi \cdot 0.005555555555555556\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if a < 2.4e-88Initial program 75.1%
unpow275.1%
swap-sqr75.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.1%
*-commutative75.1%
swap-sqr75.1%
unpow275.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.2%
*-commutative75.2%
Simplified75.2%
expm1-log1p-u74.7%
expm1-udef69.5%
Applied egg-rr69.5%
Taylor expanded in angle around 0 69.6%
Taylor expanded in a around 0 59.7%
if 2.4e-88 < a Initial program 82.1%
unpow282.1%
swap-sqr82.1%
*-commutative82.1%
associate-*r/82.0%
associate-*l/82.3%
*-commutative82.3%
swap-sqr82.3%
unpow282.3%
*-commutative82.3%
associate-*r/82.1%
associate-*l/82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in angle around 0 78.1%
*-commutative78.1%
associate-*r*78.1%
Simplified78.1%
Taylor expanded in angle around 0 78.2%
unpow278.2%
associate-*r*78.2%
associate-*l*75.4%
*-commutative75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
Applied egg-rr75.4%
associate-*r*78.3%
*-commutative78.3%
associate-*l*75.5%
*-commutative75.5%
associate-*l*75.5%
*-commutative75.5%
associate-*l*75.5%
Simplified75.5%
expm1-log1p-u49.8%
expm1-udef44.4%
*-commutative44.4%
associate-*l*44.4%
associate-*r*44.4%
*-commutative44.4%
Applied egg-rr44.4%
expm1-def49.8%
expm1-log1p75.5%
*-commutative75.5%
Simplified75.5%
Final simplification63.7%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 2.8e-88)
(pow b 2.0)
(+
(pow b 2.0)
(*
(* PI (* a 0.005555555555555556))
(* (* angle_m (* a PI)) (* angle_m 0.005555555555555556))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.8e-88) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + ((((double) M_PI) * (a * 0.005555555555555556)) * ((angle_m * (a * ((double) M_PI))) * (angle_m * 0.005555555555555556)));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 2.8e-88) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + ((Math.PI * (a * 0.005555555555555556)) * ((angle_m * (a * Math.PI)) * (angle_m * 0.005555555555555556)));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 2.8e-88: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + ((math.pi * (a * 0.005555555555555556)) * ((angle_m * (a * math.pi)) * (angle_m * 0.005555555555555556))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 2.8e-88) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(Float64(pi * Float64(a * 0.005555555555555556)) * Float64(Float64(angle_m * Float64(a * pi)) * Float64(angle_m * 0.005555555555555556)))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 2.8e-88) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + ((pi * (a * 0.005555555555555556)) * ((angle_m * (a * pi)) * (angle_m * 0.005555555555555556))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 2.8e-88], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(N[(Pi * N[(a * 0.005555555555555556), $MachinePrecision]), $MachinePrecision] * N[(N[(angle$95$m * N[(a * Pi), $MachinePrecision]), $MachinePrecision] * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.8 \cdot 10^{-88}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + \left(\pi \cdot \left(a \cdot 0.005555555555555556\right)\right) \cdot \left(\left(angle_m \cdot \left(a \cdot \pi\right)\right) \cdot \left(angle_m \cdot 0.005555555555555556\right)\right)\\
\end{array}
\end{array}
if a < 2.79999999999999976e-88Initial program 75.1%
unpow275.1%
swap-sqr75.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.1%
*-commutative75.1%
swap-sqr75.1%
unpow275.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.2%
*-commutative75.2%
Simplified75.2%
expm1-log1p-u74.7%
expm1-udef69.5%
Applied egg-rr69.5%
Taylor expanded in angle around 0 69.6%
Taylor expanded in a around 0 59.7%
if 2.79999999999999976e-88 < a Initial program 82.1%
unpow282.1%
swap-sqr82.1%
*-commutative82.1%
associate-*r/82.0%
associate-*l/82.3%
*-commutative82.3%
swap-sqr82.3%
unpow282.3%
*-commutative82.3%
associate-*r/82.1%
associate-*l/82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in angle around 0 78.1%
*-commutative78.1%
associate-*r*78.1%
Simplified78.1%
Taylor expanded in angle around 0 78.2%
unpow278.2%
associate-*r*78.2%
associate-*l*75.4%
*-commutative75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
Applied egg-rr75.4%
associate-*l*75.4%
associate-*r*75.4%
*-commutative75.4%
Simplified75.4%
Final simplification63.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (let* ((t_0 (* (* a PI) (* angle_m 0.005555555555555556)))) (if (<= a 2.8e-88) (pow b 2.0) (+ (pow b 2.0) (* t_0 t_0)))))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double t_0 = (a * ((double) M_PI)) * (angle_m * 0.005555555555555556);
double tmp;
if (a <= 2.8e-88) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (t_0 * t_0);
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double t_0 = (a * Math.PI) * (angle_m * 0.005555555555555556);
double tmp;
if (a <= 2.8e-88) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (t_0 * t_0);
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): t_0 = (a * math.pi) * (angle_m * 0.005555555555555556) tmp = 0 if a <= 2.8e-88: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (t_0 * t_0) return tmp
angle_m = abs(angle) function code(a, b, angle_m) t_0 = Float64(Float64(a * pi) * Float64(angle_m * 0.005555555555555556)) tmp = 0.0 if (a <= 2.8e-88) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(t_0 * t_0)); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) t_0 = (a * pi) * (angle_m * 0.005555555555555556); tmp = 0.0; if (a <= 2.8e-88) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (t_0 * t_0); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision]
code[a_, b_, angle$95$m_] := Block[{t$95$0 = N[(N[(a * Pi), $MachinePrecision] * N[(angle$95$m * 0.005555555555555556), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 2.8e-88], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
t_0 := \left(a \cdot \pi\right) \cdot \left(angle_m \cdot 0.005555555555555556\right)\\
\mathbf{if}\;a \leq 2.8 \cdot 10^{-88}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + t_0 \cdot t_0\\
\end{array}
\end{array}
if a < 2.79999999999999976e-88Initial program 75.1%
unpow275.1%
swap-sqr75.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.1%
*-commutative75.1%
swap-sqr75.1%
unpow275.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.2%
*-commutative75.2%
Simplified75.2%
expm1-log1p-u74.7%
expm1-udef69.5%
Applied egg-rr69.5%
Taylor expanded in angle around 0 69.6%
Taylor expanded in a around 0 59.7%
if 2.79999999999999976e-88 < a Initial program 82.1%
unpow282.1%
swap-sqr82.1%
*-commutative82.1%
associate-*r/82.0%
associate-*l/82.3%
*-commutative82.3%
swap-sqr82.3%
unpow282.3%
*-commutative82.3%
associate-*r/82.1%
associate-*l/82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in angle around 0 78.1%
*-commutative78.1%
associate-*r*78.1%
Simplified78.1%
Taylor expanded in angle around 0 78.2%
unpow278.2%
*-commutative78.2%
*-commutative78.2%
associate-*l*78.2%
*-commutative78.2%
associate-*l*78.3%
*-commutative78.3%
Applied egg-rr78.3%
Final simplification64.4%
angle_m = (fabs.f64 angle)
(FPCore (a b angle_m)
:precision binary64
(if (<= a 1.15e-88)
(pow b 2.0)
(+
(pow b 2.0)
(* angle_m (* (* a PI) (* (* a (* angle_m PI)) 3.08641975308642e-5))))))angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.15e-88) {
tmp = pow(b, 2.0);
} else {
tmp = pow(b, 2.0) + (angle_m * ((a * ((double) M_PI)) * ((a * (angle_m * ((double) M_PI))) * 3.08641975308642e-5)));
}
return tmp;
}
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
double tmp;
if (a <= 1.15e-88) {
tmp = Math.pow(b, 2.0);
} else {
tmp = Math.pow(b, 2.0) + (angle_m * ((a * Math.PI) * ((a * (angle_m * Math.PI)) * 3.08641975308642e-5)));
}
return tmp;
}
angle_m = math.fabs(angle) def code(a, b, angle_m): tmp = 0 if a <= 1.15e-88: tmp = math.pow(b, 2.0) else: tmp = math.pow(b, 2.0) + (angle_m * ((a * math.pi) * ((a * (angle_m * math.pi)) * 3.08641975308642e-5))) return tmp
angle_m = abs(angle) function code(a, b, angle_m) tmp = 0.0 if (a <= 1.15e-88) tmp = b ^ 2.0; else tmp = Float64((b ^ 2.0) + Float64(angle_m * Float64(Float64(a * pi) * Float64(Float64(a * Float64(angle_m * pi)) * 3.08641975308642e-5)))); end return tmp end
angle_m = abs(angle); function tmp_2 = code(a, b, angle_m) tmp = 0.0; if (a <= 1.15e-88) tmp = b ^ 2.0; else tmp = (b ^ 2.0) + (angle_m * ((a * pi) * ((a * (angle_m * pi)) * 3.08641975308642e-5))); end tmp_2 = tmp; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := If[LessEqual[a, 1.15e-88], N[Power[b, 2.0], $MachinePrecision], N[(N[Power[b, 2.0], $MachinePrecision] + N[(angle$95$m * N[(N[(a * Pi), $MachinePrecision] * N[(N[(a * N[(angle$95$m * Pi), $MachinePrecision]), $MachinePrecision] * 3.08641975308642e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
angle_m = \left|angle\right|
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.15 \cdot 10^{-88}:\\
\;\;\;\;{b}^{2}\\
\mathbf{else}:\\
\;\;\;\;{b}^{2} + angle_m \cdot \left(\left(a \cdot \pi\right) \cdot \left(\left(a \cdot \left(angle_m \cdot \pi\right)\right) \cdot 3.08641975308642 \cdot 10^{-5}\right)\right)\\
\end{array}
\end{array}
if a < 1.14999999999999993e-88Initial program 75.1%
unpow275.1%
swap-sqr75.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.1%
*-commutative75.1%
swap-sqr75.1%
unpow275.1%
*-commutative75.1%
associate-*r/75.1%
associate-*l/75.2%
*-commutative75.2%
Simplified75.2%
expm1-log1p-u74.7%
expm1-udef69.5%
Applied egg-rr69.5%
Taylor expanded in angle around 0 69.6%
Taylor expanded in a around 0 59.7%
if 1.14999999999999993e-88 < a Initial program 82.1%
unpow282.1%
swap-sqr82.1%
*-commutative82.1%
associate-*r/82.0%
associate-*l/82.3%
*-commutative82.3%
swap-sqr82.3%
unpow282.3%
*-commutative82.3%
associate-*r/82.1%
associate-*l/82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in angle around 0 78.1%
*-commutative78.1%
associate-*r*78.1%
Simplified78.1%
Taylor expanded in angle around 0 78.2%
unpow278.2%
associate-*r*78.2%
associate-*l*75.4%
*-commutative75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
associate-*l*75.4%
*-commutative75.4%
Applied egg-rr75.4%
associate-*r*78.3%
*-commutative78.3%
associate-*l*75.5%
*-commutative75.5%
associate-*l*75.5%
*-commutative75.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in angle around 0 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification63.7%
angle_m = (fabs.f64 angle) (FPCore (a b angle_m) :precision binary64 (pow b 2.0))
angle_m = fabs(angle);
double code(double a, double b, double angle_m) {
return pow(b, 2.0);
}
angle_m = abs(angle)
real(8) function code(a, b, angle_m)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: angle_m
code = b ** 2.0d0
end function
angle_m = Math.abs(angle);
public static double code(double a, double b, double angle_m) {
return Math.pow(b, 2.0);
}
angle_m = math.fabs(angle) def code(a, b, angle_m): return math.pow(b, 2.0)
angle_m = abs(angle) function code(a, b, angle_m) return b ^ 2.0 end
angle_m = abs(angle); function tmp = code(a, b, angle_m) tmp = b ^ 2.0; end
angle_m = N[Abs[angle], $MachinePrecision] code[a_, b_, angle$95$m_] := N[Power[b, 2.0], $MachinePrecision]
\begin{array}{l}
angle_m = \left|angle\right|
\\
{b}^{2}
\end{array}
Initial program 76.9%
unpow276.9%
swap-sqr76.9%
*-commutative76.9%
associate-*r/76.8%
associate-*l/76.9%
*-commutative76.9%
swap-sqr76.9%
unpow276.9%
*-commutative76.9%
associate-*r/76.9%
associate-*l/77.0%
*-commutative77.0%
Simplified77.0%
expm1-log1p-u76.5%
expm1-udef70.7%
Applied egg-rr70.7%
Taylor expanded in angle around 0 70.8%
Taylor expanded in a around 0 57.9%
Final simplification57.9%
herbie shell --seed 2024014
(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)))