
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (fma (cos y) x (* (- z) (sin y))))
double code(double x, double y, double z) {
return fma(cos(y), x, (-z * sin(y)));
}
function code(x, y, z) return fma(cos(y), x, Float64(Float64(-z) * sin(y))) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * x + N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, x, \left(-z\right) \cdot \sin y\right)
\end{array}
Initial program 99.8%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
lift-cos.f64N/A
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (- (* x (cos y)) (* z (sin y))))
double code(double x, double y, double z) {
return (x * cos(y)) - (z * sin(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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * cos(y)) - (z * sin(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.cos(y)) - (z * Math.sin(y));
}
def code(x, y, z): return (x * math.cos(y)) - (z * math.sin(y))
function code(x, y, z) return Float64(Float64(x * cos(y)) - Float64(z * sin(y))) end
function tmp = code(x, y, z) tmp = (x * cos(y)) - (z * sin(y)); end
code[x_, y_, z_] := N[(N[(x * N[Cos[y], $MachinePrecision]), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \cos y - z \cdot \sin y
\end{array}
Initial program 99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- x (* (sin y) z)))) (if (<= z -1.75e-39) t_0 (if (<= z 7.5e-80) (* (cos y) x) t_0))))
double code(double x, double y, double z) {
double t_0 = x - (sin(y) * z);
double tmp;
if (z <= -1.75e-39) {
tmp = t_0;
} else if (z <= 7.5e-80) {
tmp = cos(y) * x;
} else {
tmp = t_0;
}
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x - (sin(y) * z)
if (z <= (-1.75d-39)) then
tmp = t_0
else if (z <= 7.5d-80) then
tmp = cos(y) * x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (Math.sin(y) * z);
double tmp;
if (z <= -1.75e-39) {
tmp = t_0;
} else if (z <= 7.5e-80) {
tmp = Math.cos(y) * x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x - (math.sin(y) * z) tmp = 0 if z <= -1.75e-39: tmp = t_0 elif z <= 7.5e-80: tmp = math.cos(y) * x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x - Float64(sin(y) * z)) tmp = 0.0 if (z <= -1.75e-39) tmp = t_0; elseif (z <= 7.5e-80) tmp = Float64(cos(y) * x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (sin(y) * z); tmp = 0.0; if (z <= -1.75e-39) tmp = t_0; elseif (z <= 7.5e-80) tmp = cos(y) * x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e-39], t$95$0, If[LessEqual[z, 7.5e-80], N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \sin y \cdot z\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{-39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-80}:\\
\;\;\;\;\cos y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.75e-39 or 7.49999999999999999e-80 < z Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites85.9%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6485.9
Applied rewrites85.9%
if -1.75e-39 < z < 7.49999999999999999e-80Initial program 99.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6487.1
Applied rewrites87.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- z) (sin y))))
(if (<= y -0.0056)
t_0
(if (<= y 0.0055)
(fma (- (* (fma 0.16666666666666666 (* z y) (* -0.5 x)) y) z) y x)
(if (<= y 4.5e+141) t_0 (* (cos y) x))))))
double code(double x, double y, double z) {
double t_0 = -z * sin(y);
double tmp;
if (y <= -0.0056) {
tmp = t_0;
} else if (y <= 0.0055) {
tmp = fma(((fma(0.16666666666666666, (z * y), (-0.5 * x)) * y) - z), y, x);
} else if (y <= 4.5e+141) {
tmp = t_0;
} else {
tmp = cos(y) * x;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-z) * sin(y)) tmp = 0.0 if (y <= -0.0056) tmp = t_0; elseif (y <= 0.0055) tmp = fma(Float64(Float64(fma(0.16666666666666666, Float64(z * y), Float64(-0.5 * x)) * y) - z), y, x); elseif (y <= 4.5e+141) tmp = t_0; else tmp = Float64(cos(y) * x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[((-z) * N[Sin[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.0056], t$95$0, If[LessEqual[y, 0.0055], N[(N[(N[(N[(0.16666666666666666 * N[(z * y), $MachinePrecision] + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] - z), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[y, 4.5e+141], t$95$0, N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-z\right) \cdot \sin y\\
\mathbf{if}\;y \leq -0.0056:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.0055:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, z \cdot y, -0.5 \cdot x\right) \cdot y - z, y, x\right)\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+141}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos y \cdot x\\
\end{array}
\end{array}
if y < -0.00559999999999999994 or 0.0054999999999999997 < y < 4.5000000000000002e141Initial program 99.6%
Taylor expanded in x around 0
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lift-sin.f6450.4
Applied rewrites50.4%
if -0.00559999999999999994 < y < 0.0054999999999999997Initial program 100.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
if 4.5000000000000002e141 < y Initial program 99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6450.2
Applied rewrites50.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) x)))
(if (<= y -2.1e+21)
t_0
(if (<= y 0.17)
(-
x
(*
(fma
(* z (fma (* y y) 0.008333333333333333 -0.16666666666666666))
(* y y)
z)
y))
t_0))))
double code(double x, double y, double z) {
double t_0 = cos(y) * x;
double tmp;
if (y <= -2.1e+21) {
tmp = t_0;
} else if (y <= 0.17) {
tmp = x - (fma((z * fma((y * y), 0.008333333333333333, -0.16666666666666666)), (y * y), z) * y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(cos(y) * x) tmp = 0.0 if (y <= -2.1e+21) tmp = t_0; elseif (y <= 0.17) tmp = Float64(x - Float64(fma(Float64(z * fma(Float64(y * y), 0.008333333333333333, -0.16666666666666666)), Float64(y * y), z) * y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -2.1e+21], t$95$0, If[LessEqual[y, 0.17], N[(x - N[(N[(N[(z * N[(N[(y * y), $MachinePrecision] * 0.008333333333333333 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot x\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.17:\\
\;\;\;\;x - \mathsf{fma}\left(z \cdot \mathsf{fma}\left(y \cdot y, 0.008333333333333333, -0.16666666666666666\right), y \cdot y, z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.1e21 or 0.170000000000000012 < y Initial program 99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6450.3
Applied rewrites50.3%
if -2.1e21 < y < 0.170000000000000012Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites98.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.9
Applied rewrites96.9%
*-commutative96.9
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites96.9%
(FPCore (x y z) :precision binary64 (fma (- z) y x))
double code(double x, double y, double z) {
return fma(-z, y, x);
}
function code(x, y, z) return fma(Float64(-z), y, x) end
code[x_, y_, z_] := N[((-z) * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-z, y, x\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in y around 0
mul-1-negN/A
lift-neg.f6453.5
Applied rewrites53.5%
(FPCore (x y z) :precision binary64 (- x (* z y)))
double code(double x, double y, double z) {
return x - (z * 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - (z * y)
end function
public static double code(double x, double y, double z) {
return x - (z * y);
}
def code(x, y, z): return x - (z * y)
function code(x, y, z) return Float64(x - Float64(z * y)) end
function tmp = code(x, y, z) tmp = x - (z * y); end
code[x_, y_, z_] := N[(x - N[(z * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e-77) (* (- y) z) x))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-77) {
tmp = -y * z;
} else {
tmp = 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.9d-77)) then
tmp = -y * z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-77) {
tmp = -y * z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.9e-77: tmp = -y * z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.9e-77) tmp = Float64(Float64(-y) * z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.9e-77) tmp = -y * z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.9e-77], N[((-y) * z), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-77}:\\
\;\;\;\;\left(-y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -2.8999999999999999e-77Initial program 99.7%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6488.3
Applied rewrites88.3%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-/.f6488.2
Applied rewrites88.2%
Taylor expanded in y around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f6424.3
Applied rewrites24.3%
Taylor expanded in x around 0
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lower-*.f6412.2
Applied rewrites12.2%
if -2.8999999999999999e-77 < y Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites49.6%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return 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, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites39.6%
herbie shell --seed 2025112
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, A"
:precision binary64
(- (* x (cos y)) (* z (sin y))))