
(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}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
Herbie found 11 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}
\\
\left(x + \sin y\right) + z \cdot \cos y
\end{array}
(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 + x\right)
\end{array}
Initial program 99.9%
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.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (fma x (/ (* (cos y) z) x) x))) (if (<= x -2.1e-35) t_0 (if (<= x 1.16e-29) (fma (cos y) z (sin y)) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(x, ((cos(y) * z) / x), x);
double tmp;
if (x <= -2.1e-35) {
tmp = t_0;
} else if (x <= 1.16e-29) {
tmp = fma(cos(y), z, sin(y));
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(x, Float64(Float64(cos(y) * z) / x), x) tmp = 0.0 if (x <= -2.1e-35) tmp = t_0; elseif (x <= 1.16e-29) tmp = fma(cos(y), z, sin(y)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -2.1e-35], t$95$0, If[LessEqual[x, 1.16e-29], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, \frac{\cos y \cdot z}{x}, x\right)\\
\mathbf{if}\;x \leq -2.1 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.16 \cdot 10^{-29}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.1e-35 or 1.15999999999999996e-29 < x Initial program 99.9%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f6488.5
Applied rewrites88.5%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6472.1
Applied rewrites72.1%
if -2.1e-35 < x < 1.15999999999999996e-29Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f6457.5
Applied rewrites57.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ x y) (* z (cos y)))))
(if (<= z -4.2e+148)
t_0
(if (<= z 3.35e-9)
(+ (+ x (sin y)) z)
(if (<= z 7.5e+157) (fma x (/ (* (cos y) z) x) x) t_0)))))
double code(double x, double y, double z) {
double t_0 = (x + y) + (z * cos(y));
double tmp;
if (z <= -4.2e+148) {
tmp = t_0;
} else if (z <= 3.35e-9) {
tmp = (x + sin(y)) + z;
} else if (z <= 7.5e+157) {
tmp = fma(x, ((cos(y) * z) / x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + y) + Float64(z * cos(y))) tmp = 0.0 if (z <= -4.2e+148) tmp = t_0; elseif (z <= 3.35e-9) tmp = Float64(Float64(x + sin(y)) + z); elseif (z <= 7.5e+157) tmp = fma(x, Float64(Float64(cos(y) * z) / x), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+148], t$95$0, If[LessEqual[z, 3.35e-9], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[z, 7.5e+157], N[(x * N[(N[(N[Cos[y], $MachinePrecision] * z), $MachinePrecision] / x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) + z \cdot \cos y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.35 \cdot 10^{-9}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{\cos y \cdot z}{x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.19999999999999998e148 or 7.5e157 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites71.2%
if -4.19999999999999998e148 < z < 3.34999999999999981e-9Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites83.2%
if 3.34999999999999981e-9 < z < 7.5e157Initial program 99.9%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f6488.5
Applied rewrites88.5%
Taylor expanded in z around inf
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6472.1
Applied rewrites72.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ x y) (* z (cos y)))))
(if (<= z -4.2e+148)
t_0
(if (<= z 3.35e-9)
(+ (+ x (sin y)) z)
(if (<= z 7.5e+157) (fma x (* (/ (cos y) x) z) x) t_0)))))
double code(double x, double y, double z) {
double t_0 = (x + y) + (z * cos(y));
double tmp;
if (z <= -4.2e+148) {
tmp = t_0;
} else if (z <= 3.35e-9) {
tmp = (x + sin(y)) + z;
} else if (z <= 7.5e+157) {
tmp = fma(x, ((cos(y) / x) * z), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x + y) + Float64(z * cos(y))) tmp = 0.0 if (z <= -4.2e+148) tmp = t_0; elseif (z <= 3.35e-9) tmp = Float64(Float64(x + sin(y)) + z); elseif (z <= 7.5e+157) tmp = fma(x, Float64(Float64(cos(y) / x) * z), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+148], t$95$0, If[LessEqual[z, 3.35e-9], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[z, 7.5e+157], N[(x * N[(N[(N[Cos[y], $MachinePrecision] / x), $MachinePrecision] * z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) + z \cdot \cos y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.35 \cdot 10^{-9}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{\cos y}{x} \cdot z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.19999999999999998e148 or 7.5e157 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites71.2%
if -4.19999999999999998e148 < z < 3.34999999999999981e-9Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites83.2%
if 3.34999999999999981e-9 < z < 7.5e157Initial program 99.9%
Taylor expanded in x around inf
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f6488.5
Applied rewrites88.5%
lift-/.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-sin.f64N/A
div-addN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
lift-sin.f6488.4
Applied rewrites88.4%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-/.f6472.0
Applied rewrites72.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (+ x y) (* z (cos y))))) (if (<= z -4.2e+148) t_0 (if (<= z 6e+156) (+ (+ x (sin y)) z) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + y) + (z * cos(y));
double tmp;
if (z <= -4.2e+148) {
tmp = t_0;
} else if (z <= 6e+156) {
tmp = (x + sin(y)) + z;
} 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 + y) + (z * cos(y))
if (z <= (-4.2d+148)) then
tmp = t_0
else if (z <= 6d+156) then
tmp = (x + sin(y)) + z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) + (z * Math.cos(y));
double tmp;
if (z <= -4.2e+148) {
tmp = t_0;
} else if (z <= 6e+156) {
tmp = (x + Math.sin(y)) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) + (z * math.cos(y)) tmp = 0 if z <= -4.2e+148: tmp = t_0 elif z <= 6e+156: tmp = (x + math.sin(y)) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) + Float64(z * cos(y))) tmp = 0.0 if (z <= -4.2e+148) tmp = t_0; elseif (z <= 6e+156) tmp = Float64(Float64(x + sin(y)) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) + (z * cos(y)); tmp = 0.0; if (z <= -4.2e+148) tmp = t_0; elseif (z <= 6e+156) tmp = (x + sin(y)) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+148], t$95$0, If[LessEqual[z, 6e+156], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + y\right) + z \cdot \cos y\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+156}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.19999999999999998e148 or 5.9999999999999999e156 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites71.2%
if -4.19999999999999998e148 < z < 5.9999999999999999e156Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites83.2%
(FPCore (x y z) :precision binary64 (if (<= z -8500000.0) (* (cos y) z) (+ (+ x (sin y)) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8500000.0) {
tmp = cos(y) * z;
} else {
tmp = (x + sin(y)) + 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 <= (-8500000.0d0)) then
tmp = cos(y) * z
else
tmp = (x + sin(y)) + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8500000.0) {
tmp = Math.cos(y) * z;
} else {
tmp = (x + Math.sin(y)) + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8500000.0: tmp = math.cos(y) * z else: tmp = (x + math.sin(y)) + z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8500000.0) tmp = Float64(cos(y) * z); else tmp = Float64(Float64(x + sin(y)) + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8500000.0) tmp = cos(y) * z; else tmp = (x + sin(y)) + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8500000.0], 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}\;z \leq -8500000:\\
\;\;\;\;\cos y \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\end{array}
\end{array}
if z < -8.5e6Initial program 99.9%
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.9
Applied rewrites99.9%
Taylor expanded in z around inf
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f6441.7
Applied rewrites41.7%
if -8.5e6 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites83.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (sin y) x)))
(if (<= y -0.02)
t_0
(if (<= y 0.155) (+ (fma (fma (* z y) -0.5 1.0) y z) x) t_0))))
double code(double x, double y, double z) {
double t_0 = sin(y) + x;
double tmp;
if (y <= -0.02) {
tmp = t_0;
} else if (y <= 0.155) {
tmp = fma(fma((z * y), -0.5, 1.0), y, z) + x;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(sin(y) + x) tmp = 0.0 if (y <= -0.02) tmp = t_0; elseif (y <= 0.155) tmp = Float64(fma(fma(Float64(z * y), -0.5, 1.0), y, z) + x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -0.02], t$95$0, If[LessEqual[y, 0.155], N[(N[(N[(N[(z * y), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * y + z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin y + x\\
\mathbf{if}\;y \leq -0.02:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.155:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z \cdot y, -0.5, 1\right), y, z\right) + x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -0.0200000000000000004 or 0.154999999999999999 < y Initial program 99.9%
lift-+.f64N/A
lift-+.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
associate-+l+N/A
+-commutativeN/A
flip-+N/A
lower-/.f64N/A
Applied rewrites57.6%
Taylor expanded in z around 0
unpow2N/A
pow2N/A
flip-+N/A
lift-sin.f64N/A
lift-+.f6459.5
Applied rewrites59.5%
if -0.0200000000000000004 < y < 0.154999999999999999Initial program 99.9%
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-*.f6458.2
Applied rewrites58.2%
(FPCore (x y z) :precision binary64 (+ z x))
double code(double x, double y, double z) {
return z + 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 = z + x
end function
public static double code(double x, double y, double z) {
return z + x;
}
def code(x, y, z): return z + x
function code(x, y, z) return Float64(z + x) end
function tmp = code(x, y, z) tmp = z + x; end
code[x_, y_, z_] := N[(z + x), $MachinePrecision]
\begin{array}{l}
\\
z + x
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6467.4
Applied rewrites67.4%
(FPCore (x y z) :precision binary64 (if (<= x -3.2e-15) (+ y x) (if (<= x 9.5e+42) (+ z y) (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.2e-15) {
tmp = y + x;
} else if (x <= 9.5e+42) {
tmp = z + y;
} else {
tmp = 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-3.2d-15)) then
tmp = y + x
else if (x <= 9.5d+42) then
tmp = z + y
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.2e-15) {
tmp = y + x;
} else if (x <= 9.5e+42) {
tmp = z + y;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.2e-15: tmp = y + x elif x <= 9.5e+42: tmp = z + y else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.2e-15) tmp = Float64(y + x); elseif (x <= 9.5e+42) tmp = Float64(z + y); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.2e-15) tmp = y + x; elseif (x <= 9.5e+42) tmp = z + y; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.2e-15], N[(y + x), $MachinePrecision], If[LessEqual[x, 9.5e+42], N[(z + y), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-15}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+42}:\\
\;\;\;\;z + y\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if x < -3.1999999999999999e-15 or 9.50000000000000019e42 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6462.6
Applied rewrites62.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6439.6
Applied rewrites39.6%
if -3.1999999999999999e-15 < x < 9.50000000000000019e42Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6462.6
Applied rewrites62.6%
Taylor expanded in x around 0
+-commutativeN/A
lift-+.f6429.2
Applied rewrites29.2%
(FPCore (x y z) :precision binary64 (if (<= x -3.2e-15) (+ y x) (if (<= x 9.5e+42) z (+ y x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.2e-15) {
tmp = y + x;
} else if (x <= 9.5e+42) {
tmp = z;
} else {
tmp = 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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-3.2d-15)) then
tmp = y + x
else if (x <= 9.5d+42) then
tmp = z
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3.2e-15) {
tmp = y + x;
} else if (x <= 9.5e+42) {
tmp = z;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.2e-15: tmp = y + x elif x <= 9.5e+42: tmp = z else: tmp = y + x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.2e-15) tmp = Float64(y + x); elseif (x <= 9.5e+42) tmp = z; else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3.2e-15) tmp = y + x; elseif (x <= 9.5e+42) tmp = z; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.2e-15], N[(y + x), $MachinePrecision], If[LessEqual[x, 9.5e+42], z, N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{-15}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+42}:\\
\;\;\;\;z\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if x < -3.1999999999999999e-15 or 9.50000000000000019e42 < x Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f6462.6
Applied rewrites62.6%
Taylor expanded in z around 0
+-commutativeN/A
lower-+.f6439.6
Applied rewrites39.6%
if -3.1999999999999999e-15 < x < 9.50000000000000019e42Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6467.4
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites26.0%
(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.9%
Taylor expanded in y around 0
+-commutativeN/A
lower-+.f6467.4
Applied rewrites67.4%
Taylor expanded in x around 0
Applied rewrites26.0%
herbie shell --seed 2025139
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, C"
:precision binary64
(+ (+ x (sin y)) (* z (cos y))))