
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ 1 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l): return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l)))) end
function tmp = code(F, l) tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l))); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (F l) :precision binary64 (- (* PI l) (* (/ 1 (* F F)) (tan (* PI l)))))
double code(double F, double l) {
return (((double) M_PI) * l) - ((1.0 / (F * F)) * tan((((double) M_PI) * l)));
}
public static double code(double F, double l) {
return (Math.PI * l) - ((1.0 / (F * F)) * Math.tan((Math.PI * l)));
}
def code(F, l): return (math.pi * l) - ((1.0 / (F * F)) * math.tan((math.pi * l)))
function code(F, l) return Float64(Float64(pi * l) - Float64(Float64(1.0 / Float64(F * F)) * tan(Float64(pi * l)))) end
function tmp = code(F, l) tmp = (pi * l) - ((1.0 / (F * F)) * tan((pi * l))); end
code[F_, l_] := N[(N[(Pi * l), $MachinePrecision] - N[(N[(1 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[N[(Pi * l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\pi \cdot \ell - \frac{1}{F \cdot F} \cdot \tan \left(\pi \cdot \ell\right)
(FPCore (F l)
:precision binary64
(let* ((t_0 (* (fabs l) PI)))
(*
(copysign 1 l)
(if (<= (fabs l) 2900000000000000)
(- (* PI (fabs l)) (/ -1 (* (/ (- F) (tan t_0)) F)))
t_0))))double code(double F, double l) {
double t_0 = fabs(l) * ((double) M_PI);
double tmp;
if (fabs(l) <= 2.9e+15) {
tmp = (((double) M_PI) * fabs(l)) - (-1.0 / ((-F / tan(t_0)) * F));
} else {
tmp = t_0;
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.abs(l) * Math.PI;
double tmp;
if (Math.abs(l) <= 2.9e+15) {
tmp = (Math.PI * Math.abs(l)) - (-1.0 / ((-F / Math.tan(t_0)) * F));
} else {
tmp = t_0;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.fabs(l) * math.pi tmp = 0 if math.fabs(l) <= 2.9e+15: tmp = (math.pi * math.fabs(l)) - (-1.0 / ((-F / math.tan(t_0)) * F)) else: tmp = t_0 return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(abs(l) * pi) tmp = 0.0 if (abs(l) <= 2.9e+15) tmp = Float64(Float64(pi * abs(l)) - Float64(-1.0 / Float64(Float64(Float64(-F) / tan(t_0)) * F))); else tmp = t_0; end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = abs(l) * pi; tmp = 0.0; if (abs(l) <= 2.9e+15) tmp = (pi * abs(l)) - (-1.0 / ((-F / tan(t_0)) * F)); else tmp = t_0; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[l], $MachinePrecision], 2900000000000000], N[(N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision] - N[(-1 / N[(N[((-F) / N[Tan[t$95$0], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|\ell\right| \cdot \pi\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|\ell\right| \leq 2900000000000000:\\
\;\;\;\;\pi \cdot \left|\ell\right| - \frac{-1}{\frac{-F}{\tan t\_0} \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < 2.9e15Initial program 75.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7%
Applied rewrites81.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6481.7%
Applied rewrites81.7%
lift-/.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6481.7%
Applied rewrites81.7%
if 2.9e15 < l Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l)
:precision binary64
(let* ((t_0 (* (fabs l) PI)))
(*
(copysign 1 l)
(if (<= (fabs l) 2900000000000000)
(- (* PI (fabs l)) (/ (/ (tan t_0) F) F))
t_0))))double code(double F, double l) {
double t_0 = fabs(l) * ((double) M_PI);
double tmp;
if (fabs(l) <= 2.9e+15) {
tmp = (((double) M_PI) * fabs(l)) - ((tan(t_0) / F) / F);
} else {
tmp = t_0;
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.abs(l) * Math.PI;
double tmp;
if (Math.abs(l) <= 2.9e+15) {
tmp = (Math.PI * Math.abs(l)) - ((Math.tan(t_0) / F) / F);
} else {
tmp = t_0;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.fabs(l) * math.pi tmp = 0 if math.fabs(l) <= 2.9e+15: tmp = (math.pi * math.fabs(l)) - ((math.tan(t_0) / F) / F) else: tmp = t_0 return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(abs(l) * pi) tmp = 0.0 if (abs(l) <= 2.9e+15) tmp = Float64(Float64(pi * abs(l)) - Float64(Float64(tan(t_0) / F) / F)); else tmp = t_0; end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = abs(l) * pi; tmp = 0.0; if (abs(l) <= 2.9e+15) tmp = (pi * abs(l)) - ((tan(t_0) / F) / F); else tmp = t_0; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[l], $MachinePrecision], 2900000000000000], N[(N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Tan[t$95$0], $MachinePrecision] / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|\ell\right| \cdot \pi\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|\ell\right| \leq 2900000000000000:\\
\;\;\;\;\pi \cdot \left|\ell\right| - \frac{\frac{\tan t\_0}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < 2.9e15Initial program 75.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7%
Applied rewrites81.7%
if 2.9e15 < l Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l)
:precision binary64
(let* ((t_0 (* (fabs l) PI)))
(*
(copysign 1 l)
(if (<= (fabs l) 1300000000000000)
(- (* PI (fabs l)) (/ -1 (* (* -1 (/ F t_0)) F)))
t_0))))double code(double F, double l) {
double t_0 = fabs(l) * ((double) M_PI);
double tmp;
if (fabs(l) <= 1.3e+15) {
tmp = (((double) M_PI) * fabs(l)) - (-1.0 / ((-1.0 * (F / t_0)) * F));
} else {
tmp = t_0;
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.abs(l) * Math.PI;
double tmp;
if (Math.abs(l) <= 1.3e+15) {
tmp = (Math.PI * Math.abs(l)) - (-1.0 / ((-1.0 * (F / t_0)) * F));
} else {
tmp = t_0;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.fabs(l) * math.pi tmp = 0 if math.fabs(l) <= 1.3e+15: tmp = (math.pi * math.fabs(l)) - (-1.0 / ((-1.0 * (F / t_0)) * F)) else: tmp = t_0 return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(abs(l) * pi) tmp = 0.0 if (abs(l) <= 1.3e+15) tmp = Float64(Float64(pi * abs(l)) - Float64(-1.0 / Float64(Float64(-1.0 * Float64(F / t_0)) * F))); else tmp = t_0; end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = abs(l) * pi; tmp = 0.0; if (abs(l) <= 1.3e+15) tmp = (pi * abs(l)) - (-1.0 / ((-1.0 * (F / t_0)) * F)); else tmp = t_0; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[l], $MachinePrecision], 1300000000000000], N[(N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision] - N[(-1 / N[(N[(-1 * N[(F / t$95$0), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|\ell\right| \cdot \pi\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|\ell\right| \leq 1300000000000000:\\
\;\;\;\;\pi \cdot \left|\ell\right| - \frac{-1}{\left(-1 \cdot \frac{F}{t\_0}\right) \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < 1.3e15Initial program 75.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7%
Applied rewrites81.7%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6481.7%
Applied rewrites81.7%
lift-/.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6481.7%
Applied rewrites81.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f6474.6%
Applied rewrites74.6%
if 1.3e15 < l Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l)
:precision binary64
(let* ((t_0 (* (fabs l) PI)))
(*
(copysign 1 l)
(if (<= (fabs l) 1300000000000000)
(- (* PI (fabs l)) (/ (/ t_0 F) F))
t_0))))double code(double F, double l) {
double t_0 = fabs(l) * ((double) M_PI);
double tmp;
if (fabs(l) <= 1.3e+15) {
tmp = (((double) M_PI) * fabs(l)) - ((t_0 / F) / F);
} else {
tmp = t_0;
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.abs(l) * Math.PI;
double tmp;
if (Math.abs(l) <= 1.3e+15) {
tmp = (Math.PI * Math.abs(l)) - ((t_0 / F) / F);
} else {
tmp = t_0;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.fabs(l) * math.pi tmp = 0 if math.fabs(l) <= 1.3e+15: tmp = (math.pi * math.fabs(l)) - ((t_0 / F) / F) else: tmp = t_0 return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(abs(l) * pi) tmp = 0.0 if (abs(l) <= 1.3e+15) tmp = Float64(Float64(pi * abs(l)) - Float64(Float64(t_0 / F) / F)); else tmp = t_0; end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = abs(l) * pi; tmp = 0.0; if (abs(l) <= 1.3e+15) tmp = (pi * abs(l)) - ((t_0 / F) / F); else tmp = t_0; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[l], $MachinePrecision], 1300000000000000], N[(N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 / F), $MachinePrecision] / F), $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|\ell\right| \cdot \pi\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|\ell\right| \leq 1300000000000000:\\
\;\;\;\;\pi \cdot \left|\ell\right| - \frac{\frac{t\_0}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if l < 1.3e15Initial program 75.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flip-revN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.7%
Applied rewrites81.7%
Taylor expanded in l around 0
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f6474.6%
Applied rewrites74.6%
if 1.3e15 < l Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l)
:precision binary64
(let* ((t_0 (* PI (fabs l))))
(*
(copysign 1 l)
(if (<=
(- t_0 (* (/ 1 (* F F)) (tan t_0)))
6176826577981891/12353653155963782858428671064387042666598916611580939841119467653041402561523153496823753888027168243114445670429492914513538130943957121390808923336226715693451991227817771079374200911992994161452622538969283756626099089564495403968390097390695773702442020050803147555684412513136627351818013153603882218219464583806976)
(/ (* (- (* (* F F) PI) PI) (fabs l)) (* F F))
(* (fabs l) PI)))))double code(double F, double l) {
double t_0 = ((double) M_PI) * fabs(l);
double tmp;
if ((t_0 - ((1.0 / (F * F)) * tan(t_0))) <= 5e-304) {
tmp = ((((F * F) * ((double) M_PI)) - ((double) M_PI)) * fabs(l)) / (F * F);
} else {
tmp = fabs(l) * ((double) M_PI);
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.PI * Math.abs(l);
double tmp;
if ((t_0 - ((1.0 / (F * F)) * Math.tan(t_0))) <= 5e-304) {
tmp = ((((F * F) * Math.PI) - Math.PI) * Math.abs(l)) / (F * F);
} else {
tmp = Math.abs(l) * Math.PI;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.pi * math.fabs(l) tmp = 0 if (t_0 - ((1.0 / (F * F)) * math.tan(t_0))) <= 5e-304: tmp = ((((F * F) * math.pi) - math.pi) * math.fabs(l)) / (F * F) else: tmp = math.fabs(l) * math.pi return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(pi * abs(l)) tmp = 0.0 if (Float64(t_0 - Float64(Float64(1.0 / Float64(F * F)) * tan(t_0))) <= 5e-304) tmp = Float64(Float64(Float64(Float64(Float64(F * F) * pi) - pi) * abs(l)) / Float64(F * F)); else tmp = Float64(abs(l) * pi); end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = pi * abs(l); tmp = 0.0; if ((t_0 - ((1.0 / (F * F)) * tan(t_0))) <= 5e-304) tmp = ((((F * F) * pi) - pi) * abs(l)) / (F * F); else tmp = abs(l) * pi; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$0 - N[(N[(1 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 6176826577981891/12353653155963782858428671064387042666598916611580939841119467653041402561523153496823753888027168243114445670429492914513538130943957121390808923336226715693451991227817771079374200911992994161452622538969283756626099089564495403968390097390695773702442020050803147555684412513136627351818013153603882218219464583806976], N[(N[(N[(N[(N[(F * F), $MachinePrecision] * Pi), $MachinePrecision] - Pi), $MachinePrecision] * N[Abs[l], $MachinePrecision]), $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision], N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \pi \cdot \left|\ell\right|\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \leq \frac{6176826577981891}{12353653155963782858428671064387042666598916611580939841119467653041402561523153496823753888027168243114445670429492914513538130943957121390808923336226715693451991227817771079374200911992994161452622538969283756626099089564495403968390097390695773702442020050803147555684412513136627351818013153603882218219464583806976}:\\
\;\;\;\;\frac{\left(\left(F \cdot F\right) \cdot \pi - \pi\right) \cdot \left|\ell\right|}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;\left|\ell\right| \cdot \pi\\
\end{array}
\end{array}
if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < 4.9999999999999997e-304Initial program 75.9%
lift--.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-to-fractionN/A
lower-/.f64N/A
Applied rewrites45.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-PI.f64N/A
lower-PI.f6438.2%
Applied rewrites38.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6438.2%
lift-pow.f64N/A
pow2N/A
lift-*.f6438.2%
Applied rewrites38.2%
if 4.9999999999999997e-304 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l)
:precision binary64
(let* ((t_0 (* PI (fabs l))))
(*
(copysign 1 l)
(if (<=
(- t_0 (* (/ 1 (* F F)) (tan t_0)))
-3974446316289815/794889263257962974796277498092801308291525640763748664903194643469338087775424965801409745320266996710649718116931109481559848982586784968419475084821084743272680947722675151641735826243378403750534655587182832000457137589153821622272)
(/ (* (fabs l) (* -1 PI)) (* F F))
(* (fabs l) PI)))))double code(double F, double l) {
double t_0 = ((double) M_PI) * fabs(l);
double tmp;
if ((t_0 - ((1.0 / (F * F)) * tan(t_0))) <= -5e-219) {
tmp = (fabs(l) * (-1.0 * ((double) M_PI))) / (F * F);
} else {
tmp = fabs(l) * ((double) M_PI);
}
return copysign(1.0, l) * tmp;
}
public static double code(double F, double l) {
double t_0 = Math.PI * Math.abs(l);
double tmp;
if ((t_0 - ((1.0 / (F * F)) * Math.tan(t_0))) <= -5e-219) {
tmp = (Math.abs(l) * (-1.0 * Math.PI)) / (F * F);
} else {
tmp = Math.abs(l) * Math.PI;
}
return Math.copySign(1.0, l) * tmp;
}
def code(F, l): t_0 = math.pi * math.fabs(l) tmp = 0 if (t_0 - ((1.0 / (F * F)) * math.tan(t_0))) <= -5e-219: tmp = (math.fabs(l) * (-1.0 * math.pi)) / (F * F) else: tmp = math.fabs(l) * math.pi return math.copysign(1.0, l) * tmp
function code(F, l) t_0 = Float64(pi * abs(l)) tmp = 0.0 if (Float64(t_0 - Float64(Float64(1.0 / Float64(F * F)) * tan(t_0))) <= -5e-219) tmp = Float64(Float64(abs(l) * Float64(-1.0 * pi)) / Float64(F * F)); else tmp = Float64(abs(l) * pi); end return Float64(copysign(1.0, l) * tmp) end
function tmp_2 = code(F, l) t_0 = pi * abs(l); tmp = 0.0; if ((t_0 - ((1.0 / (F * F)) * tan(t_0))) <= -5e-219) tmp = (abs(l) * (-1.0 * pi)) / (F * F); else tmp = abs(l) * pi; end tmp_2 = (sign(l) * abs(1.0)) * tmp; end
code[F_, l_] := Block[{t$95$0 = N[(Pi * N[Abs[l], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(t$95$0 - N[(N[(1 / N[(F * F), $MachinePrecision]), $MachinePrecision] * N[Tan[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3974446316289815/794889263257962974796277498092801308291525640763748664903194643469338087775424965801409745320266996710649718116931109481559848982586784968419475084821084743272680947722675151641735826243378403750534655587182832000457137589153821622272], N[(N[(N[Abs[l], $MachinePrecision] * N[(-1 * Pi), $MachinePrecision]), $MachinePrecision] / N[(F * F), $MachinePrecision]), $MachinePrecision], N[(N[Abs[l], $MachinePrecision] * Pi), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \pi \cdot \left|\ell\right|\\
\mathsf{copysign}\left(1, \ell\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \leq \frac{-3974446316289815}{794889263257962974796277498092801308291525640763748664903194643469338087775424965801409745320266996710649718116931109481559848982586784968419475084821084743272680947722675151641735826243378403750534655587182832000457137589153821622272}:\\
\;\;\;\;\frac{\left|\ell\right| \cdot \left(-1 \cdot \pi\right)}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;\left|\ell\right| \cdot \pi\\
\end{array}
\end{array}
if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -5.0000000000000002e-219Initial program 75.9%
lift--.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
sub-to-fractionN/A
lower-/.f64N/A
Applied rewrites45.7%
Taylor expanded in l around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-PI.f64N/A
lower-PI.f6438.2%
Applied rewrites38.2%
Taylor expanded in F around 0
lower-*.f64N/A
lower-PI.f6420.6%
Applied rewrites20.6%
if -5.0000000000000002e-219 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l) :precision binary64 (* l PI))
double code(double F, double l) {
return l * ((double) M_PI);
}
public static double code(double F, double l) {
return l * Math.PI;
}
def code(F, l): return l * math.pi
function code(F, l) return Float64(l * pi) end
function tmp = code(F, l) tmp = l * pi; end
code[F_, l_] := N[(l * Pi), $MachinePrecision]
\ell \cdot \pi
Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
(FPCore (F l) :precision binary64 (* l 0))
double code(double F, double l) {
return l * 0.0;
}
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(f, l)
use fmin_fmax_functions
real(8), intent (in) :: f
real(8), intent (in) :: l
code = l * 0.0d0
end function
public static double code(double F, double l) {
return l * 0.0;
}
def code(F, l): return l * 0.0
function code(F, l) return Float64(l * 0.0) end
function tmp = code(F, l) tmp = l * 0.0; end
code[F_, l_] := N[(l * 0), $MachinePrecision]
\ell \cdot 0
Initial program 75.9%
Taylor expanded in F around inf
lower-*.f64N/A
lower-PI.f6474.2%
Applied rewrites74.2%
Taylor expanded in undef-var around zero
Applied rewrites3.1%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* PI l) (* (/ 1 (* F F)) (tan (* PI l)))))