
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (fmod (exp x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(exp(x), sqrt(cos(x))) * exp(-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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod(exp(x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(math.exp(x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(exp(x), sqrt(cos(x))) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x)))
(t_1 (+ 1.0 (* -0.25 (pow x 2.0))))
(t_2 (sqrt (cos x))))
(if (<= x -2e-20)
(*
(fmod
(* (fma (* (cosh x) (sinh x)) (pow (sinh x) -2.0) 1.0) (sinh x))
t_2)
t_0)
(if (<= x 1.1e-16)
(*
(fmod
(*
(+
1.0
(/
(/ (- (exp (+ x x)) (exp (- (- x) x))) (* 4.0 (sinh x)))
(sinh x)))
(sinh x))
t_1)
t_0)
(if (<= x 50.0)
(*
(* 2.0 (/ (fmod (exp x) t_2) (- (exp x) (/ 1.0 (exp x)))))
(/ 1.0 (/ (exp x) (sinh x))))
(* (fmod 1.0 t_1) t_0))))))
double code(double x) {
double t_0 = exp(-x);
double t_1 = 1.0 + (-0.25 * pow(x, 2.0));
double t_2 = sqrt(cos(x));
double tmp;
if (x <= -2e-20) {
tmp = fmod((fma((cosh(x) * sinh(x)), pow(sinh(x), -2.0), 1.0) * sinh(x)), t_2) * t_0;
} else if (x <= 1.1e-16) {
tmp = fmod(((1.0 + (((exp((x + x)) - exp((-x - x))) / (4.0 * sinh(x))) / sinh(x))) * sinh(x)), t_1) * t_0;
} else if (x <= 50.0) {
tmp = (2.0 * (fmod(exp(x), t_2) / (exp(x) - (1.0 / exp(x))))) * (1.0 / (exp(x) / sinh(x)));
} else {
tmp = fmod(1.0, t_1) * t_0;
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) t_1 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) t_2 = sqrt(cos(x)) tmp = 0.0 if (x <= -2e-20) tmp = Float64(rem(Float64(fma(Float64(cosh(x) * sinh(x)), (sinh(x) ^ -2.0), 1.0) * sinh(x)), t_2) * t_0); elseif (x <= 1.1e-16) tmp = Float64(rem(Float64(Float64(1.0 + Float64(Float64(Float64(exp(Float64(x + x)) - exp(Float64(Float64(-x) - x))) / Float64(4.0 * sinh(x))) / sinh(x))) * sinh(x)), t_1) * t_0); elseif (x <= 50.0) tmp = Float64(Float64(2.0 * Float64(rem(exp(x), t_2) / Float64(exp(x) - Float64(1.0 / exp(x))))) * Float64(1.0 / Float64(exp(x) / sinh(x)))); else tmp = Float64(rem(1.0, t_1) * t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2e-20], N[(N[With[{TMP1 = N[(N[(N[(N[Cosh[x], $MachinePrecision] * N[Sinh[x], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sinh[x], $MachinePrecision], -2.0], $MachinePrecision] + 1.0), $MachinePrecision] * N[Sinh[x], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$2}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 1.1e-16], N[(N[With[{TMP1 = N[(N[(1.0 + N[(N[(N[(N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision] - N[Exp[N[((-x) - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(4.0 * N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sinh[x], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$1}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 50.0], N[(N[(2.0 * N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = t$95$2}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - N[(1.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = t$95$1}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
t_1 := 1 + -0.25 \cdot {x}^{2}\\
t_2 := \sqrt{\cos x}\\
\mathbf{if}\;x \leq -2 \cdot 10^{-20}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\cosh x \cdot \sinh x, {\sinh x}^{-2}, 1\right) \cdot \sinh x\right) \bmod t\_2\right) \cdot t\_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-16}:\\
\;\;\;\;\left(\left(\left(1 + \frac{\frac{e^{x + x} - e^{\left(-x\right) - x}}{4 \cdot \sinh x}}{\sinh x}\right) \cdot \sinh x\right) \bmod t\_1\right) \cdot t\_0\\
\mathbf{elif}\;x \leq 50:\\
\;\;\;\;\left(2 \cdot \frac{\left(\left(e^{x}\right) \bmod t\_2\right)}{e^{x} - \frac{1}{e^{x}}}\right) \cdot \frac{1}{\frac{e^{x}}{\sinh x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod t\_1\right) \cdot t\_0\\
\end{array}
\end{array}
if x < -1.99999999999999989e-20Initial program 8.8%
lift-exp.f64N/A
sinh-+-cosh-revN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lower-cosh.f64N/A
lower-sinh.f64N/A
lower-sinh.f648.7
Applied rewrites8.7%
lift-cosh.f64N/A
cosh-defN/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
div-addN/A
flip-+N/A
lower-unsound--.f32N/A
lower--.f32N/A
div-subN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
lift-sinh.f64N/A
lower-unsound-/.f64N/A
Applied rewrites63.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
Applied rewrites6.8%
if -1.99999999999999989e-20 < x < 1.1e-16Initial program 8.8%
lift-exp.f64N/A
sinh-+-cosh-revN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lower-cosh.f64N/A
lower-sinh.f64N/A
lower-sinh.f648.7
Applied rewrites8.7%
lift-cosh.f64N/A
cosh-defN/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
div-addN/A
flip-+N/A
lower-unsound--.f32N/A
lower--.f32N/A
div-subN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
lift-sinh.f64N/A
lower-unsound-/.f64N/A
Applied rewrites63.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l/N/A
Applied rewrites63.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6463.5
Applied rewrites63.5%
if 1.1e-16 < x < 50Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
associate-*r/N/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
lift-cosh.f64N/A
lift-sinh.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites7.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-exp.f645.0
Applied rewrites5.0%
if 50 < x Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites34.7%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.7
Applied rewrites34.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x))))
(t_1 (exp (- x)))
(t_2 (* t_0 t_1))
(t_3 (+ 1.0 (* -0.25 (pow x 2.0)))))
(if (<= t_2 0.0)
(*
(fmod
(*
(+
1.0
(/ (/ (- (exp (+ x x)) (exp (- (- x) x))) (* 4.0 (sinh x))) (sinh x)))
(sinh x))
t_3)
t_1)
(if (<= t_2 0.5)
(*
(* 2.0 (/ t_0 (- (exp x) (/ 1.0 (exp x)))))
(/ 1.0 (/ (exp x) (sinh x))))
(/ (fmod (- x -1.0) t_3) (exp x))))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double t_2 = t_0 * t_1;
double t_3 = 1.0 + (-0.25 * pow(x, 2.0));
double tmp;
if (t_2 <= 0.0) {
tmp = fmod(((1.0 + (((exp((x + x)) - exp((-x - x))) / (4.0 * sinh(x))) / sinh(x))) * sinh(x)), t_3) * t_1;
} else if (t_2 <= 0.5) {
tmp = (2.0 * (t_0 / (exp(x) - (1.0 / exp(x))))) * (1.0 / (exp(x) / sinh(x)));
} else {
tmp = fmod((x - -1.0), t_3) / exp(x);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
t_2 = t_0 * t_1
t_3 = 1.0d0 + ((-0.25d0) * (x ** 2.0d0))
if (t_2 <= 0.0d0) then
tmp = mod(((1.0d0 + (((exp((x + x)) - exp((-x - x))) / (4.0d0 * sinh(x))) / sinh(x))) * sinh(x)), t_3) * t_1
else if (t_2 <= 0.5d0) then
tmp = (2.0d0 * (t_0 / (exp(x) - (1.0d0 / exp(x))))) * (1.0d0 / (exp(x) / sinh(x)))
else
tmp = mod((x - (-1.0d0)), t_3) / exp(x)
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) t_2 = t_0 * t_1 t_3 = 1.0 + (-0.25 * math.pow(x, 2.0)) tmp = 0 if t_2 <= 0.0: tmp = math.fmod(((1.0 + (((math.exp((x + x)) - math.exp((-x - x))) / (4.0 * math.sinh(x))) / math.sinh(x))) * math.sinh(x)), t_3) * t_1 elif t_2 <= 0.5: tmp = (2.0 * (t_0 / (math.exp(x) - (1.0 / math.exp(x))))) * (1.0 / (math.exp(x) / math.sinh(x))) else: tmp = math.fmod((x - -1.0), t_3) / math.exp(x) return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) t_2 = Float64(t_0 * t_1) t_3 = Float64(1.0 + Float64(-0.25 * (x ^ 2.0))) tmp = 0.0 if (t_2 <= 0.0) tmp = Float64(rem(Float64(Float64(1.0 + Float64(Float64(Float64(exp(Float64(x + x)) - exp(Float64(Float64(-x) - x))) / Float64(4.0 * sinh(x))) / sinh(x))) * sinh(x)), t_3) * t_1); elseif (t_2 <= 0.5) tmp = Float64(Float64(2.0 * Float64(t_0 / Float64(exp(x) - Float64(1.0 / exp(x))))) * Float64(1.0 / Float64(exp(x) / sinh(x)))); else tmp = Float64(rem(Float64(x - -1.0), t_3) / exp(x)); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.0], N[(N[With[{TMP1 = N[(N[(1.0 + N[(N[(N[(N[Exp[N[(x + x), $MachinePrecision]], $MachinePrecision] - N[Exp[N[((-x) - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(4.0 * N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sinh[x], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$3}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 0.5], N[(N[(2.0 * N[(t$95$0 / N[(N[Exp[x], $MachinePrecision] - N[(1.0 / N[Exp[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = N[(x - -1.0), $MachinePrecision], TMP2 = t$95$3}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
t_2 := t\_0 \cdot t\_1\\
t_3 := 1 + -0.25 \cdot {x}^{2}\\
\mathbf{if}\;t\_2 \leq 0:\\
\;\;\;\;\left(\left(\left(1 + \frac{\frac{e^{x + x} - e^{\left(-x\right) - x}}{4 \cdot \sinh x}}{\sinh x}\right) \cdot \sinh x\right) \bmod t\_3\right) \cdot t\_1\\
\mathbf{elif}\;t\_2 \leq 0.5:\\
\;\;\;\;\left(2 \cdot \frac{t\_0}{e^{x} - \frac{1}{e^{x}}}\right) \cdot \frac{1}{\frac{e^{x}}{\sinh x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x - -1\right) \bmod t\_3\right)}{e^{x}}\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.0Initial program 8.8%
lift-exp.f64N/A
sinh-+-cosh-revN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lower-cosh.f64N/A
lower-sinh.f64N/A
lower-sinh.f648.7
Applied rewrites8.7%
lift-cosh.f64N/A
cosh-defN/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
div-addN/A
flip-+N/A
lower-unsound--.f32N/A
lower--.f32N/A
div-subN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
lift-sinh.f64N/A
lower-unsound-/.f64N/A
Applied rewrites63.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
associate-/l/N/A
Applied rewrites63.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6463.5
Applied rewrites63.5%
if 0.0 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 0.5Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
associate-*r/N/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
lift-cosh.f64N/A
lift-sinh.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
Applied rewrites7.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f64N/A
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-/.f64N/A
lower-exp.f645.0
Applied rewrites5.0%
if 0.5 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6437.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6437.8
Applied rewrites37.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.8
Applied rewrites37.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sqrt (cos x))) (t_1 (exp (- x))))
(if (<= (* (fmod (exp x) t_0) t_1) 2.0)
(* (fmod (* (+ 1.0 (/ (cosh x) (sinh x))) (sinh x)) t_0) t_1)
(* (fmod 1.0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_1))))
double code(double x) {
double t_0 = sqrt(cos(x));
double t_1 = exp(-x);
double tmp;
if ((fmod(exp(x), t_0) * t_1) <= 2.0) {
tmp = fmod(((1.0 + (cosh(x) / sinh(x))) * sinh(x)), t_0) * t_1;
} else {
tmp = fmod(1.0, (1.0 + (-0.25 * pow(x, 2.0)))) * t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt(cos(x))
t_1 = exp(-x)
if ((mod(exp(x), t_0) * t_1) <= 2.0d0) then
tmp = mod(((1.0d0 + (cosh(x) / sinh(x))) * sinh(x)), t_0) * t_1
else
tmp = mod(1.0d0, (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) * t_1
end if
code = tmp
end function
def code(x): t_0 = math.sqrt(math.cos(x)) t_1 = math.exp(-x) tmp = 0 if (math.fmod(math.exp(x), t_0) * t_1) <= 2.0: tmp = math.fmod(((1.0 + (math.cosh(x) / math.sinh(x))) * math.sinh(x)), t_0) * t_1 else: tmp = math.fmod(1.0, (1.0 + (-0.25 * math.pow(x, 2.0)))) * t_1 return tmp
function code(x) t_0 = sqrt(cos(x)) t_1 = exp(Float64(-x)) tmp = 0.0 if (Float64(rem(exp(x), t_0) * t_1) <= 2.0) tmp = Float64(rem(Float64(Float64(1.0 + Float64(cosh(x) / sinh(x))) * sinh(x)), t_0) * t_1); else tmp = Float64(rem(1.0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) * t_1); end return tmp end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], 2.0], N[(N[With[{TMP1 = N[(N[(1.0 + N[(N[Cosh[x], $MachinePrecision] / N[Sinh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sinh[x], $MachinePrecision]), $MachinePrecision], TMP2 = t$95$0}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos x}\\
t_1 := e^{-x}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod t\_0\right) \cdot t\_1 \leq 2:\\
\;\;\;\;\left(\left(\left(1 + \frac{\cosh x}{\sinh x}\right) \cdot \sinh x\right) \bmod t\_0\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 8.8%
lift-exp.f64N/A
sinh-+-cosh-revN/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lower-cosh.f64N/A
lower-sinh.f64N/A
lower-sinh.f648.7
Applied rewrites8.7%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites34.7%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.7
Applied rewrites34.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (fmod (exp x) (sqrt (cos x)))) (t_1 (exp (- x))))
(if (<= (* t_0 t_1) 2.0)
(/ t_0 (exp x))
(* (fmod 1.0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_1))))
double code(double x) {
double t_0 = fmod(exp(x), sqrt(cos(x)));
double t_1 = exp(-x);
double tmp;
if ((t_0 * t_1) <= 2.0) {
tmp = t_0 / exp(x);
} else {
tmp = fmod(1.0, (1.0 + (-0.25 * pow(x, 2.0)))) * t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = mod(exp(x), sqrt(cos(x)))
t_1 = exp(-x)
if ((t_0 * t_1) <= 2.0d0) then
tmp = t_0 / exp(x)
else
tmp = mod(1.0d0, (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) * t_1
end if
code = tmp
end function
def code(x): t_0 = math.fmod(math.exp(x), math.sqrt(math.cos(x))) t_1 = math.exp(-x) tmp = 0 if (t_0 * t_1) <= 2.0: tmp = t_0 / math.exp(x) else: tmp = math.fmod(1.0, (1.0 + (-0.25 * math.pow(x, 2.0)))) * t_1 return tmp
function code(x) t_0 = rem(exp(x), sqrt(cos(x))) t_1 = exp(Float64(-x)) tmp = 0.0 if (Float64(t_0 * t_1) <= 2.0) tmp = Float64(t_0 / exp(x)); else tmp = Float64(rem(1.0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) * t_1); end return tmp end
code[x_] := Block[{t$95$0 = N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(t$95$0 * t$95$1), $MachinePrecision], 2.0], N[(t$95$0 / N[Exp[x], $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right)\\
t_1 := e^{-x}\\
\mathbf{if}\;t\_0 \cdot t\_1 \leq 2:\\
\;\;\;\;\frac{t\_0}{e^{x}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 8.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f648.8
Applied rewrites8.8%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites34.7%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.7
Applied rewrites34.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (* (fmod (exp x) (sqrt (cos x))) t_0) 2.0)
(/ 1.0 (/ (exp x) (fmod (exp x) (fma (* x x) -0.25 1.0))))
(* (fmod 1.0 (+ 1.0 (* -0.25 (pow x 2.0)))) t_0))))
double code(double x) {
double t_0 = exp(-x);
double tmp;
if ((fmod(exp(x), sqrt(cos(x))) * t_0) <= 2.0) {
tmp = 1.0 / (exp(x) / fmod(exp(x), fma((x * x), -0.25, 1.0)));
} else {
tmp = fmod(1.0, (1.0 + (-0.25 * pow(x, 2.0)))) * t_0;
}
return tmp;
}
function code(x) t_0 = exp(Float64(-x)) tmp = 0.0 if (Float64(rem(exp(x), sqrt(cos(x))) * t_0) <= 2.0) tmp = Float64(1.0 / Float64(exp(x) / rem(exp(x), fma(Float64(x * x), -0.25, 1.0)))); else tmp = Float64(rem(1.0, Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) * t_0); end return tmp end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision], 2.0], N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[With[{TMP1 = 1.0, TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\left(\left(e^{x}\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot t\_0 \leq 2:\\
\;\;\;\;\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) < 2Initial program 8.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f648.8
Applied rewrites8.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f648.5
Applied rewrites8.5%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f648.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f648.5
lift-pow.f64N/A
unpow2N/A
lower-*.f648.5
Applied rewrites8.5%
if 2 < (*.f64 (fmod.f64 (exp.f64 x) (sqrt.f64 (cos.f64 x))) (exp.f64 (neg.f64 x))) Initial program 8.8%
Taylor expanded in x around 0
Applied rewrites34.7%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.7
Applied rewrites34.7%
(FPCore (x) :precision binary64 (* (fmod (* (+ 1.0 (/ 1.0 x)) x) (sqrt (cos x))) (exp (- x))))
double code(double x) {
return fmod(((1.0 + (1.0 / x)) * x), sqrt(cos(x))) * exp(-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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod(((1.0d0 + (1.0d0 / x)) * x), sqrt(cos(x))) * exp(-x)
end function
def code(x): return math.fmod(((1.0 + (1.0 / x)) * x), math.sqrt(math.cos(x))) * math.exp(-x)
function code(x) return Float64(rem(Float64(Float64(1.0 + Float64(1.0 / x)) * x), sqrt(cos(x))) * exp(Float64(-x))) end
code[x_] := N[(N[With[{TMP1 = N[(N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] * N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(1 + \frac{1}{x}\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right) \cdot e^{-x}
\end{array}
Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6437.9
Applied rewrites37.9%
(FPCore (x) :precision binary64 (/ (fmod (* (- 1.0 (/ -1.0 x)) x) (sqrt (cos x))) (exp x)))
double code(double x) {
return fmod(((1.0 - (-1.0 / x)) * x), sqrt(cos(x))) / exp(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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod(((1.0d0 - ((-1.0d0) / x)) * x), sqrt(cos(x))) / exp(x)
end function
def code(x): return math.fmod(((1.0 - (-1.0 / x)) * x), math.sqrt(math.cos(x))) / math.exp(x)
function code(x) return Float64(rem(Float64(Float64(1.0 - Float64(-1.0 / x)) * x), sqrt(cos(x))) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[(N[(1.0 - N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(\left(1 - \frac{-1}{x}\right) \cdot x\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\end{array}
Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6437.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6437.8
Applied rewrites37.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6437.9
Applied rewrites37.9%
(FPCore (x) :precision binary64 (/ (fmod (- x -1.0) (sqrt (cos x))) (exp x)))
double code(double x) {
return fmod((x - -1.0), sqrt(cos(x))) / exp(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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod((x - (-1.0d0)), sqrt(cos(x))) / exp(x)
end function
def code(x): return math.fmod((x - -1.0), math.sqrt(math.cos(x))) / math.exp(x)
function code(x) return Float64(rem(Float64(x - -1.0), sqrt(cos(x))) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[(x - -1.0), $MachinePrecision], TMP2 = N[Sqrt[N[Cos[x], $MachinePrecision]], $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x - -1\right) \bmod \left(\sqrt{\cos x}\right)\right)}{e^{x}}
\end{array}
Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6437.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6437.8
Applied rewrites37.8%
(FPCore (x) :precision binary64 (/ (fmod (- x -1.0) (+ 1.0 (* -0.25 (pow x 2.0)))) (exp x)))
double code(double x) {
return fmod((x - -1.0), (1.0 + (-0.25 * pow(x, 2.0)))) / exp(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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = mod((x - (-1.0d0)), (1.0d0 + ((-0.25d0) * (x ** 2.0d0)))) / exp(x)
end function
def code(x): return math.fmod((x - -1.0), (1.0 + (-0.25 * math.pow(x, 2.0)))) / math.exp(x)
function code(x) return Float64(rem(Float64(x - -1.0), Float64(1.0 + Float64(-0.25 * (x ^ 2.0)))) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[(x - -1.0), $MachinePrecision], TMP2 = N[(1.0 + N[(-0.25 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x - -1\right) \bmod \left(1 + -0.25 \cdot {x}^{2}\right)\right)}{e^{x}}
\end{array}
Initial program 8.8%
Taylor expanded in x around 0
lower-+.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6437.8
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6437.8
Applied rewrites37.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6437.8
Applied rewrites37.8%
(FPCore (x) :precision binary64 (/ 1.0 (/ (exp x) (fmod (exp x) (fma (* x x) -0.25 1.0)))))
double code(double x) {
return 1.0 / (exp(x) / fmod(exp(x), fma((x * x), -0.25, 1.0)));
}
function code(x) return Float64(1.0 / Float64(exp(x) / rem(exp(x), fma(Float64(x * x), -0.25, 1.0)))) end
code[x_] := N[(1.0 / N[(N[Exp[x], $MachinePrecision] / N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{e^{x}}{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)}}
\end{array}
Initial program 8.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f648.8
Applied rewrites8.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f648.5
Applied rewrites8.5%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f648.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f648.5
lift-pow.f64N/A
unpow2N/A
lower-*.f648.5
Applied rewrites8.5%
(FPCore (x) :precision binary64 (/ (fmod (exp x) (fma (* x x) -0.25 1.0)) (exp x)))
double code(double x) {
return fmod(exp(x), fma((x * x), -0.25, 1.0)) / exp(x);
}
function code(x) return Float64(rem(exp(x), fma(Float64(x * x), -0.25, 1.0)) / exp(x)) end
code[x_] := N[(N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision] / N[Exp[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)}{e^{x}}
\end{array}
Initial program 8.8%
lift-*.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f648.8
Applied rewrites8.8%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f648.5
Applied rewrites8.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f648.5
lift-pow.f64N/A
unpow2N/A
lower-*.f648.5
Applied rewrites8.5%
(FPCore (x) :precision binary64 (fmod (exp x) (fma (* x x) -0.25 1.0)))
double code(double x) {
return fmod(exp(x), fma((x * x), -0.25, 1.0));
}
function code(x) return rem(exp(x), fma(Float64(x * x), -0.25, 1.0)) end
code[x_] := N[With[{TMP1 = N[Exp[x], $MachinePrecision], TMP2 = N[(N[(x * x), $MachinePrecision] * -0.25 + 1.0), $MachinePrecision]}, Mod[Abs[TMP1], Abs[TMP2]] * Sign[TMP1]], $MachinePrecision]
\begin{array}{l}
\\
\left(\left(e^{x}\right) \bmod \left(\mathsf{fma}\left(x \cdot x, -0.25, 1\right)\right)\right)
\end{array}
Initial program 8.8%
Taylor expanded in x around 0
lower-fmod.f64N/A
lower-exp.f64N/A
lower-sqrt.f64N/A
lower-cos.f646.5
Applied rewrites6.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f646.5
Applied rewrites6.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f646.5
lift-pow.f64N/A
unpow2N/A
lower-*.f646.5
Applied rewrites6.5%
herbie shell --seed 2025155
(FPCore (x)
:name "expfmod (used to be hard to sample)"
:precision binary64
(* (fmod (exp x) (sqrt (cos x))) (exp (- x))))