
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x)
:precision binary64
(let* ((t_0 (* (* (fabs x) (fabs x)) (fabs x)))
(t_1 (* (* t_0 (fabs x)) (fabs x))))
(fabs
(*
(/ 1.0 (sqrt PI))
(+
(+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) t_0)) (* (/ 1.0 5.0) t_1))
(* (/ 1.0 21.0) (* (* t_1 (fabs x)) (fabs x))))))))double code(double x) {
double t_0 = (fabs(x) * fabs(x)) * fabs(x);
double t_1 = (t_0 * fabs(x)) * fabs(x);
return fabs(((1.0 / sqrt(((double) M_PI))) * ((((2.0 * fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * fabs(x)) * fabs(x))))));
}
public static double code(double x) {
double t_0 = (Math.abs(x) * Math.abs(x)) * Math.abs(x);
double t_1 = (t_0 * Math.abs(x)) * Math.abs(x);
return Math.abs(((1.0 / Math.sqrt(Math.PI)) * ((((2.0 * Math.abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * Math.abs(x)) * Math.abs(x))))));
}
def code(x): t_0 = (math.fabs(x) * math.fabs(x)) * math.fabs(x) t_1 = (t_0 * math.fabs(x)) * math.fabs(x) return math.fabs(((1.0 / math.sqrt(math.pi)) * ((((2.0 * math.fabs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * math.fabs(x)) * math.fabs(x))))))
function code(x) t_0 = Float64(Float64(abs(x) * abs(x)) * abs(x)) t_1 = Float64(Float64(t_0 * abs(x)) * abs(x)) return abs(Float64(Float64(1.0 / sqrt(pi)) * Float64(Float64(Float64(Float64(2.0 * abs(x)) + Float64(Float64(2.0 / 3.0) * t_0)) + Float64(Float64(1.0 / 5.0) * t_1)) + Float64(Float64(1.0 / 21.0) * Float64(Float64(t_1 * abs(x)) * abs(x)))))) end
function tmp = code(x) t_0 = (abs(x) * abs(x)) * abs(x); t_1 = (t_0 * abs(x)) * abs(x); tmp = abs(((1.0 / sqrt(pi)) * ((((2.0 * abs(x)) + ((2.0 / 3.0) * t_0)) + ((1.0 / 5.0) * t_1)) + ((1.0 / 21.0) * ((t_1 * abs(x)) * abs(x)))))); end
code[x_] := Block[{t$95$0 = N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 5.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / 21.0), $MachinePrecision] * N[(N[(t$95$1 * N[Abs[x], $MachinePrecision]), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|x\right| \cdot \left|x\right|\right) \cdot \left|x\right|\\
t_1 := \left(t\_0 \cdot \left|x\right|\right) \cdot \left|x\right|\\
\left|\frac{1}{\sqrt{\pi}} \cdot \left(\left(\left(2 \cdot \left|x\right| + \frac{2}{3} \cdot t\_0\right) + \frac{1}{5} \cdot t\_1\right) + \frac{1}{21} \cdot \left(\left(t\_1 \cdot \left|x\right|\right) \cdot \left|x\right|\right)\right)\right|
\end{array}
(FPCore (x)
:precision binary64
(fabs
(*
0.5641895835477563
(fma
(* (* (fma (* 0.2 x) x 0.6666666666666666) x) x)
x
(fma (pow x 7.0) 0.047619047619047616 (+ x x))))))double code(double x) {
return fabs((0.5641895835477563 * fma(((fma((0.2 * x), x, 0.6666666666666666) * x) * x), x, fma(pow(x, 7.0), 0.047619047619047616, (x + x)))));
}
function code(x) return abs(Float64(0.5641895835477563 * fma(Float64(Float64(fma(Float64(0.2 * x), x, 0.6666666666666666) * x) * x), x, fma((x ^ 7.0), 0.047619047619047616, Float64(x + x))))) end
code[x_] := N[Abs[N[(0.5641895835477563 * N[(N[(N[(N[(N[(0.2 * x), $MachinePrecision] * x + 0.6666666666666666), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * x + N[(N[Power[x, 7.0], $MachinePrecision] * 0.047619047619047616 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|0.5641895835477563 \cdot \mathsf{fma}\left(\left(\mathsf{fma}\left(0.2 \cdot x, x, 0.6666666666666666\right) \cdot x\right) \cdot x, x, \mathsf{fma}\left({x}^{7}, 0.047619047619047616, x + x\right)\right)\right|
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Evaluated real constant99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6499.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrt73.7%
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f6473.7%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrt99.3%
lift-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
count-2-revN/A
lower-+.f6499.8%
Applied rewrites99.8%
(FPCore (x)
:precision binary64
(fabs
(*
0.5641895835477563
(fma
(* (* x x) 0.6666666666666666)
(fabs x)
(fma 0.047619047619047616 (pow (fabs x) 7.0) (* 2.0 (fabs x)))))))double code(double x) {
return fabs((0.5641895835477563 * fma(((x * x) * 0.6666666666666666), fabs(x), fma(0.047619047619047616, pow(fabs(x), 7.0), (2.0 * fabs(x))))));
}
function code(x) return abs(Float64(0.5641895835477563 * fma(Float64(Float64(x * x) * 0.6666666666666666), abs(x), fma(0.047619047619047616, (abs(x) ^ 7.0), Float64(2.0 * abs(x)))))) end
code[x_] := N[Abs[N[(0.5641895835477563 * N[(N[(N[(x * x), $MachinePrecision] * 0.6666666666666666), $MachinePrecision] * N[Abs[x], $MachinePrecision] + N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|0.5641895835477563 \cdot \mathsf{fma}\left(\left(x \cdot x\right) \cdot 0.6666666666666666, \left|x\right|, \mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)\right)\right|
Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Evaluated real constant99.8%
Taylor expanded in x around 0
Applied rewrites99.1%
(FPCore (x) :precision binary64 (fabs (* 0.5641895835477563 (fma 0.047619047619047616 (pow (fabs x) 7.0) (* 2.0 (fabs x))))))
double code(double x) {
return fabs((0.5641895835477563 * fma(0.047619047619047616, pow(fabs(x), 7.0), (2.0 * fabs(x)))));
}
function code(x) return abs(Float64(0.5641895835477563 * fma(0.047619047619047616, (abs(x) ^ 7.0), Float64(2.0 * abs(x))))) end
code[x_] := N[Abs[N[(0.5641895835477563 * N[(0.047619047619047616 * N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] + N[(2.0 * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|0.5641895835477563 \cdot \mathsf{fma}\left(0.047619047619047616, {\left(\left|x\right|\right)}^{7}, 2 \cdot \left|x\right|\right)\right|
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-pow.f64N/A
lower-fabs.f64N/A
lower-*.f64N/A
lower-fabs.f6498.8%
Applied rewrites98.8%
Evaluated real constant98.8%
(FPCore (x) :precision binary64 (if (<= (fabs x) 11500000000.0) (fabs (* (fabs x) 1.1283791670955126)) (* (/ 1.0 (sqrt PI)) (fabs (* (pow (fabs x) 7.0) 0.047619047619047616)))))
double code(double x) {
double tmp;
if (fabs(x) <= 11500000000.0) {
tmp = fabs((fabs(x) * 1.1283791670955126));
} else {
tmp = (1.0 / sqrt(((double) M_PI))) * fabs((pow(fabs(x), 7.0) * 0.047619047619047616));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 11500000000.0) {
tmp = Math.abs((Math.abs(x) * 1.1283791670955126));
} else {
tmp = (1.0 / Math.sqrt(Math.PI)) * Math.abs((Math.pow(Math.abs(x), 7.0) * 0.047619047619047616));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 11500000000.0: tmp = math.fabs((math.fabs(x) * 1.1283791670955126)) else: tmp = (1.0 / math.sqrt(math.pi)) * math.fabs((math.pow(math.fabs(x), 7.0) * 0.047619047619047616)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 11500000000.0) tmp = abs(Float64(abs(x) * 1.1283791670955126)); else tmp = Float64(Float64(1.0 / sqrt(pi)) * abs(Float64((abs(x) ^ 7.0) * 0.047619047619047616))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 11500000000.0) tmp = abs((abs(x) * 1.1283791670955126)); else tmp = (1.0 / sqrt(pi)) * abs(((abs(x) ^ 7.0) * 0.047619047619047616)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 11500000000.0], N[Abs[N[(N[Abs[x], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]], $MachinePrecision], N[(N[(1.0 / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision] * N[Abs[N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 11500000000:\\
\;\;\;\;\left|\left|x\right| \cdot 1.1283791670955126\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\pi}} \cdot \left|{\left(\left|x\right|\right)}^{7} \cdot 0.047619047619047616\right|\\
\end{array}
if x < 1.15e10Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
if 1.15e10 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f6437.3%
Applied rewrites37.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow3N/A
pow3N/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f6437.3%
Applied rewrites37.3%
Applied rewrites37.3%
(FPCore (x) :precision binary64 (if (<= (fabs x) 11500000000.0) (fabs (* (fabs x) 1.1283791670955126)) (/ (fabs (* (pow (fabs x) 7.0) 0.047619047619047616)) (sqrt PI))))
double code(double x) {
double tmp;
if (fabs(x) <= 11500000000.0) {
tmp = fabs((fabs(x) * 1.1283791670955126));
} else {
tmp = fabs((pow(fabs(x), 7.0) * 0.047619047619047616)) / sqrt(((double) M_PI));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 11500000000.0) {
tmp = Math.abs((Math.abs(x) * 1.1283791670955126));
} else {
tmp = Math.abs((Math.pow(Math.abs(x), 7.0) * 0.047619047619047616)) / Math.sqrt(Math.PI);
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 11500000000.0: tmp = math.fabs((math.fabs(x) * 1.1283791670955126)) else: tmp = math.fabs((math.pow(math.fabs(x), 7.0) * 0.047619047619047616)) / math.sqrt(math.pi) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 11500000000.0) tmp = abs(Float64(abs(x) * 1.1283791670955126)); else tmp = Float64(abs(Float64((abs(x) ^ 7.0) * 0.047619047619047616)) / sqrt(pi)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 11500000000.0) tmp = abs((abs(x) * 1.1283791670955126)); else tmp = abs(((abs(x) ^ 7.0) * 0.047619047619047616)) / sqrt(pi); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 11500000000.0], N[Abs[N[(N[Abs[x], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]], $MachinePrecision], N[(N[Abs[N[(N[Power[N[Abs[x], $MachinePrecision], 7.0], $MachinePrecision] * 0.047619047619047616), $MachinePrecision]], $MachinePrecision] / N[Sqrt[Pi], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 11500000000:\\
\;\;\;\;\left|\left|x\right| \cdot 1.1283791670955126\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\left|{\left(\left|x\right|\right)}^{7} \cdot 0.047619047619047616\right|}{\sqrt{\pi}}\\
\end{array}
if x < 1.15e10Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
if 1.15e10 < x Initial program 99.8%
Applied rewrites99.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f6437.3%
Applied rewrites37.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
pow3N/A
pow3N/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lower-*.f6437.3%
Applied rewrites37.3%
lift-*.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
lower-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
Applied rewrites37.3%
(FPCore (x) :precision binary64 (if (<= (fabs x) 11500000000.0) (fabs (* (fabs x) 1.1283791670955126)) (fabs (* 0.11283791670955126 (* (pow (fabs x) 4.0) (fabs (fabs x)))))))
double code(double x) {
double tmp;
if (fabs(x) <= 11500000000.0) {
tmp = fabs((fabs(x) * 1.1283791670955126));
} else {
tmp = fabs((0.11283791670955126 * (pow(fabs(x), 4.0) * fabs(fabs(x)))));
}
return tmp;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (abs(x) <= 11500000000.0d0) then
tmp = abs((abs(x) * 1.1283791670955126d0))
else
tmp = abs((0.11283791670955126d0 * ((abs(x) ** 4.0d0) * abs(abs(x)))))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 11500000000.0) {
tmp = Math.abs((Math.abs(x) * 1.1283791670955126));
} else {
tmp = Math.abs((0.11283791670955126 * (Math.pow(Math.abs(x), 4.0) * Math.abs(Math.abs(x)))));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 11500000000.0: tmp = math.fabs((math.fabs(x) * 1.1283791670955126)) else: tmp = math.fabs((0.11283791670955126 * (math.pow(math.fabs(x), 4.0) * math.fabs(math.fabs(x))))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 11500000000.0) tmp = abs(Float64(abs(x) * 1.1283791670955126)); else tmp = abs(Float64(0.11283791670955126 * Float64((abs(x) ^ 4.0) * abs(abs(x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 11500000000.0) tmp = abs((abs(x) * 1.1283791670955126)); else tmp = abs((0.11283791670955126 * ((abs(x) ^ 4.0) * abs(abs(x))))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 11500000000.0], N[Abs[N[(N[Abs[x], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]], $MachinePrecision], N[Abs[N[(0.11283791670955126 * N[(N[Power[N[Abs[x], $MachinePrecision], 4.0], $MachinePrecision] * N[Abs[N[Abs[x], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 11500000000:\\
\;\;\;\;\left|\left|x\right| \cdot 1.1283791670955126\right|\\
\mathbf{else}:\\
\;\;\;\;\left|0.11283791670955126 \cdot \left({\left(\left|x\right|\right)}^{4} \cdot \left|\left|x\right|\right|\right)\right|\\
\end{array}
if x < 1.15e10Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
if 1.15e10 < x Initial program 99.8%
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Evaluated real constant99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-fabs.f6431.5%
Applied rewrites31.5%
(FPCore (x) :precision binary64 (if (<= (fabs x) 2e-7) (fabs (* (fabs x) 1.1283791670955126)) (fabs (* 2.0 (sqrt (/ (* (fabs x) (fabs x)) PI))))))
double code(double x) {
double tmp;
if (fabs(x) <= 2e-7) {
tmp = fabs((fabs(x) * 1.1283791670955126));
} else {
tmp = fabs((2.0 * sqrt(((fabs(x) * fabs(x)) / ((double) M_PI)))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 2e-7) {
tmp = Math.abs((Math.abs(x) * 1.1283791670955126));
} else {
tmp = Math.abs((2.0 * Math.sqrt(((Math.abs(x) * Math.abs(x)) / Math.PI))));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 2e-7: tmp = math.fabs((math.fabs(x) * 1.1283791670955126)) else: tmp = math.fabs((2.0 * math.sqrt(((math.fabs(x) * math.fabs(x)) / math.pi)))) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 2e-7) tmp = abs(Float64(abs(x) * 1.1283791670955126)); else tmp = abs(Float64(2.0 * sqrt(Float64(Float64(abs(x) * abs(x)) / pi)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 2e-7) tmp = abs((abs(x) * 1.1283791670955126)); else tmp = abs((2.0 * sqrt(((abs(x) * abs(x)) / pi)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 2e-7], N[Abs[N[(N[Abs[x], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]], $MachinePrecision], N[Abs[N[(2.0 * N[Sqrt[N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] / Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\left|\left|x\right| \cdot 1.1283791670955126\right|\\
\mathbf{else}:\\
\;\;\;\;\left|2 \cdot \sqrt{\frac{\left|x\right| \cdot \left|x\right|}{\pi}}\right|\\
\end{array}
if x < 1.9999999999999999e-7Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
if 1.9999999999999999e-7 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lower-sqrt.f64N/A
lower-/.f6453.7%
Applied rewrites53.7%
(FPCore (x) :precision binary64 (let* ((t_0 (* (fabs x) 1.1283791670955126))) (if (<= (fabs x) 5e+146) (fabs t_0) (sqrt (* t_0 t_0)))))
double code(double x) {
double t_0 = fabs(x) * 1.1283791670955126;
double tmp;
if (fabs(x) <= 5e+146) {
tmp = fabs(t_0);
} else {
tmp = sqrt((t_0 * t_0));
}
return tmp;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = abs(x) * 1.1283791670955126d0
if (abs(x) <= 5d+146) then
tmp = abs(t_0)
else
tmp = sqrt((t_0 * t_0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.abs(x) * 1.1283791670955126;
double tmp;
if (Math.abs(x) <= 5e+146) {
tmp = Math.abs(t_0);
} else {
tmp = Math.sqrt((t_0 * t_0));
}
return tmp;
}
def code(x): t_0 = math.fabs(x) * 1.1283791670955126 tmp = 0 if math.fabs(x) <= 5e+146: tmp = math.fabs(t_0) else: tmp = math.sqrt((t_0 * t_0)) return tmp
function code(x) t_0 = Float64(abs(x) * 1.1283791670955126) tmp = 0.0 if (abs(x) <= 5e+146) tmp = abs(t_0); else tmp = sqrt(Float64(t_0 * t_0)); end return tmp end
function tmp_2 = code(x) t_0 = abs(x) * 1.1283791670955126; tmp = 0.0; if (abs(x) <= 5e+146) tmp = abs(t_0); else tmp = sqrt((t_0 * t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Abs[x], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 5e+146], N[Abs[t$95$0], $MachinePrecision], N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \left|x\right| \cdot 1.1283791670955126\\
\mathbf{if}\;\left|x\right| \leq 5 \cdot 10^{+146}:\\
\;\;\;\;\left|t\_0\right|\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_0 \cdot t\_0}\\
\end{array}
if x < 4.9999999999999999e146Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
if 4.9999999999999999e146 < x Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
Applied rewrites53.8%
(FPCore (x) :precision binary64 (fabs (* x 1.1283791670955126)))
double code(double x) {
return fabs((x * 1.1283791670955126));
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = abs((x * 1.1283791670955126d0))
end function
public static double code(double x) {
return Math.abs((x * 1.1283791670955126));
}
def code(x): return math.fabs((x * 1.1283791670955126))
function code(x) return abs(Float64(x * 1.1283791670955126)) end
function tmp = code(x) tmp = abs((x * 1.1283791670955126)); end
code[x_] := N[Abs[N[(x * 1.1283791670955126), $MachinePrecision]], $MachinePrecision]
\left|x \cdot 1.1283791670955126\right|
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
lower-sqrt.f64N/A
lower-PI.f6466.8%
Applied rewrites66.8%
Evaluated real constant67.0%
lift-*.f64N/A
lift-/.f64N/A
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-unprodN/A
rem-square-sqrtN/A
associate-*r/N/A
count-2-revN/A
div-add-revN/A
mult-flipN/A
mult-flipN/A
distribute-lft-outN/A
lower-*.f64N/A
metadata-evalN/A
metadata-evalN/A
metadata-eval67.2%
Applied rewrites67.2%
herbie shell --seed 2025209
(FPCore (x)
:name "Jmat.Real.erfi, branch x less than or equal to 0.5"
:precision binary64
:pre (<= x 0.5)
(fabs (* (/ 1.0 (sqrt PI)) (+ (+ (+ (* 2.0 (fabs x)) (* (/ 2.0 3.0) (* (* (fabs x) (fabs x)) (fabs x)))) (* (/ 1.0 5.0) (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)))) (* (/ 1.0 21.0) (* (* (* (* (* (* (fabs x) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)) (fabs x)))))))