
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1))
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), $MachinePrecision]
e^{a \cdot x} - 1
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a x) :precision binary64 (- (exp (* a x)) 1))
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), $MachinePrecision]
e^{a \cdot x} - 1
(FPCore (a x)
:precision binary64
(let* ((t_0 (- (exp (* (fmin a x) (fmax a x))) 1)))
(if (<= t_0 -1/2)
t_0
(*
(-
(fmin a x)
(*
(* (- -1/2 (* (* 1/6 (fmax a x)) (fmin a x))) (fmin a x))
(* (fmax a x) (fmin a x))))
(fmax a x)))))double code(double a, double x) {
double t_0 = exp((fmin(a, x) * fmax(a, x))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = t_0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(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 = exp((fmin(a, x) * fmax(a, x))) - 1.0d0
if (t_0 <= (-0.5d0)) then
tmp = t_0
else
tmp = (fmin(a, x) - ((((-0.5d0) - ((0.16666666666666666d0 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x)
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = Math.exp((fmin(a, x) * fmax(a, x))) - 1.0;
double tmp;
if (t_0 <= -0.5) {
tmp = t_0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x);
}
return tmp;
}
def code(a, x): t_0 = math.exp((fmin(a, x) * fmax(a, x))) - 1.0 tmp = 0 if t_0 <= -0.5: tmp = t_0 else: tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x) return tmp
function code(a, x) t_0 = Float64(exp(Float64(fmin(a, x) * fmax(a, x))) - 1.0) tmp = 0.0 if (t_0 <= -0.5) tmp = t_0; else tmp = Float64(Float64(fmin(a, x) - Float64(Float64(Float64(-0.5 - Float64(Float64(0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * Float64(fmax(a, x) * fmin(a, x)))) * fmax(a, x)); end return tmp end
function tmp_2 = code(a, x) t_0 = exp((min(a, x) * max(a, x))) - 1.0; tmp = 0.0; if (t_0 <= -0.5) tmp = t_0; else tmp = (min(a, x) - (((-0.5 - ((0.16666666666666666 * max(a, x)) * min(a, x))) * min(a, x)) * (max(a, x) * min(a, x)))) * max(a, x); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Exp[N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision]}, If[LessEqual[t$95$0, -1/2], t$95$0, N[(N[(N[Min[a, x], $MachinePrecision] - N[(N[(N[(-1/2 - N[(N[(1/6 * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision] * N[(N[Max[a, x], $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := e^{\mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)} - 1\\
\mathbf{if}\;t\_0 \leq \frac{-1}{2}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{min}\left(a, x\right) - \left(\left(\frac{-1}{2} - \left(\frac{1}{6} \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \left(\mathsf{max}\left(a, x\right) \cdot \mathsf{min}\left(a, x\right)\right)\right) \cdot \mathsf{max}\left(a, x\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -0.5Initial program 53.9%
if -0.5 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 53.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-pow.f64N/A
lower-*.f64N/A
lower-pow.f6459.7%
Applied rewrites59.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.7%
Applied rewrites59.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
Applied rewrites63.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6467.6%
Applied rewrites67.6%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* (fmax a x) (fmin a x))))
(if (<= (- (exp (* (fmin a x) (fmax a x))) 1) -1)
(-
(*
(fmax a x)
(/
(- t_0 (* t_0 (* (- (fmin a x)) (fmax a x))))
(* (* (fmax a x) (fmax a x)) (fmin a x))))
1)
(*
(-
(fmin a x)
(*
(* (- -1/2 (* (* 1/6 (fmax a x)) (fmin a x))) (fmin a x))
t_0))
(fmax a x)))))double code(double a, double x) {
double t_0 = fmax(a, x) * fmin(a, x);
double tmp;
if ((exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) {
tmp = (fmax(a, x) * ((t_0 - (t_0 * (-fmin(a, x) * fmax(a, x)))) / ((fmax(a, x) * fmax(a, x)) * fmin(a, x)))) - 1.0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(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 = fmax(a, x) * fmin(a, x)
if ((exp((fmin(a, x) * fmax(a, x))) - 1.0d0) <= (-1.0d0)) then
tmp = (fmax(a, x) * ((t_0 - (t_0 * (-fmin(a, x) * fmax(a, x)))) / ((fmax(a, x) * fmax(a, x)) * fmin(a, x)))) - 1.0d0
else
tmp = (fmin(a, x) - ((((-0.5d0) - ((0.16666666666666666d0 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x)
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = fmax(a, x) * fmin(a, x);
double tmp;
if ((Math.exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) {
tmp = (fmax(a, x) * ((t_0 - (t_0 * (-fmin(a, x) * fmax(a, x)))) / ((fmax(a, x) * fmax(a, x)) * fmin(a, x)))) - 1.0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x);
}
return tmp;
}
def code(a, x): t_0 = fmax(a, x) * fmin(a, x) tmp = 0 if (math.exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0: tmp = (fmax(a, x) * ((t_0 - (t_0 * (-fmin(a, x) * fmax(a, x)))) / ((fmax(a, x) * fmax(a, x)) * fmin(a, x)))) - 1.0 else: tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x) return tmp
function code(a, x) t_0 = Float64(fmax(a, x) * fmin(a, x)) tmp = 0.0 if (Float64(exp(Float64(fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) tmp = Float64(Float64(fmax(a, x) * Float64(Float64(t_0 - Float64(t_0 * Float64(Float64(-fmin(a, x)) * fmax(a, x)))) / Float64(Float64(fmax(a, x) * fmax(a, x)) * fmin(a, x)))) - 1.0); else tmp = Float64(Float64(fmin(a, x) - Float64(Float64(Float64(-0.5 - Float64(Float64(0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x)); end return tmp end
function tmp_2 = code(a, x) t_0 = max(a, x) * min(a, x); tmp = 0.0; if ((exp((min(a, x) * max(a, x))) - 1.0) <= -1.0) tmp = (max(a, x) * ((t_0 - (t_0 * (-min(a, x) * max(a, x)))) / ((max(a, x) * max(a, x)) * min(a, x)))) - 1.0; else tmp = (min(a, x) - (((-0.5 - ((0.16666666666666666 * max(a, x)) * min(a, x))) * min(a, x)) * t_0)) * max(a, x); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Max[a, x], $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision], -1], N[(N[(N[Max[a, x], $MachinePrecision] * N[(N[(t$95$0 - N[(t$95$0 * N[((-N[Min[a, x], $MachinePrecision]) * N[Max[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Max[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision], N[(N[(N[Min[a, x], $MachinePrecision] - N[(N[(N[(-1/2 - N[(N[(1/6 * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(a, x\right) \cdot \mathsf{min}\left(a, x\right)\\
\mathbf{if}\;e^{\mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)} - 1 \leq -1:\\
\;\;\;\;\mathsf{max}\left(a, x\right) \cdot \frac{t\_0 - t\_0 \cdot \left(\left(-\mathsf{min}\left(a, x\right)\right) \cdot \mathsf{max}\left(a, x\right)\right)}{\left(\mathsf{max}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{min}\left(a, x\right) - \left(\left(\frac{-1}{2} - \left(\frac{1}{6} \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot t\_0\right) \cdot \mathsf{max}\left(a, x\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1Initial program 53.9%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6421.6%
Applied rewrites21.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6418.8%
Applied rewrites18.8%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
add-flip-revN/A
div-subN/A
*-inversesN/A
associate-/r*N/A
*-commutativeN/A
lift-*.f64N/A
frac-subN/A
*-commutativeN/A
lift-*.f64N/A
associate-*l*N/A
lower-/.f64N/A
Applied rewrites7.7%
if -1 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 53.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-pow.f64N/A
lower-*.f64N/A
lower-pow.f6459.7%
Applied rewrites59.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.7%
Applied rewrites59.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
Applied rewrites63.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6467.6%
Applied rewrites67.6%
(FPCore (a x)
:precision binary64
(let* ((t_0 (* (fmax a x) (fmin a x))))
(if (<= (- (exp (* (fmin a x) (fmax a x))) 1) -1)
(-
(*
(fmax a x)
(/ (* (* (- t_0 -1) (fmax a x)) 1) (* (fmax a x) (fmax a x))))
1)
(*
(-
(fmin a x)
(*
(* (- -1/2 (* (* 1/6 (fmax a x)) (fmin a x))) (fmin a x))
t_0))
(fmax a x)))))double code(double a, double x) {
double t_0 = fmax(a, x) * fmin(a, x);
double tmp;
if ((exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) {
tmp = (fmax(a, x) * ((((t_0 - -1.0) * fmax(a, x)) * 1.0) / (fmax(a, x) * fmax(a, x)))) - 1.0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(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 = fmax(a, x) * fmin(a, x)
if ((exp((fmin(a, x) * fmax(a, x))) - 1.0d0) <= (-1.0d0)) then
tmp = (fmax(a, x) * ((((t_0 - (-1.0d0)) * fmax(a, x)) * 1.0d0) / (fmax(a, x) * fmax(a, x)))) - 1.0d0
else
tmp = (fmin(a, x) - ((((-0.5d0) - ((0.16666666666666666d0 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x)
end if
code = tmp
end function
public static double code(double a, double x) {
double t_0 = fmax(a, x) * fmin(a, x);
double tmp;
if ((Math.exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) {
tmp = (fmax(a, x) * ((((t_0 - -1.0) * fmax(a, x)) * 1.0) / (fmax(a, x) * fmax(a, x)))) - 1.0;
} else {
tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x);
}
return tmp;
}
def code(a, x): t_0 = fmax(a, x) * fmin(a, x) tmp = 0 if (math.exp((fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0: tmp = (fmax(a, x) * ((((t_0 - -1.0) * fmax(a, x)) * 1.0) / (fmax(a, x) * fmax(a, x)))) - 1.0 else: tmp = (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x) return tmp
function code(a, x) t_0 = Float64(fmax(a, x) * fmin(a, x)) tmp = 0.0 if (Float64(exp(Float64(fmin(a, x) * fmax(a, x))) - 1.0) <= -1.0) tmp = Float64(Float64(fmax(a, x) * Float64(Float64(Float64(Float64(t_0 - -1.0) * fmax(a, x)) * 1.0) / Float64(fmax(a, x) * fmax(a, x)))) - 1.0); else tmp = Float64(Float64(fmin(a, x) - Float64(Float64(Float64(-0.5 - Float64(Float64(0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * t_0)) * fmax(a, x)); end return tmp end
function tmp_2 = code(a, x) t_0 = max(a, x) * min(a, x); tmp = 0.0; if ((exp((min(a, x) * max(a, x))) - 1.0) <= -1.0) tmp = (max(a, x) * ((((t_0 - -1.0) * max(a, x)) * 1.0) / (max(a, x) * max(a, x)))) - 1.0; else tmp = (min(a, x) - (((-0.5 - ((0.16666666666666666 * max(a, x)) * min(a, x))) * min(a, x)) * t_0)) * max(a, x); end tmp_2 = tmp; end
code[a_, x_] := Block[{t$95$0 = N[(N[Max[a, x], $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(N[Min[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 1), $MachinePrecision], -1], N[(N[(N[Max[a, x], $MachinePrecision] * N[(N[(N[(N[(t$95$0 - -1), $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * 1), $MachinePrecision] / N[(N[Max[a, x], $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision], N[(N[(N[Min[a, x], $MachinePrecision] - N[(N[(N[(-1/2 - N[(N[(1/6 * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(a, x\right) \cdot \mathsf{min}\left(a, x\right)\\
\mathbf{if}\;e^{\mathsf{min}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)} - 1 \leq -1:\\
\;\;\;\;\mathsf{max}\left(a, x\right) \cdot \frac{\left(\left(t\_0 - -1\right) \cdot \mathsf{max}\left(a, x\right)\right) \cdot 1}{\mathsf{max}\left(a, x\right) \cdot \mathsf{max}\left(a, x\right)} - 1\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{min}\left(a, x\right) - \left(\left(\frac{-1}{2} - \left(\frac{1}{6} \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot t\_0\right) \cdot \mathsf{max}\left(a, x\right)\\
\end{array}
if (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) < -1Initial program 53.9%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f6421.6%
Applied rewrites21.6%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6418.8%
Applied rewrites18.8%
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
*-commutativeN/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lft-mult-inverseN/A
lift-/.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
lift-+.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*l/N/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites9.0%
if -1 < (-.f64 (exp.f64 (*.f64 a x)) #s(literal 1 binary64)) Initial program 53.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-pow.f64N/A
lower-*.f64N/A
lower-pow.f6459.7%
Applied rewrites59.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.7%
Applied rewrites59.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
Applied rewrites63.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6467.6%
Applied rewrites67.6%
(FPCore (a x) :precision binary64 (* (- (fmin a x) (* (* (- -1/2 (* (* 1/6 (fmax a x)) (fmin a x))) (fmin a x)) (* (fmax a x) (fmin a x)))) (fmax a x)))
double code(double a, double x) {
return (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(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 = (fmin(a, x) - ((((-0.5d0) - ((0.16666666666666666d0 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x)
end function
public static double code(double a, double x) {
return (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x);
}
def code(a, x): return (fmin(a, x) - (((-0.5 - ((0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * (fmax(a, x) * fmin(a, x)))) * fmax(a, x)
function code(a, x) return Float64(Float64(fmin(a, x) - Float64(Float64(Float64(-0.5 - Float64(Float64(0.16666666666666666 * fmax(a, x)) * fmin(a, x))) * fmin(a, x)) * Float64(fmax(a, x) * fmin(a, x)))) * fmax(a, x)) end
function tmp = code(a, x) tmp = (min(a, x) - (((-0.5 - ((0.16666666666666666 * max(a, x)) * min(a, x))) * min(a, x)) * (max(a, x) * min(a, x)))) * max(a, x); end
code[a_, x_] := N[(N[(N[Min[a, x], $MachinePrecision] - N[(N[(N[(-1/2 - N[(N[(1/6 * N[Max[a, x], $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision] * N[(N[Max[a, x], $MachinePrecision] * N[Min[a, x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Max[a, x], $MachinePrecision]), $MachinePrecision]
\left(\mathsf{min}\left(a, x\right) - \left(\left(\frac{-1}{2} - \left(\frac{1}{6} \cdot \mathsf{max}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \mathsf{min}\left(a, x\right)\right) \cdot \left(\mathsf{max}\left(a, x\right) \cdot \mathsf{min}\left(a, x\right)\right)\right) \cdot \mathsf{max}\left(a, x\right)
Initial program 53.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-pow.f64N/A
lower-*.f64N/A
lower-pow.f6459.7%
Applied rewrites59.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.7%
Applied rewrites59.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower-*.f64N/A
Applied rewrites63.2%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6467.6%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6467.6%
Applied rewrites67.6%
(FPCore (a x) :precision binary64 (* a x))
double code(double a, double x) {
return 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 = a * x
end function
public static double code(double a, double x) {
return a * x;
}
def code(a, x): return a * x
function code(a, x) return Float64(a * x) end
function tmp = code(a, x) tmp = a * x; end
code[a_, x_] := N[(a * x), $MachinePrecision]
a \cdot x
Initial program 53.9%
Taylor expanded in a around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6462.6%
Applied rewrites62.6%
Taylor expanded in a around 0
Applied rewrites67.0%
(FPCore (a x) :precision binary64 (- 1 1))
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 - 1), $MachinePrecision]
1 - 1
Initial program 53.9%
Taylor expanded in a around 0
Applied rewrites19.5%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (a x)
:name "expax (section 3.5)"
:precision binary64
:pre (> 710 (* a x))
(- (exp (* a x)) 1))