
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
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(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
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(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (* -1.0 (/ (* (* -1.0 a_m) (/ (pow k m) (* -1.0 k))) (* -1.0 k))))
(t_1 (/ (* a_m (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
(t_2 (fma k k (fma 10.0 k 1.0))))
(*
a_s
(if (<= t_1 0.0)
t_0
(if (<= t_1 1e+302)
(fma
(/ (fma (* (* (pow (log k) 2.0) m) a_m) 0.5 (* (log k) a_m)) t_2)
m
(/ a_m t_2))
t_0)))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = -1.0 * (((-1.0 * a_m) * (pow(k, m) / (-1.0 * k))) / (-1.0 * k));
double t_1 = (a_m * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double t_2 = fma(k, k, fma(10.0, k, 1.0));
double tmp;
if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 1e+302) {
tmp = fma((fma(((pow(log(k), 2.0) * m) * a_m), 0.5, (log(k) * a_m)) / t_2), m, (a_m / t_2));
} else {
tmp = t_0;
}
return a_s * tmp;
}
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64(-1.0 * Float64(Float64(Float64(-1.0 * a_m) * Float64((k ^ m) / Float64(-1.0 * k))) / Float64(-1.0 * k))) t_1 = Float64(Float64(a_m * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) t_2 = fma(k, k, fma(10.0, k, 1.0)) tmp = 0.0 if (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 1e+302) tmp = fma(Float64(fma(Float64(Float64((log(k) ^ 2.0) * m) * a_m), 0.5, Float64(log(k) * a_m)) / t_2), m, Float64(a_m / t_2)); else tmp = t_0; end return Float64(a_s * tmp) end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(-1.0 * N[(N[(N[(-1.0 * a$95$m), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(k * k + N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 1e+302], N[(N[(N[(N[(N[(N[Power[N[Log[k], $MachinePrecision], 2.0], $MachinePrecision] * m), $MachinePrecision] * a$95$m), $MachinePrecision] * 0.5 + N[(N[Log[k], $MachinePrecision] * a$95$m), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision] * m + N[(a$95$m / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$0]]), $MachinePrecision]]]]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := -1 \cdot \frac{\left(-1 \cdot a\_m\right) \cdot \frac{{k}^{m}}{-1 \cdot k}}{-1 \cdot k}\\
t_1 := \frac{a\_m \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
t_2 := \mathsf{fma}\left(k, k, \mathsf{fma}\left(10, k, 1\right)\right)\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+302}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\left({\log k}^{2} \cdot m\right) \cdot a\_m, 0.5, \log k \cdot a\_m\right)}{t\_2}, m, \frac{a\_m}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 0.0 or 1.0000000000000001e302 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 88.1%
Taylor expanded in k around inf
pow2N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
exp-prodN/A
pow-unpowN/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-exp.f64N/A
inv-powN/A
log-powN/A
lower-*.f64N/A
lower-log.f64N/A
lower-neg.f6448.8
Applied rewrites48.8%
Taylor expanded in k around 0
lift-pow.f6477.4
Applied rewrites77.4%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-*.f6489.3
Applied rewrites89.3%
if 0.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 1.0000000000000001e302Initial program 99.9%
Taylor expanded in m around 0
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.1%
Final simplification89.9%
a\_m = (fabs.f64 a)
a\_s = (copysign.f64 #s(literal 1 binary64) a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= k 0.0082)
(/ (* a_m (pow k m)) 1.0)
(* -1.0 (/ (* (* -1.0 a_m) (/ (pow k m) (* -1.0 k))) (* -1.0 k))))))a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (k <= 0.0082) {
tmp = (a_m * pow(k, m)) / 1.0;
} else {
tmp = -1.0 * (((-1.0 * a_m) * (pow(k, m) / (-1.0 * k))) / (-1.0 * k));
}
return a_s * tmp;
}
a\_m = private
a\_s = private
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(a_s, a_m, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (k <= 0.0082d0) then
tmp = (a_m * (k ** m)) / 1.0d0
else
tmp = (-1.0d0) * ((((-1.0d0) * a_m) * ((k ** m) / ((-1.0d0) * k))) / ((-1.0d0) * k))
end if
code = a_s * tmp
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (k <= 0.0082) {
tmp = (a_m * Math.pow(k, m)) / 1.0;
} else {
tmp = -1.0 * (((-1.0 * a_m) * (Math.pow(k, m) / (-1.0 * k))) / (-1.0 * k));
}
return a_s * tmp;
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if k <= 0.0082: tmp = (a_m * math.pow(k, m)) / 1.0 else: tmp = -1.0 * (((-1.0 * a_m) * (math.pow(k, m) / (-1.0 * k))) / (-1.0 * k)) return a_s * tmp
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (k <= 0.0082) tmp = Float64(Float64(a_m * (k ^ m)) / 1.0); else tmp = Float64(-1.0 * Float64(Float64(Float64(-1.0 * a_m) * Float64((k ^ m) / Float64(-1.0 * k))) / Float64(-1.0 * k))); end return Float64(a_s * tmp) end
a\_m = abs(a); a\_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (k <= 0.0082) tmp = (a_m * (k ^ m)) / 1.0; else tmp = -1.0 * (((-1.0 * a_m) * ((k ^ m) / (-1.0 * k))) / (-1.0 * k)); end tmp_2 = a_s * tmp; end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[k, 0.0082], N[(N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(-1.0 * N[(N[(N[(-1.0 * a$95$m), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;k \leq 0.0082:\\
\;\;\;\;\frac{a\_m \cdot {k}^{m}}{1}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\left(-1 \cdot a\_m\right) \cdot \frac{{k}^{m}}{-1 \cdot k}}{-1 \cdot k}\\
\end{array}
\end{array}
if k < 0.00820000000000000069Initial program 94.2%
Taylor expanded in k around 0
Applied rewrites98.4%
if 0.00820000000000000069 < k Initial program 78.2%
Taylor expanded in k around inf
pow2N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
exp-prodN/A
pow-unpowN/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-exp.f64N/A
inv-powN/A
log-powN/A
lower-*.f64N/A
lower-log.f64N/A
lower-neg.f6490.1
Applied rewrites90.1%
Taylor expanded in k around 0
lift-pow.f6490.1
Applied rewrites90.1%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-*.f6498.7
Applied rewrites98.7%
Final simplification98.5%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (* -1.0 (/ (* (* -1.0 a_m) (/ (pow k m) (* -1.0 k))) (* -1.0 k)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
return a_s * (-1.0 * (((-1.0 * a_m) * (pow(k, m) / (-1.0 * k))) / (-1.0 * k)));
}
a\_m = private
a\_s = private
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(a_s, a_m, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a_s * ((-1.0d0) * ((((-1.0d0) * a_m) * ((k ** m) / ((-1.0d0) * k))) / ((-1.0d0) * k)))
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
return a_s * (-1.0 * (((-1.0 * a_m) * (Math.pow(k, m) / (-1.0 * k))) / (-1.0 * k)));
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): return a_s * (-1.0 * (((-1.0 * a_m) * (math.pow(k, m) / (-1.0 * k))) / (-1.0 * k)))
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) return Float64(a_s * Float64(-1.0 * Float64(Float64(Float64(-1.0 * a_m) * Float64((k ^ m) / Float64(-1.0 * k))) / Float64(-1.0 * k)))) end
a\_m = abs(a); a\_s = sign(a) * abs(1.0); function tmp = code(a_s, a_m, k, m) tmp = a_s * (-1.0 * (((-1.0 * a_m) * ((k ^ m) / (-1.0 * k))) / (-1.0 * k))); end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * N[(-1.0 * N[(N[(N[(-1.0 * a$95$m), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(-1 \cdot \frac{\left(-1 \cdot a\_m\right) \cdot \frac{{k}^{m}}{-1 \cdot k}}{-1 \cdot k}\right)
\end{array}
Initial program 89.1%
Taylor expanded in k around inf
pow2N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
exp-prodN/A
pow-unpowN/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-exp.f64N/A
inv-powN/A
log-powN/A
lower-*.f64N/A
lower-log.f64N/A
lower-neg.f6446.1
Applied rewrites46.1%
Taylor expanded in k around 0
lift-pow.f6472.3
Applied rewrites72.3%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-*.f6483.2
Applied rewrites83.2%
Final simplification83.2%
a\_m = (fabs.f64 a) a\_s = (copysign.f64 #s(literal 1 binary64) a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (* (/ a_m (* -1.0 k)) (/ (pow k m) (* -1.0 k)))))
a\_m = fabs(a);
a\_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
return a_s * ((a_m / (-1.0 * k)) * (pow(k, m) / (-1.0 * k)));
}
a\_m = private
a\_s = private
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(a_s, a_m, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a_s * ((a_m / ((-1.0d0) * k)) * ((k ** m) / ((-1.0d0) * k)))
end function
a\_m = Math.abs(a);
a\_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
return a_s * ((a_m / (-1.0 * k)) * (Math.pow(k, m) / (-1.0 * k)));
}
a\_m = math.fabs(a) a\_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): return a_s * ((a_m / (-1.0 * k)) * (math.pow(k, m) / (-1.0 * k)))
a\_m = abs(a) a\_s = copysign(1.0, a) function code(a_s, a_m, k, m) return Float64(a_s * Float64(Float64(a_m / Float64(-1.0 * k)) * Float64((k ^ m) / Float64(-1.0 * k)))) end
a\_m = abs(a); a\_s = sign(a) * abs(1.0); function tmp = code(a_s, a_m, k, m) tmp = a_s * ((a_m / (-1.0 * k)) * ((k ^ m) / (-1.0 * k))); end
a\_m = N[Abs[a], $MachinePrecision]
a\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * N[(N[(a$95$m / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision] * N[(N[Power[k, m], $MachinePrecision] / N[(-1.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
a\_m = \left|a\right|
\\
a\_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \left(\frac{a\_m}{-1 \cdot k} \cdot \frac{{k}^{m}}{-1 \cdot k}\right)
\end{array}
Initial program 89.1%
Taylor expanded in k around inf
pow2N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
exp-prodN/A
pow-unpowN/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-exp.f64N/A
inv-powN/A
log-powN/A
lower-*.f64N/A
lower-log.f64N/A
lower-neg.f6446.1
Applied rewrites46.1%
Taylor expanded in k around 0
lift-pow.f6472.3
Applied rewrites72.3%
Final simplification72.3%
herbie shell --seed 2025064
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))