
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y): return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y) return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y)))) end
function tmp = code(c, x, y) tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y))); end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (c x y) :precision binary64 (* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))
double code(double c, double x, double y) {
return c * log((1.0 + ((pow(((double) M_E), x) - 1.0) * y)));
}
public static double code(double c, double x, double y) {
return c * Math.log((1.0 + ((Math.pow(Math.E, x) - 1.0) * y)));
}
def code(c, x, y): return c * math.log((1.0 + ((math.pow(math.e, x) - 1.0) * y)))
function code(c, x, y) return Float64(c * log(Float64(1.0 + Float64(Float64((exp(1) ^ x) - 1.0) * y)))) end
function tmp = code(c, x, y) tmp = c * log((1.0 + (((2.71828182845904523536 ^ x) - 1.0) * y))); end
code[c_, x_, y_] := N[(c * N[Log[N[(1.0 + N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
c \cdot \log \left(1 + \left({e}^{x} - 1\right) \cdot y\right)
(FPCore (c x y)
:precision binary64
(let* ((t_0 (- (exp x) 1.0))
(t_1 (pow t_0 2.0))
(t_2 (* (- (pow E x) 1.0) y)))
(if (<= t_2 -4e-295)
(*
(*
(-
(* (* t_1 (+ (* (* 0.3333333333333333 y) t_0) -0.5)) y)
(- 1.0 (exp x)))
y)
c)
(if (<= t_2 0.0)
(* (* x (+ c (* c (* x (+ 0.5 (* -0.5 y)))))) y)
(if (<= t_2 2e-8)
(* (* c (+ t_0 (* (* t_1 -0.5) y))) y)
(* (log (- (* y t_0) -1.0)) c))))))double code(double c, double x, double y) {
double t_0 = exp(x) - 1.0;
double t_1 = pow(t_0, 2.0);
double t_2 = (pow(((double) M_E), x) - 1.0) * y;
double tmp;
if (t_2 <= -4e-295) {
tmp = ((((t_1 * (((0.3333333333333333 * y) * t_0) + -0.5)) * y) - (1.0 - exp(x))) * y) * c;
} else if (t_2 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_2 <= 2e-8) {
tmp = (c * (t_0 + ((t_1 * -0.5) * y))) * y;
} else {
tmp = log(((y * t_0) - -1.0)) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = Math.exp(x) - 1.0;
double t_1 = Math.pow(t_0, 2.0);
double t_2 = (Math.pow(Math.E, x) - 1.0) * y;
double tmp;
if (t_2 <= -4e-295) {
tmp = ((((t_1 * (((0.3333333333333333 * y) * t_0) + -0.5)) * y) - (1.0 - Math.exp(x))) * y) * c;
} else if (t_2 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_2 <= 2e-8) {
tmp = (c * (t_0 + ((t_1 * -0.5) * y))) * y;
} else {
tmp = Math.log(((y * t_0) - -1.0)) * c;
}
return tmp;
}
def code(c, x, y): t_0 = math.exp(x) - 1.0 t_1 = math.pow(t_0, 2.0) t_2 = (math.pow(math.e, x) - 1.0) * y tmp = 0 if t_2 <= -4e-295: tmp = ((((t_1 * (((0.3333333333333333 * y) * t_0) + -0.5)) * y) - (1.0 - math.exp(x))) * y) * c elif t_2 <= 0.0: tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y elif t_2 <= 2e-8: tmp = (c * (t_0 + ((t_1 * -0.5) * y))) * y else: tmp = math.log(((y * t_0) - -1.0)) * c return tmp
function code(c, x, y) t_0 = Float64(exp(x) - 1.0) t_1 = t_0 ^ 2.0 t_2 = Float64(Float64((exp(1) ^ x) - 1.0) * y) tmp = 0.0 if (t_2 <= -4e-295) tmp = Float64(Float64(Float64(Float64(Float64(t_1 * Float64(Float64(Float64(0.3333333333333333 * y) * t_0) + -0.5)) * y) - Float64(1.0 - exp(x))) * y) * c); elseif (t_2 <= 0.0) tmp = Float64(Float64(x * Float64(c + Float64(c * Float64(x * Float64(0.5 + Float64(-0.5 * y)))))) * y); elseif (t_2 <= 2e-8) tmp = Float64(Float64(c * Float64(t_0 + Float64(Float64(t_1 * -0.5) * y))) * y); else tmp = Float64(log(Float64(Float64(y * t_0) - -1.0)) * c); end return tmp end
function tmp_2 = code(c, x, y) t_0 = exp(x) - 1.0; t_1 = t_0 ^ 2.0; t_2 = ((2.71828182845904523536 ^ x) - 1.0) * y; tmp = 0.0; if (t_2 <= -4e-295) tmp = ((((t_1 * (((0.3333333333333333 * y) * t_0) + -0.5)) * y) - (1.0 - exp(x))) * y) * c; elseif (t_2 <= 0.0) tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y; elseif (t_2 <= 2e-8) tmp = (c * (t_0 + ((t_1 * -0.5) * y))) * y; else tmp = log(((y * t_0) - -1.0)) * c; end tmp_2 = tmp; end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$2, -4e-295], N[(N[(N[(N[(N[(t$95$1 * N[(N[(N[(0.3333333333333333 * y), $MachinePrecision] * t$95$0), $MachinePrecision] + -0.5), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - N[(1.0 - N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * c), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(x * N[(c + N[(c * N[(x * N[(0.5 + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$2, 2e-8], N[(N[(c * N[(t$95$0 + N[(N[(t$95$1 * -0.5), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Log[N[(N[(y * t$95$0), $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := e^{x} - 1\\
t_1 := {t\_0}^{2}\\
t_2 := \left({e}^{x} - 1\right) \cdot y\\
\mathbf{if}\;t\_2 \leq -4 \cdot 10^{-295}:\\
\;\;\;\;\left(\left(\left(t\_1 \cdot \left(\left(0.3333333333333333 \cdot y\right) \cdot t\_0 + -0.5\right)\right) \cdot y - \left(1 - e^{x}\right)\right) \cdot y\right) \cdot c\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\left(x \cdot \left(c + c \cdot \left(x \cdot \left(0.5 + -0.5 \cdot y\right)\right)\right)\right) \cdot y\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\left(c \cdot \left(t\_0 + \left(t\_1 \cdot -0.5\right) \cdot y\right)\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\log \left(y \cdot t\_0 - -1\right) \cdot c\\
\end{array}
if (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -4.0000000000000002e-295Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f64N/A
Applied rewrites45.4%
Applied rewrites45.4%
if -4.0000000000000002e-295 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -0.0Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6458.3%
Applied rewrites58.3%
if -0.0 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < 2e-8Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
if 2e-8 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) Initial program 41.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
metadata-eval41.2%
Applied rewrites41.2%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (- (exp x) 1.0))
(t_1 (* (- (pow E x) 1.0) y))
(t_2 (* (* c (+ t_0 (* (* (pow t_0 2.0) -0.5) y))) y)))
(if (<= t_1 -4e-295)
t_2
(if (<= t_1 0.0)
(* (* x (+ c (* c (* x (+ 0.5 (* -0.5 y)))))) y)
(if (<= t_1 2e-8) t_2 (* (log (- (* y t_0) -1.0)) c))))))double code(double c, double x, double y) {
double t_0 = exp(x) - 1.0;
double t_1 = (pow(((double) M_E), x) - 1.0) * y;
double t_2 = (c * (t_0 + ((pow(t_0, 2.0) * -0.5) * y))) * y;
double tmp;
if (t_1 <= -4e-295) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_1 <= 2e-8) {
tmp = t_2;
} else {
tmp = log(((y * t_0) - -1.0)) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = Math.exp(x) - 1.0;
double t_1 = (Math.pow(Math.E, x) - 1.0) * y;
double t_2 = (c * (t_0 + ((Math.pow(t_0, 2.0) * -0.5) * y))) * y;
double tmp;
if (t_1 <= -4e-295) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_1 <= 2e-8) {
tmp = t_2;
} else {
tmp = Math.log(((y * t_0) - -1.0)) * c;
}
return tmp;
}
def code(c, x, y): t_0 = math.exp(x) - 1.0 t_1 = (math.pow(math.e, x) - 1.0) * y t_2 = (c * (t_0 + ((math.pow(t_0, 2.0) * -0.5) * y))) * y tmp = 0 if t_1 <= -4e-295: tmp = t_2 elif t_1 <= 0.0: tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y elif t_1 <= 2e-8: tmp = t_2 else: tmp = math.log(((y * t_0) - -1.0)) * c return tmp
function code(c, x, y) t_0 = Float64(exp(x) - 1.0) t_1 = Float64(Float64((exp(1) ^ x) - 1.0) * y) t_2 = Float64(Float64(c * Float64(t_0 + Float64(Float64((t_0 ^ 2.0) * -0.5) * y))) * y) tmp = 0.0 if (t_1 <= -4e-295) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(x * Float64(c + Float64(c * Float64(x * Float64(0.5 + Float64(-0.5 * y)))))) * y); elseif (t_1 <= 2e-8) tmp = t_2; else tmp = Float64(log(Float64(Float64(y * t_0) - -1.0)) * c); end return tmp end
function tmp_2 = code(c, x, y) t_0 = exp(x) - 1.0; t_1 = ((2.71828182845904523536 ^ x) - 1.0) * y; t_2 = (c * (t_0 + (((t_0 ^ 2.0) * -0.5) * y))) * y; tmp = 0.0; if (t_1 <= -4e-295) tmp = t_2; elseif (t_1 <= 0.0) tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y; elseif (t_1 <= 2e-8) tmp = t_2; else tmp = log(((y * t_0) - -1.0)) * c; end tmp_2 = tmp; end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * N[(t$95$0 + N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] * -0.5), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-295], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(x * N[(c + N[(c * N[(x * N[(0.5 + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 2e-8], t$95$2, N[(N[Log[N[(N[(y * t$95$0), $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := e^{x} - 1\\
t_1 := \left({e}^{x} - 1\right) \cdot y\\
t_2 := \left(c \cdot \left(t\_0 + \left({t\_0}^{2} \cdot -0.5\right) \cdot y\right)\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-295}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(x \cdot \left(c + c \cdot \left(x \cdot \left(0.5 + -0.5 \cdot y\right)\right)\right)\right) \cdot y\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\log \left(y \cdot t\_0 - -1\right) \cdot c\\
\end{array}
if (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -4.0000000000000002e-295 or -0.0 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < 2e-8Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
if -4.0000000000000002e-295 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -0.0Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6458.3%
Applied rewrites58.3%
if 2e-8 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) Initial program 41.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
metadata-eval41.2%
Applied rewrites41.2%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (- (pow E x) 1.0) y)))
(if (<= t_0 -4e-295)
(* c (* y (/ (- (exp (+ x x)) 1.0) (+ (exp x) 1.0))))
(if (<= t_0 0.0)
(* (* x (+ c (* c (* x (+ 0.5 (* -0.5 y)))))) y)
(if (<= t_0 2e-22)
(- (* (* y c) (exp x)) (* (* y c) 1.0))
(*
c
(-
(log (+ (* (* y (- (exp x) 1.0)) 2.0) 2.0))
(log 2.0))))))))double code(double c, double x, double y) {
double t_0 = (pow(((double) M_E), x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = c * (y * ((exp((x + x)) - 1.0) / (exp(x) + 1.0)));
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * exp(x)) - ((y * c) * 1.0);
} else {
tmp = c * (log((((y * (exp(x) - 1.0)) * 2.0) + 2.0)) - log(2.0));
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = (Math.pow(Math.E, x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = c * (y * ((Math.exp((x + x)) - 1.0) / (Math.exp(x) + 1.0)));
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * Math.exp(x)) - ((y * c) * 1.0);
} else {
tmp = c * (Math.log((((y * (Math.exp(x) - 1.0)) * 2.0) + 2.0)) - Math.log(2.0));
}
return tmp;
}
def code(c, x, y): t_0 = (math.pow(math.e, x) - 1.0) * y tmp = 0 if t_0 <= -4e-295: tmp = c * (y * ((math.exp((x + x)) - 1.0) / (math.exp(x) + 1.0))) elif t_0 <= 0.0: tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y elif t_0 <= 2e-22: tmp = ((y * c) * math.exp(x)) - ((y * c) * 1.0) else: tmp = c * (math.log((((y * (math.exp(x) - 1.0)) * 2.0) + 2.0)) - math.log(2.0)) return tmp
function code(c, x, y) t_0 = Float64(Float64((exp(1) ^ x) - 1.0) * y) tmp = 0.0 if (t_0 <= -4e-295) tmp = Float64(c * Float64(y * Float64(Float64(exp(Float64(x + x)) - 1.0) / Float64(exp(x) + 1.0)))); elseif (t_0 <= 0.0) tmp = Float64(Float64(x * Float64(c + Float64(c * Float64(x * Float64(0.5 + Float64(-0.5 * y)))))) * y); elseif (t_0 <= 2e-22) tmp = Float64(Float64(Float64(y * c) * exp(x)) - Float64(Float64(y * c) * 1.0)); else tmp = Float64(c * Float64(log(Float64(Float64(Float64(y * Float64(exp(x) - 1.0)) * 2.0) + 2.0)) - log(2.0))); end return tmp end
function tmp_2 = code(c, x, y) t_0 = ((2.71828182845904523536 ^ x) - 1.0) * y; tmp = 0.0; if (t_0 <= -4e-295) tmp = c * (y * ((exp((x + x)) - 1.0) / (exp(x) + 1.0))); elseif (t_0 <= 0.0) tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y; elseif (t_0 <= 2e-22) tmp = ((y * c) * exp(x)) - ((y * c) * 1.0); else tmp = c * (log((((y * (exp(x) - 1.0)) * 2.0) + 2.0)) - log(2.0)); end tmp_2 = tmp; end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-295], N[(c * N[(y * N[(N[(N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(x * N[(c + N[(c * N[(x * N[(0.5 + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e-22], N[(N[(N[(y * c), $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision] - N[(N[(y * c), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(c * N[(N[Log[N[(N[(N[(y * N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision] - N[Log[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left({e}^{x} - 1\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-295}:\\
\;\;\;\;c \cdot \left(y \cdot \frac{e^{x + x} - 1}{e^{x} + 1}\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(x \cdot \left(c + c \cdot \left(x \cdot \left(0.5 + -0.5 \cdot y\right)\right)\right)\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\left(y \cdot c\right) \cdot e^{x} - \left(y \cdot c\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(\log \left(\left(y \cdot \left(e^{x} - 1\right)\right) \cdot 2 + 2\right) - \log 2\right)\\
\end{array}
if (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -4.0000000000000002e-295Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites45.3%
if -4.0000000000000002e-295 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -0.0Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6458.3%
Applied rewrites58.3%
if -0.0 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < 2.0000000000000001e-22Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
if 2.0000000000000001e-22 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) Initial program 41.2%
lift-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
metadata-evalN/A
add-to-fractionN/A
log-divN/A
lower-unsound--.f64N/A
Applied rewrites41.2%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (- (pow E x) 1.0) y)))
(if (<= t_0 -4e-295)
(* c (* y (/ (- (exp (+ x x)) 1.0) (+ (exp x) 1.0))))
(if (<= t_0 0.0)
(* (* x (+ c (* c (* x (+ 0.5 (* -0.5 y)))))) y)
(if (<= t_0 2e-22)
(- (* (* y c) (exp x)) (* (* y c) 1.0))
(* (log (- (* y (- (exp x) 1.0)) -1.0)) c))))))double code(double c, double x, double y) {
double t_0 = (pow(((double) M_E), x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = c * (y * ((exp((x + x)) - 1.0) / (exp(x) + 1.0)));
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * exp(x)) - ((y * c) * 1.0);
} else {
tmp = log(((y * (exp(x) - 1.0)) - -1.0)) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = (Math.pow(Math.E, x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = c * (y * ((Math.exp((x + x)) - 1.0) / (Math.exp(x) + 1.0)));
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * Math.exp(x)) - ((y * c) * 1.0);
} else {
tmp = Math.log(((y * (Math.exp(x) - 1.0)) - -1.0)) * c;
}
return tmp;
}
def code(c, x, y): t_0 = (math.pow(math.e, x) - 1.0) * y tmp = 0 if t_0 <= -4e-295: tmp = c * (y * ((math.exp((x + x)) - 1.0) / (math.exp(x) + 1.0))) elif t_0 <= 0.0: tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y elif t_0 <= 2e-22: tmp = ((y * c) * math.exp(x)) - ((y * c) * 1.0) else: tmp = math.log(((y * (math.exp(x) - 1.0)) - -1.0)) * c return tmp
function code(c, x, y) t_0 = Float64(Float64((exp(1) ^ x) - 1.0) * y) tmp = 0.0 if (t_0 <= -4e-295) tmp = Float64(c * Float64(y * Float64(Float64(exp(Float64(x + x)) - 1.0) / Float64(exp(x) + 1.0)))); elseif (t_0 <= 0.0) tmp = Float64(Float64(x * Float64(c + Float64(c * Float64(x * Float64(0.5 + Float64(-0.5 * y)))))) * y); elseif (t_0 <= 2e-22) tmp = Float64(Float64(Float64(y * c) * exp(x)) - Float64(Float64(y * c) * 1.0)); else tmp = Float64(log(Float64(Float64(y * Float64(exp(x) - 1.0)) - -1.0)) * c); end return tmp end
function tmp_2 = code(c, x, y) t_0 = ((2.71828182845904523536 ^ x) - 1.0) * y; tmp = 0.0; if (t_0 <= -4e-295) tmp = c * (y * ((exp((x + x)) - 1.0) / (exp(x) + 1.0))); elseif (t_0 <= 0.0) tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y; elseif (t_0 <= 2e-22) tmp = ((y * c) * exp(x)) - ((y * c) * 1.0); else tmp = log(((y * (exp(x) - 1.0)) - -1.0)) * c; end tmp_2 = tmp; end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-295], N[(c * N[(y * N[(N[(N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(x * N[(c + N[(c * N[(x * N[(0.5 + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e-22], N[(N[(N[(y * c), $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision] - N[(N[(y * c), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(y * N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left({e}^{x} - 1\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-295}:\\
\;\;\;\;c \cdot \left(y \cdot \frac{e^{x + x} - 1}{e^{x} + 1}\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(x \cdot \left(c + c \cdot \left(x \cdot \left(0.5 + -0.5 \cdot y\right)\right)\right)\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\left(y \cdot c\right) \cdot e^{x} - \left(y \cdot c\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\log \left(y \cdot \left(e^{x} - 1\right) - -1\right) \cdot c\\
\end{array}
if (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -4.0000000000000002e-295Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites45.3%
if -4.0000000000000002e-295 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -0.0Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6458.3%
Applied rewrites58.3%
if -0.0 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < 2.0000000000000001e-22Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
if 2.0000000000000001e-22 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) Initial program 41.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
metadata-eval41.2%
Applied rewrites41.2%
(FPCore (c x y)
:precision binary64
(let* ((t_0 (* (- (pow E x) 1.0) y)))
(if (<= t_0 -4e-295)
(* y (- (* (exp x) c) c))
(if (<= t_0 0.0)
(* (* x (+ c (* c (* x (+ 0.5 (* -0.5 y)))))) y)
(if (<= t_0 2e-22)
(- (* (* y c) (exp x)) (* (* y c) 1.0))
(* (log (- (* y (- (exp x) 1.0)) -1.0)) c))))))double code(double c, double x, double y) {
double t_0 = (pow(((double) M_E), x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = y * ((exp(x) * c) - c);
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * exp(x)) - ((y * c) * 1.0);
} else {
tmp = log(((y * (exp(x) - 1.0)) - -1.0)) * c;
}
return tmp;
}
public static double code(double c, double x, double y) {
double t_0 = (Math.pow(Math.E, x) - 1.0) * y;
double tmp;
if (t_0 <= -4e-295) {
tmp = y * ((Math.exp(x) * c) - c);
} else if (t_0 <= 0.0) {
tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y;
} else if (t_0 <= 2e-22) {
tmp = ((y * c) * Math.exp(x)) - ((y * c) * 1.0);
} else {
tmp = Math.log(((y * (Math.exp(x) - 1.0)) - -1.0)) * c;
}
return tmp;
}
def code(c, x, y): t_0 = (math.pow(math.e, x) - 1.0) * y tmp = 0 if t_0 <= -4e-295: tmp = y * ((math.exp(x) * c) - c) elif t_0 <= 0.0: tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y elif t_0 <= 2e-22: tmp = ((y * c) * math.exp(x)) - ((y * c) * 1.0) else: tmp = math.log(((y * (math.exp(x) - 1.0)) - -1.0)) * c return tmp
function code(c, x, y) t_0 = Float64(Float64((exp(1) ^ x) - 1.0) * y) tmp = 0.0 if (t_0 <= -4e-295) tmp = Float64(y * Float64(Float64(exp(x) * c) - c)); elseif (t_0 <= 0.0) tmp = Float64(Float64(x * Float64(c + Float64(c * Float64(x * Float64(0.5 + Float64(-0.5 * y)))))) * y); elseif (t_0 <= 2e-22) tmp = Float64(Float64(Float64(y * c) * exp(x)) - Float64(Float64(y * c) * 1.0)); else tmp = Float64(log(Float64(Float64(y * Float64(exp(x) - 1.0)) - -1.0)) * c); end return tmp end
function tmp_2 = code(c, x, y) t_0 = ((2.71828182845904523536 ^ x) - 1.0) * y; tmp = 0.0; if (t_0 <= -4e-295) tmp = y * ((exp(x) * c) - c); elseif (t_0 <= 0.0) tmp = (x * (c + (c * (x * (0.5 + (-0.5 * y)))))) * y; elseif (t_0 <= 2e-22) tmp = ((y * c) * exp(x)) - ((y * c) * 1.0); else tmp = log(((y * (exp(x) - 1.0)) - -1.0)) * c; end tmp_2 = tmp; end
code[c_, x_, y_] := Block[{t$95$0 = N[(N[(N[Power[E, x], $MachinePrecision] - 1.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -4e-295], N[(y * N[(N[(N[Exp[x], $MachinePrecision] * c), $MachinePrecision] - c), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(x * N[(c + N[(c * N[(x * N[(0.5 + N[(-0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$0, 2e-22], N[(N[(N[(y * c), $MachinePrecision] * N[Exp[x], $MachinePrecision]), $MachinePrecision] - N[(N[(y * c), $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(y * N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left({e}^{x} - 1\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-295}:\\
\;\;\;\;y \cdot \left(e^{x} \cdot c - c\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(x \cdot \left(c + c \cdot \left(x \cdot \left(0.5 + -0.5 \cdot y\right)\right)\right)\right) \cdot y\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\left(y \cdot c\right) \cdot e^{x} - \left(y \cdot c\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\log \left(y \cdot \left(e^{x} - 1\right) - -1\right) \cdot c\\
\end{array}
if (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -4.0000000000000002e-295Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6445.3%
Applied rewrites45.3%
if -4.0000000000000002e-295 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < -0.0Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6458.3%
Applied rewrites58.3%
if -0.0 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) < 2.0000000000000001e-22Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
if 2.0000000000000001e-22 < (*.f64 (-.f64 (pow.f64 (E.f64) x) #s(literal 1 binary64)) y) Initial program 41.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6441.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
metadata-eval41.2%
Applied rewrites41.2%
(FPCore (c x y)
:precision binary64
(if (<= x -820.0)
(* y (- (* (exp x) c) c))
(if (<= x -2.55e-49)
(* (log (- (* x y) -1.0)) c)
(*
(*
x
(*
c
(+
1.0
(*
x
(+
0.5
(+
(* -0.5 y)
(*
x
(+
0.16666666666666666
(+
(* -0.5 y)
(*
x
(+
0.041666666666666664
(* -0.2916666666666667 y))))))))))))
y))))double code(double c, double x, double y) {
double tmp;
if (x <= -820.0) {
tmp = y * ((exp(x) * c) - c);
} else if (x <= -2.55e-49) {
tmp = log(((x * y) - -1.0)) * c;
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
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(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-820.0d0)) then
tmp = y * ((exp(x) * c) - c)
else if (x <= (-2.55d-49)) then
tmp = log(((x * y) - (-1.0d0))) * c
else
tmp = (x * (c * (1.0d0 + (x * (0.5d0 + (((-0.5d0) * y) + (x * (0.16666666666666666d0 + (((-0.5d0) * y) + (x * (0.041666666666666664d0 + ((-0.2916666666666667d0) * y)))))))))))) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (x <= -820.0) {
tmp = y * ((Math.exp(x) * c) - c);
} else if (x <= -2.55e-49) {
tmp = Math.log(((x * y) - -1.0)) * c;
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -820.0: tmp = y * ((math.exp(x) * c) - c) elif x <= -2.55e-49: tmp = math.log(((x * y) - -1.0)) * c else: tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y return tmp
function code(c, x, y) tmp = 0.0 if (x <= -820.0) tmp = Float64(y * Float64(Float64(exp(x) * c) - c)); elseif (x <= -2.55e-49) tmp = Float64(log(Float64(Float64(x * y) - -1.0)) * c); else tmp = Float64(Float64(x * Float64(c * Float64(1.0 + Float64(x * Float64(0.5 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.16666666666666666 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.041666666666666664 + Float64(-0.2916666666666667 * y)))))))))))) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (x <= -820.0) tmp = y * ((exp(x) * c) - c); elseif (x <= -2.55e-49) tmp = log(((x * y) - -1.0)) * c; else tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[x, -820.0], N[(y * N[(N[(N[Exp[x], $MachinePrecision] * c), $MachinePrecision] - c), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.55e-49], N[(N[Log[N[(N[(x * y), $MachinePrecision] - -1.0), $MachinePrecision]], $MachinePrecision] * c), $MachinePrecision], N[(N[(x * N[(c * N[(1.0 + N[(x * N[(0.5 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.16666666666666666 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.041666666666666664 + N[(-0.2916666666666667 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -820:\\
\;\;\;\;y \cdot \left(e^{x} \cdot c - c\right)\\
\mathbf{elif}\;x \leq -2.55 \cdot 10^{-49}:\\
\;\;\;\;\log \left(x \cdot y - -1\right) \cdot c\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(c \cdot \left(1 + x \cdot \left(0.5 + \left(-0.5 \cdot y + x \cdot \left(0.16666666666666666 + \left(-0.5 \cdot y + x \cdot \left(0.041666666666666664 + -0.2916666666666667 \cdot y\right)\right)\right)\right)\right)\right)\right)\right) \cdot y\\
\end{array}
if x < -820Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6445.3%
Applied rewrites45.3%
if -820 < x < -2.5500000000000001e-49Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6440.2%
Applied rewrites40.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.2%
Applied rewrites40.2%
if -2.5500000000000001e-49 < x Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites54.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
Applied rewrites57.9%
(FPCore (c x y)
:precision binary64
(if (<= x -1.78e-10)
(* (* (- (exp x) 1.0) c) y)
(*
(*
x
(*
c
(+
1.0
(*
x
(+
0.5
(+
(* -0.5 y)
(*
x
(+
0.16666666666666666
(+
(* -0.5 y)
(*
x
(+
0.041666666666666664
(* -0.2916666666666667 y))))))))))))
y)))double code(double c, double x, double y) {
double tmp;
if (x <= -1.78e-10) {
tmp = ((exp(x) - 1.0) * c) * y;
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
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(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.78d-10)) then
tmp = ((exp(x) - 1.0d0) * c) * y
else
tmp = (x * (c * (1.0d0 + (x * (0.5d0 + (((-0.5d0) * y) + (x * (0.16666666666666666d0 + (((-0.5d0) * y) + (x * (0.041666666666666664d0 + ((-0.2916666666666667d0) * y)))))))))))) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (x <= -1.78e-10) {
tmp = ((Math.exp(x) - 1.0) * c) * y;
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -1.78e-10: tmp = ((math.exp(x) - 1.0) * c) * y else: tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y return tmp
function code(c, x, y) tmp = 0.0 if (x <= -1.78e-10) tmp = Float64(Float64(Float64(exp(x) - 1.0) * c) * y); else tmp = Float64(Float64(x * Float64(c * Float64(1.0 + Float64(x * Float64(0.5 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.16666666666666666 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.041666666666666664 + Float64(-0.2916666666666667 * y)))))))))))) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (x <= -1.78e-10) tmp = ((exp(x) - 1.0) * c) * y; else tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[x, -1.78e-10], N[(N[(N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision] * c), $MachinePrecision] * y), $MachinePrecision], N[(N[(x * N[(c * N[(1.0 + N[(x * N[(0.5 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.16666666666666666 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.041666666666666664 + N[(-0.2916666666666667 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.78 \cdot 10^{-10}:\\
\;\;\;\;\left(\left(e^{x} - 1\right) \cdot c\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(c \cdot \left(1 + x \cdot \left(0.5 + \left(-0.5 \cdot y + x \cdot \left(0.16666666666666666 + \left(-0.5 \cdot y + x \cdot \left(0.041666666666666664 + -0.2916666666666667 \cdot y\right)\right)\right)\right)\right)\right)\right)\right) \cdot y\\
\end{array}
if x < -1.7800000000000001e-10Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lower-*.f6445.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.3%
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f6445.3%
Applied rewrites45.3%
if -1.7800000000000001e-10 < x Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites54.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
Applied rewrites57.9%
(FPCore (c x y)
:precision binary64
(if (<= x -1.78e-10)
(* y (- (* (exp x) c) c))
(*
(*
x
(*
c
(+
1.0
(*
x
(+
0.5
(+
(* -0.5 y)
(*
x
(+
0.16666666666666666
(+
(* -0.5 y)
(*
x
(+
0.041666666666666664
(* -0.2916666666666667 y))))))))))))
y)))double code(double c, double x, double y) {
double tmp;
if (x <= -1.78e-10) {
tmp = y * ((exp(x) * c) - c);
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
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(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.78d-10)) then
tmp = y * ((exp(x) * c) - c)
else
tmp = (x * (c * (1.0d0 + (x * (0.5d0 + (((-0.5d0) * y) + (x * (0.16666666666666666d0 + (((-0.5d0) * y) + (x * (0.041666666666666664d0 + ((-0.2916666666666667d0) * y)))))))))))) * y
end if
code = tmp
end function
public static double code(double c, double x, double y) {
double tmp;
if (x <= -1.78e-10) {
tmp = y * ((Math.exp(x) * c) - c);
} else {
tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
return tmp;
}
def code(c, x, y): tmp = 0 if x <= -1.78e-10: tmp = y * ((math.exp(x) * c) - c) else: tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y return tmp
function code(c, x, y) tmp = 0.0 if (x <= -1.78e-10) tmp = Float64(y * Float64(Float64(exp(x) * c) - c)); else tmp = Float64(Float64(x * Float64(c * Float64(1.0 + Float64(x * Float64(0.5 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.16666666666666666 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.041666666666666664 + Float64(-0.2916666666666667 * y)))))))))))) * y); end return tmp end
function tmp_2 = code(c, x, y) tmp = 0.0; if (x <= -1.78e-10) tmp = y * ((exp(x) * c) - c); else tmp = (x * (c * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y; end tmp_2 = tmp; end
code[c_, x_, y_] := If[LessEqual[x, -1.78e-10], N[(y * N[(N[(N[Exp[x], $MachinePrecision] * c), $MachinePrecision] - c), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(c * N[(1.0 + N[(x * N[(0.5 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.16666666666666666 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.041666666666666664 + N[(-0.2916666666666667 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.78 \cdot 10^{-10}:\\
\;\;\;\;y \cdot \left(e^{x} \cdot c - c\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(c \cdot \left(1 + x \cdot \left(0.5 + \left(-0.5 \cdot y + x \cdot \left(0.16666666666666666 + \left(-0.5 \cdot y + x \cdot \left(0.041666666666666664 + -0.2916666666666667 \cdot y\right)\right)\right)\right)\right)\right)\right)\right) \cdot y\\
\end{array}
if x < -1.7800000000000001e-10Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f6445.3%
Applied rewrites45.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-flipN/A
distribute-lft-inN/A
add-flipN/A
distribute-rgt-neg-outN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64N/A
lift-E.f64N/A
e-exp-1N/A
pow-expN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6445.0%
Applied rewrites45.0%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-lft-out--N/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6445.3%
Applied rewrites45.3%
if -1.7800000000000001e-10 < x Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites54.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
Applied rewrites57.9%
(FPCore (c x y)
:precision binary64
(*
(copysign 1.0 c)
(if (<= (fabs c) 8200.0)
(* (* y (fabs c)) x)
(*
(*
x
(*
(fabs c)
(+
1.0
(*
x
(+
0.5
(+
(* -0.5 y)
(*
x
(+
0.16666666666666666
(+
(* -0.5 y)
(*
x
(+
0.041666666666666664
(* -0.2916666666666667 y))))))))))))
y))))double code(double c, double x, double y) {
double tmp;
if (fabs(c) <= 8200.0) {
tmp = (y * fabs(c)) * x;
} else {
tmp = (x * (fabs(c) * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
return copysign(1.0, c) * tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (Math.abs(c) <= 8200.0) {
tmp = (y * Math.abs(c)) * x;
} else {
tmp = (x * (Math.abs(c) * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y;
}
return Math.copySign(1.0, c) * tmp;
}
def code(c, x, y): tmp = 0 if math.fabs(c) <= 8200.0: tmp = (y * math.fabs(c)) * x else: tmp = (x * (math.fabs(c) * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y return math.copysign(1.0, c) * tmp
function code(c, x, y) tmp = 0.0 if (abs(c) <= 8200.0) tmp = Float64(Float64(y * abs(c)) * x); else tmp = Float64(Float64(x * Float64(abs(c) * Float64(1.0 + Float64(x * Float64(0.5 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.16666666666666666 + Float64(Float64(-0.5 * y) + Float64(x * Float64(0.041666666666666664 + Float64(-0.2916666666666667 * y)))))))))))) * y); end return Float64(copysign(1.0, c) * tmp) end
function tmp_2 = code(c, x, y) tmp = 0.0; if (abs(c) <= 8200.0) tmp = (y * abs(c)) * x; else tmp = (x * (abs(c) * (1.0 + (x * (0.5 + ((-0.5 * y) + (x * (0.16666666666666666 + ((-0.5 * y) + (x * (0.041666666666666664 + (-0.2916666666666667 * y)))))))))))) * y; end tmp_2 = (sign(c) * abs(1.0)) * tmp; end
code[c_, x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[c], $MachinePrecision], 8200.0], N[(N[(y * N[Abs[c], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * N[(N[Abs[c], $MachinePrecision] * N[(1.0 + N[(x * N[(0.5 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.16666666666666666 + N[(N[(-0.5 * y), $MachinePrecision] + N[(x * N[(0.041666666666666664 + N[(-0.2916666666666667 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, c\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|c\right| \leq 8200:\\
\;\;\;\;\left(y \cdot \left|c\right|\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\left|c\right| \cdot \left(1 + x \cdot \left(0.5 + \left(-0.5 \cdot y + x \cdot \left(0.16666666666666666 + \left(-0.5 \cdot y + x \cdot \left(0.041666666666666664 + -0.2916666666666667 \cdot y\right)\right)\right)\right)\right)\right)\right)\right) \cdot y\\
\end{array}
if c < 8200Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6456.3%
Applied rewrites56.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-log.f64N/A
lift-E.f64N/A
log-EN/A
*-rgt-identityN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.3%
Applied rewrites62.3%
if 8200 < c Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites54.7%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
Applied rewrites57.9%
(FPCore (c x y)
:precision binary64
(*
(copysign 1.0 c)
(if (<= (fabs c) 1e+118)
(* (* y (fabs c)) x)
(*
(*
x
(+
(fabs c)
(*
x
(+
(* 0.5 (fabs c))
(*
x
(+
(* 0.041666666666666664 (* (fabs c) x))
(* 0.16666666666666666 (fabs c))))))))
y))))double code(double c, double x, double y) {
double tmp;
if (fabs(c) <= 1e+118) {
tmp = (y * fabs(c)) * x;
} else {
tmp = (x * (fabs(c) + (x * ((0.5 * fabs(c)) + (x * ((0.041666666666666664 * (fabs(c) * x)) + (0.16666666666666666 * fabs(c)))))))) * y;
}
return copysign(1.0, c) * tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (Math.abs(c) <= 1e+118) {
tmp = (y * Math.abs(c)) * x;
} else {
tmp = (x * (Math.abs(c) + (x * ((0.5 * Math.abs(c)) + (x * ((0.041666666666666664 * (Math.abs(c) * x)) + (0.16666666666666666 * Math.abs(c)))))))) * y;
}
return Math.copySign(1.0, c) * tmp;
}
def code(c, x, y): tmp = 0 if math.fabs(c) <= 1e+118: tmp = (y * math.fabs(c)) * x else: tmp = (x * (math.fabs(c) + (x * ((0.5 * math.fabs(c)) + (x * ((0.041666666666666664 * (math.fabs(c) * x)) + (0.16666666666666666 * math.fabs(c)))))))) * y return math.copysign(1.0, c) * tmp
function code(c, x, y) tmp = 0.0 if (abs(c) <= 1e+118) tmp = Float64(Float64(y * abs(c)) * x); else tmp = Float64(Float64(x * Float64(abs(c) + Float64(x * Float64(Float64(0.5 * abs(c)) + Float64(x * Float64(Float64(0.041666666666666664 * Float64(abs(c) * x)) + Float64(0.16666666666666666 * abs(c)))))))) * y); end return Float64(copysign(1.0, c) * tmp) end
function tmp_2 = code(c, x, y) tmp = 0.0; if (abs(c) <= 1e+118) tmp = (y * abs(c)) * x; else tmp = (x * (abs(c) + (x * ((0.5 * abs(c)) + (x * ((0.041666666666666664 * (abs(c) * x)) + (0.16666666666666666 * abs(c)))))))) * y; end tmp_2 = (sign(c) * abs(1.0)) * tmp; end
code[c_, x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[c], $MachinePrecision], 1e+118], N[(N[(y * N[Abs[c], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * N[(N[Abs[c], $MachinePrecision] + N[(x * N[(N[(0.5 * N[Abs[c], $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(0.041666666666666664 * N[(N[Abs[c], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[Abs[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, c\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|c\right| \leq 10^{+118}:\\
\;\;\;\;\left(y \cdot \left|c\right|\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(\left|c\right| + x \cdot \left(0.5 \cdot \left|c\right| + x \cdot \left(0.041666666666666664 \cdot \left(\left|c\right| \cdot x\right) + 0.16666666666666666 \cdot \left|c\right|\right)\right)\right)\right) \cdot y\\
\end{array}
if c < 9.9999999999999997e117Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6456.3%
Applied rewrites56.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-log.f64N/A
lift-E.f64N/A
log-EN/A
*-rgt-identityN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.3%
Applied rewrites62.3%
if 9.9999999999999997e117 < c Initial program 41.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-E.f64N/A
lower-*.f64N/A
Applied rewrites44.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6444.9%
Applied rewrites44.9%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites54.7%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6458.1%
Applied rewrites58.1%
(FPCore (c x y) :precision binary64 (* (copysign 1.0 c) (if (<= (fabs c) 1e+116) (* (* y (fabs c)) x) (* (* x (fabs c)) y))))
double code(double c, double x, double y) {
double tmp;
if (fabs(c) <= 1e+116) {
tmp = (y * fabs(c)) * x;
} else {
tmp = (x * fabs(c)) * y;
}
return copysign(1.0, c) * tmp;
}
public static double code(double c, double x, double y) {
double tmp;
if (Math.abs(c) <= 1e+116) {
tmp = (y * Math.abs(c)) * x;
} else {
tmp = (x * Math.abs(c)) * y;
}
return Math.copySign(1.0, c) * tmp;
}
def code(c, x, y): tmp = 0 if math.fabs(c) <= 1e+116: tmp = (y * math.fabs(c)) * x else: tmp = (x * math.fabs(c)) * y return math.copysign(1.0, c) * tmp
function code(c, x, y) tmp = 0.0 if (abs(c) <= 1e+116) tmp = Float64(Float64(y * abs(c)) * x); else tmp = Float64(Float64(x * abs(c)) * y); end return Float64(copysign(1.0, c) * tmp) end
function tmp_2 = code(c, x, y) tmp = 0.0; if (abs(c) <= 1e+116) tmp = (y * abs(c)) * x; else tmp = (x * abs(c)) * y; end tmp_2 = (sign(c) * abs(1.0)) * tmp; end
code[c_, x_, y_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[c], $MachinePrecision], 1e+116], N[(N[(y * N[Abs[c], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(x * N[Abs[c], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, c\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|c\right| \leq 10^{+116}:\\
\;\;\;\;\left(y \cdot \left|c\right|\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left|c\right|\right) \cdot y\\
\end{array}
if c < 1e116Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6456.3%
Applied rewrites56.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-log.f64N/A
lift-E.f64N/A
log-EN/A
*-rgt-identityN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6462.3%
Applied rewrites62.3%
if 1e116 < c Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6456.3%
Applied rewrites56.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-log.f64N/A
lift-E.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.8%
Applied rewrites59.8%
(FPCore (c x y) :precision binary64 (* (* x c) y))
double code(double c, double x, double y) {
return (x * c) * y;
}
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(c, x, y)
use fmin_fmax_functions
real(8), intent (in) :: c
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * c) * y
end function
public static double code(double c, double x, double y) {
return (x * c) * y;
}
def code(c, x, y): return (x * c) * y
function code(c, x, y) return Float64(Float64(x * c) * y) end
function tmp = code(c, x, y) tmp = (x * c) * y; end
code[c_, x_, y_] := N[(N[(x * c), $MachinePrecision] * y), $MachinePrecision]
\left(x \cdot c\right) \cdot y
Initial program 41.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-E.f6456.3%
Applied rewrites56.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lift-log.f64N/A
lift-E.f64N/A
log-EN/A
*-rgt-identityN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6459.8%
Applied rewrites59.8%
herbie shell --seed 2025258
(FPCore (c x y)
:name "Logarithmic Transform"
:precision binary64
(* c (log (+ 1.0 (* (- (pow E x) 1.0) y)))))