
(FPCore (x y) :precision binary64 (exp (* (* x y) y)))
double code(double x, double y) {
return exp(((x * y) * y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp(((x * y) * y))
end function
public static double code(double x, double y) {
return Math.exp(((x * y) * y));
}
def code(x, y): return math.exp(((x * y) * y))
function code(x, y) return exp(Float64(Float64(x * y) * y)) end
function tmp = code(x, y) tmp = exp(((x * y) * y)); end
code[x_, y_] := N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x \cdot y\right) \cdot y}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (exp (* (* x y) y)))
double code(double x, double y) {
return exp(((x * y) * y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp(((x * y) * y))
end function
public static double code(double x, double y) {
return Math.exp(((x * y) * y));
}
def code(x, y): return math.exp(((x * y) * y))
function code(x, y) return exp(Float64(Float64(x * y) * y)) end
function tmp = code(x, y) tmp = exp(((x * y) * y)); end
code[x_, y_] := N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x \cdot y\right) \cdot y}
\end{array}
(FPCore (x y) :precision binary64 (exp (* (* x y) y)))
double code(double x, double y) {
return exp(((x * y) * y));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp(((x * y) * y))
end function
public static double code(double x, double y) {
return Math.exp(((x * y) * y));
}
def code(x, y): return math.exp(((x * y) * y))
function code(x, y) return exp(Float64(Float64(x * y) * y)) end
function tmp = code(x, y) tmp = exp(((x * y) * y)); end
code[x_, y_] := N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(x \cdot y\right) \cdot y}
\end{array}
Initial program 100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* x y) y)))
(if (<= t_0 -1e+287)
(* (* (/ 1.0 (* y x)) y) x)
(if (<= t_0 -10000000000000.0)
(* (/ x (* x x)) x)
(if (<= t_0 2e+87) (fma (* y y) x 1.0) (/ (* (* (* y y) x) x) x))))))
double code(double x, double y) {
double t_0 = (x * y) * y;
double tmp;
if (t_0 <= -1e+287) {
tmp = ((1.0 / (y * x)) * y) * x;
} else if (t_0 <= -10000000000000.0) {
tmp = (x / (x * x)) * x;
} else if (t_0 <= 2e+87) {
tmp = fma((y * y), x, 1.0);
} else {
tmp = (((y * y) * x) * x) / x;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * y) * y) tmp = 0.0 if (t_0 <= -1e+287) tmp = Float64(Float64(Float64(1.0 / Float64(y * x)) * y) * x); elseif (t_0 <= -10000000000000.0) tmp = Float64(Float64(x / Float64(x * x)) * x); elseif (t_0 <= 2e+87) tmp = fma(Float64(y * y), x, 1.0); else tmp = Float64(Float64(Float64(Float64(y * y) * x) * x) / x); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+287], N[(N[(N[(1.0 / N[(y * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, -10000000000000.0], N[(N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 2e+87], N[(N[(y * y), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot y\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+287}:\\
\;\;\;\;\left(\frac{1}{y \cdot x} \cdot y\right) \cdot x\\
\mathbf{elif}\;t\_0 \leq -10000000000000:\\
\;\;\;\;\frac{x}{x \cdot x} \cdot x\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(y \cdot y\right) \cdot x\right) \cdot x}{x}\\
\end{array}
\end{array}
if (*.f64 (*.f64 x y) y) < -1.0000000000000001e287Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f641.6
Applied rewrites1.6%
lift-fma.f64N/A
lift-*.f64N/A
pow2N/A
lft-mult-inverseN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-/.f641.6
Applied rewrites1.6%
Taylor expanded in x around 0
lift-/.f643.1
Applied rewrites3.1%
lift-/.f64N/A
lft-mult-inverseN/A
associate-*l/N/A
associate-/r*N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
*-commutativeN/A
associate-/r*N/A
associate-*l/N/A
pow-flipN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
associate-/r*N/A
lift-*.f64N/A
lower-*.f64N/A
lower-/.f6448.7
Applied rewrites48.7%
if -1.0000000000000001e287 < (*.f64 (*.f64 x y) y) < -1e13Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f642.2
Applied rewrites2.2%
lift-fma.f64N/A
lift-*.f64N/A
pow2N/A
lft-mult-inverseN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-/.f642.2
Applied rewrites2.2%
Taylor expanded in x around 0
lift-/.f643.1
Applied rewrites3.1%
lift-/.f64N/A
*-inversesN/A
associate-/l/N/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6426.4
Applied rewrites26.4%
if -1e13 < (*.f64 (*.f64 x y) y) < 1.9999999999999999e87Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6493.2
Applied rewrites93.2%
if 1.9999999999999999e87 < (*.f64 (*.f64 x y) y) Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.3
Applied rewrites74.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.3
Applied rewrites74.3%
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
*-lft-identityN/A
*-inversesN/A
associate-*l/N/A
associate-*l*N/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6486.1
Applied rewrites86.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* x y) y)))
(if (<= t_0 -10000000000000.0)
(* (/ x (* x x)) x)
(if (<= t_0 2e+87) (fma (* y y) x 1.0) (/ (* (* (* y y) x) x) x)))))
double code(double x, double y) {
double t_0 = (x * y) * y;
double tmp;
if (t_0 <= -10000000000000.0) {
tmp = (x / (x * x)) * x;
} else if (t_0 <= 2e+87) {
tmp = fma((y * y), x, 1.0);
} else {
tmp = (((y * y) * x) * x) / x;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x * y) * y) tmp = 0.0 if (t_0 <= -10000000000000.0) tmp = Float64(Float64(x / Float64(x * x)) * x); elseif (t_0 <= 2e+87) tmp = fma(Float64(y * y), x, 1.0); else tmp = Float64(Float64(Float64(Float64(y * y) * x) * x) / x); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, -10000000000000.0], N[(N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 2e+87], N[(N[(y * y), $MachinePrecision] * x + 1.0), $MachinePrecision], N[(N[(N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot y\right) \cdot y\\
\mathbf{if}\;t\_0 \leq -10000000000000:\\
\;\;\;\;\frac{x}{x \cdot x} \cdot x\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, x, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(y \cdot y\right) \cdot x\right) \cdot x}{x}\\
\end{array}
\end{array}
if (*.f64 (*.f64 x y) y) < -1e13Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f641.8
Applied rewrites1.8%
lift-fma.f64N/A
lift-*.f64N/A
pow2N/A
lft-mult-inverseN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-/.f641.8
Applied rewrites1.8%
Taylor expanded in x around 0
lift-/.f643.1
Applied rewrites3.1%
lift-/.f64N/A
*-inversesN/A
associate-/l/N/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -1e13 < (*.f64 (*.f64 x y) y) < 1.9999999999999999e87Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6493.2
Applied rewrites93.2%
if 1.9999999999999999e87 < (*.f64 (*.f64 x y) y) Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.3
Applied rewrites74.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6474.3
Applied rewrites74.3%
lift-*.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
*-lft-identityN/A
*-inversesN/A
associate-*l/N/A
associate-*l*N/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6486.1
Applied rewrites86.1%
(FPCore (x y) :precision binary64 (if (<= (* (* x y) y) -10000000000000.0) (* (/ x (* x x)) x) (fma (* y y) x 1.0)))
double code(double x, double y) {
double tmp;
if (((x * y) * y) <= -10000000000000.0) {
tmp = (x / (x * x)) * x;
} else {
tmp = fma((y * y), x, 1.0);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(x * y) * y) <= -10000000000000.0) tmp = Float64(Float64(x / Float64(x * x)) * x); else tmp = fma(Float64(y * y), x, 1.0); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision], -10000000000000.0], N[(N[(x / N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(y * y), $MachinePrecision] * x + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y\right) \cdot y \leq -10000000000000:\\
\;\;\;\;\frac{x}{x \cdot x} \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot y, x, 1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 x y) y) < -1e13Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f641.8
Applied rewrites1.8%
lift-fma.f64N/A
lift-*.f64N/A
pow2N/A
lft-mult-inverseN/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
lower-/.f641.8
Applied rewrites1.8%
Taylor expanded in x around 0
lift-/.f643.1
Applied rewrites3.1%
lift-/.f64N/A
*-inversesN/A
associate-/l/N/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6435.9
Applied rewrites35.9%
if -1e13 < (*.f64 (*.f64 x y) y) Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
(FPCore (x y) :precision binary64 (if (<= (exp (* (* x y) y)) 2.0) 1.0 (* (* y y) x)))
double code(double x, double y) {
double tmp;
if (exp(((x * y) * y)) <= 2.0) {
tmp = 1.0;
} else {
tmp = (y * y) * 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, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (exp(((x * y) * y)) <= 2.0d0) then
tmp = 1.0d0
else
tmp = (y * y) * x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.exp(((x * y) * y)) <= 2.0) {
tmp = 1.0;
} else {
tmp = (y * y) * x;
}
return tmp;
}
def code(x, y): tmp = 0 if math.exp(((x * y) * y)) <= 2.0: tmp = 1.0 else: tmp = (y * y) * x return tmp
function code(x, y) tmp = 0.0 if (exp(Float64(Float64(x * y) * y)) <= 2.0) tmp = 1.0; else tmp = Float64(Float64(y * y) * x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (exp(((x * y) * y)) <= 2.0) tmp = 1.0; else tmp = (y * y) * x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision], 2.0], 1.0, N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(x \cdot y\right) \cdot y} \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot y\right) \cdot x\\
\end{array}
\end{array}
if (exp.f64 (*.f64 (*.f64 x y) y)) < 2Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites67.2%
if 2 < (exp.f64 (*.f64 (*.f64 x y) y)) Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6466.1
Applied rewrites66.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6466.1
Applied rewrites66.1%
(FPCore (x y) :precision binary64 (fma (* y y) x 1.0))
double code(double x, double y) {
return fma((y * y), x, 1.0);
}
function code(x, y) return fma(Float64(y * y), x, 1.0) end
code[x_, y_] := N[(N[(y * y), $MachinePrecision] * x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot y, x, 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6466.8
Applied rewrites66.8%
(FPCore (x y) :precision binary64 (if (<= (exp (* (* x y) y)) 2.0) 1.0 (* (* y x) y)))
double code(double x, double y) {
double tmp;
if (exp(((x * y) * y)) <= 2.0) {
tmp = 1.0;
} else {
tmp = (y * x) * y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (exp(((x * y) * y)) <= 2.0d0) then
tmp = 1.0d0
else
tmp = (y * x) * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (Math.exp(((x * y) * y)) <= 2.0) {
tmp = 1.0;
} else {
tmp = (y * x) * y;
}
return tmp;
}
def code(x, y): tmp = 0 if math.exp(((x * y) * y)) <= 2.0: tmp = 1.0 else: tmp = (y * x) * y return tmp
function code(x, y) tmp = 0.0 if (exp(Float64(Float64(x * y) * y)) <= 2.0) tmp = 1.0; else tmp = Float64(Float64(y * x) * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (exp(((x * y) * y)) <= 2.0) tmp = 1.0; else tmp = (y * x) * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[Exp[N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision], 2.0], 1.0, N[(N[(y * x), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{\left(x \cdot y\right) \cdot y} \leq 2:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot x\right) \cdot y\\
\end{array}
\end{array}
if (exp.f64 (*.f64 (*.f64 x y) y)) < 2Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites67.2%
if 2 < (exp.f64 (*.f64 (*.f64 x y) y)) Initial program 100.0%
Taylor expanded in x around 0
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
remove-double-negN/A
metadata-evalN/A
associate-+r+N/A
+-rgt-identityN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6466.1
Applied rewrites66.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6466.1
Applied rewrites66.1%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6453.6
Applied rewrites53.6%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites50.8%
herbie shell --seed 2025130
(FPCore (x y)
:name "Data.Random.Distribution.Normal:normalF from random-fu-0.2.6.2"
:precision binary64
(exp (* (* x y) y)))