
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
e^{a \cdot x} - 1
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1.0))
double code(double a, double x) {
return exp((a * x)) - 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
code = exp((a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return Math.exp((a * x)) - 1.0;
}
def code(a, x): return math.exp((a * x)) - 1.0
function code(a, x) return Float64(exp(Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = exp((a * x)) - 1.0; end
code[a_, x_] := N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]
e^{a \cdot x} - 1
(FPCore (a x)
:precision binary64
(let* ((t_0 (* -0.5 (* a x))) (t_1 (/ 1.0 (+ 1.0 t_0))))
(if (<= (- (exp (* a x)) 1.0) -1.0)
(- (* t_1 t_1) 1.0)
(+
(sinh (* x a))
(* (* (sinh t_0) -2.0) (sinh (* 0.5 (* a x))))))))double code(double a, double x) {
double t_0 = -0.5 * (a * x);
double t_1 = 1.0 / (1.0 + t_0);
double tmp;
if ((exp((a * x)) - 1.0) <= -1.0) {
tmp = (t_1 * t_1) - 1.0;
} else {
tmp = sinh((x * a)) + ((sinh(t_0) * -2.0) * sinh((0.5 * (a * 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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (-0.5d0) * (a * x)
t_1 = 1.0d0 / (1.0d0 + t_0)
if ((exp((a * x)) - 1.0d0) <= (-1.0d0)) then
tmp = (t_1 * t_1) - 1.0d0
else
tmp = sinh((x * a)) + ((sinh(t_0) * (-2.0d0)) * sinh((0.5d0 * (a * x))))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = -0.5 * (a * x);
double t_1 = 1.0 / (1.0 + t_0);
double tmp;
if ((Math.exp((a * x)) - 1.0) <= -1.0) {
tmp = (t_1 * t_1) - 1.0;
} else {
tmp = Math.sinh((x * a)) + ((Math.sinh(t_0) * -2.0) * Math.sinh((0.5 * (a * x))));
}
return tmp;
}
def code(a, x): t_0 = -0.5 * (a * x) t_1 = 1.0 / (1.0 + t_0) tmp = 0 if (math.exp((a * x)) - 1.0) <= -1.0: tmp = (t_1 * t_1) - 1.0 else: tmp = math.sinh((x * a)) + ((math.sinh(t_0) * -2.0) * math.sinh((0.5 * (a * x)))) return tmp
function code(a, x) t_0 = Float64(-0.5 * Float64(a * x)) t_1 = Float64(1.0 / Float64(1.0 + t_0)) tmp = 0.0 if (Float64(exp(Float64(a * x)) - 1.0) <= -1.0) tmp = Float64(Float64(t_1 * t_1) - 1.0); else tmp = Float64(sinh(Float64(x * a)) + Float64(Float64(sinh(t_0) * -2.0) * sinh(Float64(0.5 * Float64(a * x))))); end return tmp end
function tmp_2 = code(a, x) t_0 = -0.5 * (a * x); t_1 = 1.0 / (1.0 + t_0); tmp = 0.0; if ((exp((a * x)) - 1.0) <= -1.0) tmp = (t_1 * t_1) - 1.0; else tmp = sinh((x * a)) + ((sinh(t_0) * -2.0) * sinh((0.5 * (a * x)))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(-0.5 * N[(a * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(t$95$1 * t$95$1), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[Sinh[N[(x * a), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sinh[t$95$0], $MachinePrecision] * -2.0), $MachinePrecision] * N[Sinh[N[(0.5 * N[(a * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := -0.5 \cdot \left(a \cdot x\right)\\
t_1 := \frac{1}{1 + t\_0}\\
\mathbf{if}\;e^{a \cdot x} - 1 \leq -1:\\
\;\;\;\;t\_1 \cdot t\_1 - 1\\
\mathbf{else}:\\
\;\;\;\;\sinh \left(x \cdot a\right) + \left(\sinh t\_0 \cdot -2\right) \cdot \sinh \left(0.5 \cdot \left(a \cdot x\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1Initial program 54.8%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-unsound-sqrt.f6454.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.8%
Applied rewrites54.8%
lift-sqrt.f64N/A
lift-exp.f64N/A
exp-sqrt-revN/A
+-lft-identityN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
lift-*.f64N/A
div-subN/A
metadata-evalN/A
mult-flip-revN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
sub0-negN/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
div-expN/A
1-expN/A
lower-/.f64N/A
Applied rewrites54.8%
lift-sqrt.f64N/A
lift-exp.f64N/A
exp-sqrt-revN/A
+-lft-identityN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
lift-*.f64N/A
div-subN/A
metadata-evalN/A
mult-flip-revN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
sub0-negN/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
div-expN/A
1-expN/A
lower-/.f64N/A
Applied rewrites54.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6453.6%
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6453.3%
Applied rewrites53.3%
if -1 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
lift--.f64N/A
sub-negate-revN/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
sub-negateN/A
cosh-0-revN/A
cosh-neg-revN/A
diff-coshN/A
fp-cancel-sub-sign-invN/A
lower-+.f64N/A
lower-sinh.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites66.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.2%
lift-*.f64N/A
lift--.f64N/A
sub0-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval66.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.2%
lift-*.f64N/A
Applied rewrites66.2%
(FPCore (a x) :precision binary64 (if (<= (- (exp (* a x)) 1.0) -0.0001) (/ (- (* -1.0 -1.0) (exp (* x (+ a a)))) (- -1.0 (exp (* x a)))) (- (sinh (* x a)) (- 1.0 (cosh (* x a))))))
double code(double a, double x) {
double tmp;
if ((exp((a * x)) - 1.0) <= -0.0001) {
tmp = ((-1.0 * -1.0) - exp((x * (a + a)))) / (-1.0 - exp((x * a)));
} else {
tmp = sinh((x * a)) - (1.0 - cosh((x * a)));
}
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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: tmp
if ((exp((a * x)) - 1.0d0) <= (-0.0001d0)) then
tmp = (((-1.0d0) * (-1.0d0)) - exp((x * (a + a)))) / ((-1.0d0) - exp((x * a)))
else
tmp = sinh((x * a)) - (1.0d0 - cosh((x * a)))
end if
code = tmp
end function
public static double code(double a, double x) {
double tmp;
if ((Math.exp((a * x)) - 1.0) <= -0.0001) {
tmp = ((-1.0 * -1.0) - Math.exp((x * (a + a)))) / (-1.0 - Math.exp((x * a)));
} else {
tmp = Math.sinh((x * a)) - (1.0 - Math.cosh((x * a)));
}
return tmp;
}
def code(a, x): tmp = 0 if (math.exp((a * x)) - 1.0) <= -0.0001: tmp = ((-1.0 * -1.0) - math.exp((x * (a + a)))) / (-1.0 - math.exp((x * a))) else: tmp = math.sinh((x * a)) - (1.0 - math.cosh((x * a))) return tmp
function code(a, x) tmp = 0.0 if (Float64(exp(Float64(a * x)) - 1.0) <= -0.0001) tmp = Float64(Float64(Float64(-1.0 * -1.0) - exp(Float64(x * Float64(a + a)))) / Float64(-1.0 - exp(Float64(x * a)))); else tmp = Float64(sinh(Float64(x * a)) - Float64(1.0 - cosh(Float64(x * a)))); end return tmp end
function tmp_2 = code(a, x) tmp = 0.0; if ((exp((a * x)) - 1.0) <= -0.0001) tmp = ((-1.0 * -1.0) - exp((x * (a + a)))) / (-1.0 - exp((x * a))); else tmp = sinh((x * a)) - (1.0 - cosh((x * a))); end tmp_2 = tmp; end
code[a_, x_] := If[LessEqual[N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision], -0.0001], N[(N[(N[(-1.0 * -1.0), $MachinePrecision] - N[Exp[N[(x * N[(a + a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-1.0 - N[Exp[N[(x * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sinh[N[(x * a), $MachinePrecision]], $MachinePrecision] - N[(1.0 - N[Cosh[N[(x * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;e^{a \cdot x} - 1 \leq -0.0001:\\
\;\;\;\;\frac{-1 \cdot -1 - e^{x \cdot \left(a + a\right)}}{-1 - e^{x \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\sinh \left(x \cdot a\right) - \left(1 - \cosh \left(x \cdot a\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1e-4Initial program 54.8%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites54.8%
if -1e-4 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
lift--.f64N/A
sub-negate-revN/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
sub-negateN/A
lower--.f64N/A
lower-sinh.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-cosh.f6465.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.6%
Applied rewrites65.6%
(FPCore (a x) :precision binary64 (let* ((t_0 (- (exp (* a x)) 1.0))) (if (<= t_0 -0.0001) t_0 (- (sinh (* x a)) (- 1.0 (cosh (* x a)))))))
double code(double a, double x) {
double t_0 = exp((a * x)) - 1.0;
double tmp;
if (t_0 <= -0.0001) {
tmp = t_0;
} else {
tmp = sinh((x * a)) - (1.0 - cosh((x * a)));
}
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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = exp((a * x)) - 1.0d0
if (t_0 <= (-0.0001d0)) then
tmp = t_0
else
tmp = sinh((x * a)) - (1.0d0 - cosh((x * a)))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = Math.exp((a * x)) - 1.0;
double tmp;
if (t_0 <= -0.0001) {
tmp = t_0;
} else {
tmp = Math.sinh((x * a)) - (1.0 - Math.cosh((x * a)));
}
return tmp;
}
def code(a, x): t_0 = math.exp((a * x)) - 1.0 tmp = 0 if t_0 <= -0.0001: tmp = t_0 else: tmp = math.sinh((x * a)) - (1.0 - math.cosh((x * a))) return tmp
function code(a, x) t_0 = Float64(exp(Float64(a * x)) - 1.0) tmp = 0.0 if (t_0 <= -0.0001) tmp = t_0; else tmp = Float64(sinh(Float64(x * a)) - Float64(1.0 - cosh(Float64(x * a)))); end return tmp end
function tmp_2 = code(a, x) t_0 = exp((a * x)) - 1.0; tmp = 0.0; if (t_0 <= -0.0001) tmp = t_0; else tmp = sinh((x * a)) - (1.0 - cosh((x * a))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.0001], t$95$0, N[(N[Sinh[N[(x * a), $MachinePrecision]], $MachinePrecision] - N[(1.0 - N[Cosh[N[(x * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := e^{a \cdot x} - 1\\
\mathbf{if}\;t\_0 \leq -0.0001:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\sinh \left(x \cdot a\right) - \left(1 - \cosh \left(x \cdot a\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1e-4Initial program 54.8%
if -1e-4 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
lift--.f64N/A
sub-negate-revN/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
sub-negateN/A
lower--.f64N/A
lower-sinh.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-cosh.f6465.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.6%
Applied rewrites65.6%
(FPCore (a x)
:precision binary64
(let* ((t_0 (- (exp (* a x)) 1.0)))
(if (<= t_0 -0.02)
t_0
(+
(sinh (* x a))
(*
(* -1.0 (* x (- (* -0.5 a) (* 0.5 a))))
(* 0.5 (* x (- (* 0.5 a) (* -0.5 a)))))))))double code(double a, double x) {
double t_0 = exp((a * x)) - 1.0;
double tmp;
if (t_0 <= -0.02) {
tmp = t_0;
} else {
tmp = sinh((x * a)) + ((-1.0 * (x * ((-0.5 * a) - (0.5 * a)))) * (0.5 * (x * ((0.5 * a) - (-0.5 * a)))));
}
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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = exp((a * x)) - 1.0d0
if (t_0 <= (-0.02d0)) then
tmp = t_0
else
tmp = sinh((x * a)) + (((-1.0d0) * (x * (((-0.5d0) * a) - (0.5d0 * a)))) * (0.5d0 * (x * ((0.5d0 * a) - ((-0.5d0) * a)))))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = Math.exp((a * x)) - 1.0;
double tmp;
if (t_0 <= -0.02) {
tmp = t_0;
} else {
tmp = Math.sinh((x * a)) + ((-1.0 * (x * ((-0.5 * a) - (0.5 * a)))) * (0.5 * (x * ((0.5 * a) - (-0.5 * a)))));
}
return tmp;
}
def code(a, x): t_0 = math.exp((a * x)) - 1.0 tmp = 0 if t_0 <= -0.02: tmp = t_0 else: tmp = math.sinh((x * a)) + ((-1.0 * (x * ((-0.5 * a) - (0.5 * a)))) * (0.5 * (x * ((0.5 * a) - (-0.5 * a))))) return tmp
function code(a, x) t_0 = Float64(exp(Float64(a * x)) - 1.0) tmp = 0.0 if (t_0 <= -0.02) tmp = t_0; else tmp = Float64(sinh(Float64(x * a)) + Float64(Float64(-1.0 * Float64(x * Float64(Float64(-0.5 * a) - Float64(0.5 * a)))) * Float64(0.5 * Float64(x * Float64(Float64(0.5 * a) - Float64(-0.5 * a)))))); end return tmp end
function tmp_2 = code(a, x) t_0 = exp((a * x)) - 1.0; tmp = 0.0; if (t_0 <= -0.02) tmp = t_0; else tmp = sinh((x * a)) + ((-1.0 * (x * ((-0.5 * a) - (0.5 * a)))) * (0.5 * (x * ((0.5 * a) - (-0.5 * a))))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Exp[N[(a * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.02], t$95$0, N[(N[Sinh[N[(x * a), $MachinePrecision]], $MachinePrecision] + N[(N[(-1.0 * N[(x * N[(N[(-0.5 * a), $MachinePrecision] - N[(0.5 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 * N[(x * N[(N[(0.5 * a), $MachinePrecision] - N[(-0.5 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := e^{a \cdot x} - 1\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\sinh \left(x \cdot a\right) + \left(-1 \cdot \left(x \cdot \left(-0.5 \cdot a - 0.5 \cdot a\right)\right)\right) \cdot \left(0.5 \cdot \left(x \cdot \left(0.5 \cdot a - -0.5 \cdot a\right)\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -0.02Initial program 54.8%
if -0.02 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
lift--.f64N/A
sub-negate-revN/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
sub-negateN/A
cosh-0-revN/A
cosh-neg-revN/A
diff-coshN/A
fp-cancel-sub-sign-invN/A
lower-+.f64N/A
lower-sinh.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
metadata-evalN/A
Applied rewrites66.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6466.2%
lift-*.f64N/A
lift--.f64N/A
sub0-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval66.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6466.2%
lift-*.f64N/A
Applied rewrites66.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6465.4%
Applied rewrites65.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6465.8%
Applied rewrites65.8%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* (fmin a x) (fmax a x))) (t_1 (- (exp t_0) 1.0)))
(if (<= t_1 -4e-5)
t_1
(* (fmax a x) (+ (fmin a x) (* 0.5 (* t_0 (fmin a x))))))))double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double t_1 = exp(t_0) - 1.0;
double tmp;
if (t_1 <= -4e-5) {
tmp = t_1;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, 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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmin(a, x) * fmax(a, x)
t_1 = exp(t_0) - 1.0d0
if (t_1 <= (-4d-5)) then
tmp = t_1
else
tmp = fmax(a, x) * (fmin(a, x) + (0.5d0 * (t_0 * fmin(a, x))))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double t_1 = Math.exp(t_0) - 1.0;
double tmp;
if (t_1 <= -4e-5) {
tmp = t_1;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x))));
}
return tmp;
}
def code(a, x): t_0 = fmin(a, x) * fmax(a, x) t_1 = math.exp(t_0) - 1.0 tmp = 0 if t_1 <= -4e-5: tmp = t_1 else: tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x)))) return tmp
function code(a, x) t_0 = Float64(fmin(a, x) * fmax(a, x)) t_1 = Float64(exp(t_0) - 1.0) tmp = 0.0 if (t_1 <= -4e-5) tmp = t_1; else tmp = Float64(fmax(a, x) * Float64(fmin(a, x) + Float64(0.5 * Float64(t_0 * fmin(a, x))))); end return tmp end
function tmp_2 = code(a, x) t_0 = min(a, x) * max(a, x); t_1 = exp(t_0) - 1.0; tmp = 0.0; if (t_1 <= -4e-5) tmp = t_1; else tmp = max(a, x) * (min(a, x) + (0.5 * (t_0 * min(a, x)))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[t$95$0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[t$95$1, -4e-5], t$95$1, N[(N[Max[a, x], $MachinePrecision] * N[(N[Min[a, x], $MachinePrecision] + N[(0.5 * N[(t$95$0 * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)\\
t_1 := e^{t\_0} - 1\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(a, x\right) \cdot \left(\mathsf{min}\left(a, x\right) + 0.5 \cdot \left(t\_0 \cdot \mathsf{min}\left(a, x\right)\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -4.0000000000000003e-5Initial program 54.8%
if -4.0000000000000003e-5 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6461.5%
Applied rewrites61.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6465.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.3%
Applied rewrites65.3%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* (fmin a x) (fmax a x)))
(t_1 (/ 1.0 (+ 1.0 (* -0.5 t_0)))))
(if (<= (- (exp t_0) 1.0) -1.0)
(- (* t_1 t_1) 1.0)
(* (fmax a x) (+ (fmin a x) (* 0.5 (* t_0 (fmin a x))))))))double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double t_1 = 1.0 / (1.0 + (-0.5 * t_0));
double tmp;
if ((exp(t_0) - 1.0) <= -1.0) {
tmp = (t_1 * t_1) - 1.0;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, 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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = fmin(a, x) * fmax(a, x)
t_1 = 1.0d0 / (1.0d0 + ((-0.5d0) * t_0))
if ((exp(t_0) - 1.0d0) <= (-1.0d0)) then
tmp = (t_1 * t_1) - 1.0d0
else
tmp = fmax(a, x) * (fmin(a, x) + (0.5d0 * (t_0 * fmin(a, x))))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double t_1 = 1.0 / (1.0 + (-0.5 * t_0));
double tmp;
if ((Math.exp(t_0) - 1.0) <= -1.0) {
tmp = (t_1 * t_1) - 1.0;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x))));
}
return tmp;
}
def code(a, x): t_0 = fmin(a, x) * fmax(a, x) t_1 = 1.0 / (1.0 + (-0.5 * t_0)) tmp = 0 if (math.exp(t_0) - 1.0) <= -1.0: tmp = (t_1 * t_1) - 1.0 else: tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x)))) return tmp
function code(a, x) t_0 = Float64(fmin(a, x) * fmax(a, x)) t_1 = Float64(1.0 / Float64(1.0 + Float64(-0.5 * t_0))) tmp = 0.0 if (Float64(exp(t_0) - 1.0) <= -1.0) tmp = Float64(Float64(t_1 * t_1) - 1.0); else tmp = Float64(fmax(a, x) * Float64(fmin(a, x) + Float64(0.5 * Float64(t_0 * fmin(a, x))))); end return tmp end
function tmp_2 = code(a, x) t_0 = min(a, x) * max(a, x); t_1 = 1.0 / (1.0 + (-0.5 * t_0)); tmp = 0.0; if ((exp(t_0) - 1.0) <= -1.0) tmp = (t_1 * t_1) - 1.0; else tmp = max(a, x) * (min(a, x) + (0.5 * (t_0 * min(a, x)))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(1.0 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[t$95$0], $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(t$95$1 * t$95$1), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[Max[a, x], $MachinePrecision] * N[(N[Min[a, x], $MachinePrecision] + N[(0.5 * N[(t$95$0 * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)\\
t_1 := \frac{1}{1 + -0.5 \cdot t\_0}\\
\mathbf{if}\;e^{t\_0} - 1 \leq -1:\\
\;\;\;\;t\_1 \cdot t\_1 - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(a, x\right) \cdot \left(\mathsf{min}\left(a, x\right) + 0.5 \cdot \left(t\_0 \cdot \mathsf{min}\left(a, x\right)\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1Initial program 54.8%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-unsound-sqrt.f6454.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6454.8%
Applied rewrites54.8%
lift-sqrt.f64N/A
lift-exp.f64N/A
exp-sqrt-revN/A
+-lft-identityN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
lift-*.f64N/A
div-subN/A
metadata-evalN/A
mult-flip-revN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
sub0-negN/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
div-expN/A
1-expN/A
lower-/.f64N/A
Applied rewrites54.8%
lift-sqrt.f64N/A
lift-exp.f64N/A
exp-sqrt-revN/A
+-lft-identityN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
lift-*.f64N/A
div-subN/A
metadata-evalN/A
mult-flip-revN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
sub0-negN/A
lift--.f64N/A
metadata-evalN/A
lift-*.f64N/A
div-expN/A
1-expN/A
lower-/.f64N/A
Applied rewrites54.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6453.6%
Applied rewrites53.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6453.3%
Applied rewrites53.3%
if -1 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6461.5%
Applied rewrites61.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6465.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.3%
Applied rewrites65.3%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* (fmin a x) (fmax a x))))
(if (<= (- (exp t_0) 1.0) -1.0)
(-
(*
(fmin a x)
(/
(* (* (- t_0 -1.0) (fmin a x)) 1.0)
(* (fmin a x) (fmin a x))))
1.0)
(* (fmax a x) (+ (fmin a x) (* 0.5 (* t_0 (fmin a x))))))))double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double tmp;
if ((exp(t_0) - 1.0) <= -1.0) {
tmp = (fmin(a, x) * ((((t_0 - -1.0) * fmin(a, x)) * 1.0) / (fmin(a, x) * fmin(a, x)))) - 1.0;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, 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(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = fmin(a, x) * fmax(a, x)
if ((exp(t_0) - 1.0d0) <= (-1.0d0)) then
tmp = (fmin(a, x) * ((((t_0 - (-1.0d0)) * fmin(a, x)) * 1.0d0) / (fmin(a, x) * fmin(a, x)))) - 1.0d0
else
tmp = fmax(a, x) * (fmin(a, x) + (0.5d0 * (t_0 * fmin(a, x))))
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = fmin(a, x) * fmax(a, x);
double tmp;
if ((Math.exp(t_0) - 1.0) <= -1.0) {
tmp = (fmin(a, x) * ((((t_0 - -1.0) * fmin(a, x)) * 1.0) / (fmin(a, x) * fmin(a, x)))) - 1.0;
} else {
tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x))));
}
return tmp;
}
def code(a, x): t_0 = fmin(a, x) * fmax(a, x) tmp = 0 if (math.exp(t_0) - 1.0) <= -1.0: tmp = (fmin(a, x) * ((((t_0 - -1.0) * fmin(a, x)) * 1.0) / (fmin(a, x) * fmin(a, x)))) - 1.0 else: tmp = fmax(a, x) * (fmin(a, x) + (0.5 * (t_0 * fmin(a, x)))) return tmp
function code(a, x) t_0 = Float64(fmin(a, x) * fmax(a, x)) tmp = 0.0 if (Float64(exp(t_0) - 1.0) <= -1.0) tmp = Float64(Float64(fmin(a, x) * Float64(Float64(Float64(Float64(t_0 - -1.0) * fmin(a, x)) * 1.0) / Float64(fmin(a, x) * fmin(a, x)))) - 1.0); else tmp = Float64(fmax(a, x) * Float64(fmin(a, x) + Float64(0.5 * Float64(t_0 * fmin(a, x))))); end return tmp end
function tmp_2 = code(a, x) t_0 = min(a, x) * max(a, x); tmp = 0.0; if ((exp(t_0) - 1.0) <= -1.0) tmp = (min(a, x) * ((((t_0 - -1.0) * min(a, x)) * 1.0) / (min(a, x) * min(a, x)))) - 1.0; else tmp = max(a, x) * (min(a, x) + (0.5 * (t_0 * min(a, x)))); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[t$95$0], $MachinePrecision] - 1.0), $MachinePrecision], -1.0], N[(N[(N[Min[a, x], $MachinePrecision] * N[(N[(N[(N[(t$95$0 - -1.0), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[Min[a, x], $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[Max[a, x], $MachinePrecision] * N[(N[Min[a, x], $MachinePrecision] + N[(0.5 * N[(t$95$0 * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)\\
\mathbf{if}\;e^{t\_0} - 1 \leq -1:\\
\;\;\;\;\mathsf{min}\left(a, x\right) \cdot \frac{\left(\left(t\_0 - -1\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot 1}{\mathsf{min}\left(a, x\right) \cdot \mathsf{min}\left(a, x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(a, x\right) \cdot \left(\mathsf{min}\left(a, x\right) + 0.5 \cdot \left(t\_0 \cdot \mathsf{min}\left(a, x\right)\right)\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1Initial program 54.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6421.5%
Applied rewrites21.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6418.9%
Applied rewrites18.9%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-commutativeN/A
+-commutativeN/A
mult-flipN/A
+-commutativeN/A
rgt-mult-inverseN/A
lift-/.f64N/A
distribute-lft-inN/A
lift-+.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-commutativeN/A
+-commutativeN/A
associate-*l/N/A
frac-timesN/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites8.7%
if -1 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 54.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6461.5%
Applied rewrites61.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6465.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.3%
Applied rewrites65.3%
(FPCore (a x) :precision binary64 (* (fmax a x) (+ (fmin a x) (* 0.5 (* (* (fmin a x) (fmax a x)) (fmin a x))))))
double code(double a, double x) {
return fmax(a, x) * (fmin(a, x) + (0.5 * ((fmin(a, x) * fmax(a, x)) * fmin(a, x))));
}
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, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
code = fmax(a, x) * (fmin(a, x) + (0.5d0 * ((fmin(a, x) * fmax(a, x)) * fmin(a, x))))
end function
public static double code(double a, double x) {
return fmax(a, x) * (fmin(a, x) + (0.5 * ((fmin(a, x) * fmax(a, x)) * fmin(a, x))));
}
def code(a, x): return fmax(a, x) * (fmin(a, x) + (0.5 * ((fmin(a, x) * fmax(a, x)) * fmin(a, x))))
function code(a, x) return Float64(fmax(a, x) * Float64(fmin(a, x) + Float64(0.5 * Float64(Float64(fmin(a, x) * fmax(a, x)) * fmin(a, x))))) end
function tmp = code(a, x) tmp = max(a, x) * (min(a, x) + (0.5 * ((min(a, x) * max(a, x)) * min(a, x)))); end
code[a_, x_] := N[(N[Max[a, x], $MachinePrecision] * N[(N[Min[a, x], $MachinePrecision] + N[(0.5 * N[(N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{max}\left(a, x\right) \cdot \left(\mathsf{min}\left(a, x\right) + 0.5 \cdot \left(\left(\mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right)\right)
Initial program 54.8%
Taylor expanded in x around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6461.5%
Applied rewrites61.5%
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6465.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.3%
Applied rewrites65.3%
(FPCore (a x) :precision binary64 (- (+ 1.0 (* a x)) 1.0))
double code(double a, double x) {
return (1.0 + (a * x)) - 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
code = (1.0d0 + (a * x)) - 1.0d0
end function
public static double code(double a, double x) {
return (1.0 + (a * x)) - 1.0;
}
def code(a, x): return (1.0 + (a * x)) - 1.0
function code(a, x) return Float64(Float64(1.0 + Float64(a * x)) - 1.0) end
function tmp = code(a, x) tmp = (1.0 + (a * x)) - 1.0; end
code[a_, x_] := N[(N[(1.0 + N[(a * x), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\left(1 + a \cdot x\right) - 1
Initial program 54.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6421.5%
Applied rewrites21.5%
(FPCore (a x) :precision binary64 (- 1.0 1.0))
double code(double a, double x) {
return 1.0 - 1.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, x)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: x
code = 1.0d0 - 1.0d0
end function
public static double code(double a, double x) {
return 1.0 - 1.0;
}
def code(a, x): return 1.0 - 1.0
function code(a, x) return Float64(1.0 - 1.0) end
function tmp = code(a, x) tmp = 1.0 - 1.0; end
code[a_, x_] := N[(1.0 - 1.0), $MachinePrecision]
1 - 1
Initial program 54.8%
Taylor expanded in a around 0
Applied rewrites19.7%
herbie shell --seed 2025258
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:pre (> 710.0 (* a x))
(- (exp (* a x)) 1.0))