
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(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 * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x (sin y)) (* z (cos y))))
double code(double x, double y, double z) {
return (x * sin(y)) + (z * cos(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 * sin(y)) + (z * cos(y))
end function
public static double code(double x, double y, double z) {
return (x * Math.sin(y)) + (z * Math.cos(y));
}
def code(x, y, z): return (x * math.sin(y)) + (z * math.cos(y))
function code(x, y, z) return Float64(Float64(x * sin(y)) + Float64(z * cos(y))) end
function tmp = code(x, y, z) tmp = (x * sin(y)) + (z * cos(y)); end
code[x_, y_, z_] := N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \sin y + z \cdot \cos y
\end{array}
(FPCore (x y z) :precision binary64 (fma (sin y) x (* (cos y) z)))
double code(double x, double y, double z) {
return fma(sin(y), x, (cos(y) * z));
}
function code(x, y, z) return fma(sin(y), x, Float64(cos(y) * z)) end
code[x_, y_, z_] := N[(N[Sin[y], $MachinePrecision] * x + N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\sin y, x, \cos y \cdot z\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (fma (cos y) z (* (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) * x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) * x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos y, z, \sin y \cdot x\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (sin y) x)) (t_1 (* (cos y) z)))
(if (<= y -6e+52)
t_0
(if (<= y -0.205)
t_1
(if (<= y 0.115)
(+
(fma
y
x
(*
(*
(fma
(* 0.008333333333333333 x)
(* y y)
(* -0.16666666666666666 x))
(* y y))
y))
z)
(if (<= y 2e+122) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = sin(y) * x;
double t_1 = cos(y) * z;
double tmp;
if (y <= -6e+52) {
tmp = t_0;
} else if (y <= -0.205) {
tmp = t_1;
} else if (y <= 0.115) {
tmp = fma(y, x, ((fma((0.008333333333333333 * x), (y * y), (-0.16666666666666666 * x)) * (y * y)) * y)) + z;
} else if (y <= 2e+122) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) * x) t_1 = Float64(cos(y) * z) tmp = 0.0 if (y <= -6e+52) tmp = t_0; elseif (y <= -0.205) tmp = t_1; elseif (y <= 0.115) tmp = Float64(fma(y, x, Float64(Float64(fma(Float64(0.008333333333333333 * x), Float64(y * y), Float64(-0.16666666666666666 * x)) * Float64(y * y)) * y)) + z); elseif (y <= 2e+122) tmp = t_1; else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -6e+52], t$95$0, If[LessEqual[y, -0.205], t$95$1, If[LessEqual[y, 0.115], N[(N[(y * x + N[(N[(N[(N[(0.008333333333333333 * x), $MachinePrecision] * N[(y * y), $MachinePrecision] + N[(-0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[y, 2e+122], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y \cdot x\\
t_1 := \cos y \cdot z\\
\mathbf{if}\;y \leq -6 \cdot 10^{+52}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -0.205:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.115:\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(\mathsf{fma}\left(0.008333333333333333 \cdot x, y \cdot y, -0.16666666666666666 \cdot x\right) \cdot \left(y \cdot y\right)\right) \cdot y\right) + z\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+122}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -6e52 or 2.00000000000000003e122 < y Initial program 99.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6450.7
Applied rewrites50.7%
if -6e52 < y < -0.204999999999999988 or 0.115000000000000005 < y < 2.00000000000000003e122Initial program 99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6451.3
Applied rewrites51.3%
if -0.204999999999999988 < y < 0.115000000000000005Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (if (<= x -5.8e-26) (fma (sin y) x z) (if (<= x 1.9e-46) (* (cos y) z) (+ (* x (sin y)) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.8e-26) {
tmp = fma(sin(y), x, z);
} else if (x <= 1.9e-46) {
tmp = cos(y) * z;
} else {
tmp = (x * sin(y)) + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -5.8e-26) tmp = fma(sin(y), x, z); elseif (x <= 1.9e-46) tmp = Float64(cos(y) * z); else tmp = Float64(Float64(x * sin(y)) + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -5.8e-26], N[(N[Sin[y], $MachinePrecision] * x + z), $MachinePrecision], If[LessEqual[x, 1.9e-46], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], N[(N[(x * N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{-26}:\\
\;\;\;\;\mathsf{fma}\left(\sin y, x, z\right)\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-46}:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \sin y + z\\
\end{array}
\end{array}
if x < -5.7999999999999996e-26Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites86.7%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f6486.7
Applied rewrites86.7%
if -5.7999999999999996e-26 < x < 1.8999999999999998e-46Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6486.1
Applied rewrites86.1%
if 1.8999999999999998e-46 < x Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites86.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma (sin y) x z))) (if (<= x -5.8e-26) t_0 (if (<= x 1.9e-46) (* (cos y) z) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(sin(y), x, z);
double tmp;
if (x <= -5.8e-26) {
tmp = t_0;
} else if (x <= 1.9e-46) {
tmp = cos(y) * z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(sin(y), x, z) tmp = 0.0 if (x <= -5.8e-26) tmp = t_0; elseif (x <= 1.9e-46) tmp = Float64(cos(y) * z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] * x + z), $MachinePrecision]}, If[LessEqual[x, -5.8e-26], t$95$0, If[LessEqual[x, 1.9e-46], N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin y, x, z\right)\\
\mathbf{if}\;x \leq -5.8 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-46}:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.7999999999999996e-26 or 1.8999999999999998e-46 < x Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites86.3%
lift-+.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f6486.3
Applied rewrites86.3%
if -5.7999999999999996e-26 < x < 1.8999999999999998e-46Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6486.1
Applied rewrites86.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cos y) z)))
(if (<= y -0.205)
t_0
(if (<= y 0.115)
(+
(fma
y
x
(*
(*
(fma (* 0.008333333333333333 x) (* y y) (* -0.16666666666666666 x))
(* y y))
y))
z)
t_0))))
double code(double x, double y, double z) {
double t_0 = cos(y) * z;
double tmp;
if (y <= -0.205) {
tmp = t_0;
} else if (y <= 0.115) {
tmp = fma(y, x, ((fma((0.008333333333333333 * x), (y * y), (-0.16666666666666666 * x)) * (y * y)) * y)) + z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(cos(y) * z) tmp = 0.0 if (y <= -0.205) tmp = t_0; elseif (y <= 0.115) tmp = Float64(fma(y, x, Float64(Float64(fma(Float64(0.008333333333333333 * x), Float64(y * y), Float64(-0.16666666666666666 * x)) * Float64(y * y)) * y)) + z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[y, -0.205], t$95$0, If[LessEqual[y, 0.115], N[(N[(y * x + N[(N[(N[(N[(0.008333333333333333 * x), $MachinePrecision] * N[(y * y), $MachinePrecision] + N[(-0.16666666666666666 * x), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos y \cdot z\\
\mathbf{if}\;y \leq -0.205:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.115:\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(\mathsf{fma}\left(0.008333333333333333 \cdot x, y \cdot y, -0.16666666666666666 \cdot x\right) \cdot \left(y \cdot y\right)\right) \cdot y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.204999999999999988 or 0.115000000000000005 < y Initial program 99.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6450.7
Applied rewrites50.7%
if -0.204999999999999988 < y < 0.115000000000000005Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites99.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.5
Applied rewrites99.5%
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (if (<= z -8.5e-138) z (if (<= z 4.5e-97) (* x y) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-138) {
tmp = z;
} else if (z <= 4.5e-97) {
tmp = x * y;
} else {
tmp = z;
}
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 (z <= (-8.5d-138)) then
tmp = z
else if (z <= 4.5d-97) then
tmp = x * y
else
tmp = z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-138) {
tmp = z;
} else if (z <= 4.5e-97) {
tmp = x * y;
} else {
tmp = z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.5e-138: tmp = z elif z <= 4.5e-97: tmp = x * y else: tmp = z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.5e-138) tmp = z; elseif (z <= 4.5e-97) tmp = Float64(x * y); else tmp = z; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.5e-138) tmp = z; elseif (z <= 4.5e-97) tmp = x * y; else tmp = z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.5e-138], z, If[LessEqual[z, 4.5e-97], N[(x * y), $MachinePrecision], z]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-138}:\\
\;\;\;\;z\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-97}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z\\
\end{array}
\end{array}
if z < -8.50000000000000035e-138 or 4.5000000000000001e-97 < z Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites45.9%
if -8.50000000000000035e-138 < z < 4.5000000000000001e-97Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.2
Applied rewrites51.2%
Taylor expanded in x around inf
lower-*.f6431.3
Applied rewrites31.3%
(FPCore (x y z) :precision binary64 (fma y x z))
double code(double x, double y, double z) {
return fma(y, x, z);
}
function code(x, y, z) return fma(y, x, z) end
code[x_, y_, z_] := N[(y * x + z), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x, z\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6452.5
Applied rewrites52.5%
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
return z;
}
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 = z
end function
public static double code(double x, double y, double z) {
return z;
}
def code(x, y, z): return z
function code(x, y, z) return z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 99.8%
Taylor expanded in y around 0
Applied rewrites39.1%
herbie shell --seed 2025107
(FPCore (x y z)
:name "Diagrams.ThreeD.Transform:aboutX from diagrams-lib-1.3.0.3, B"
:precision binary64
(+ (* x (sin y)) (* z (cos y))))