
(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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
Herbie found 12 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}
\\
\left(x + \cos y\right) - z \cdot \sin y
\end{array}
(FPCore (x y z) :precision binary64 (- x (fma (sin y) z (- (cos y)))))
double code(double x, double y, double z) {
return x - fma(sin(y), z, -cos(y));
}
function code(x, y, z) return Float64(x - fma(sin(y), z, Float64(-cos(y)))) end
code[x_, y_, z_] := N[(x - N[(N[Sin[y], $MachinePrecision] * z + (-N[Cos[y], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \mathsf{fma}\left(\sin y, z, -\cos y\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sub-flipN/A
lower-fma.f64N/A
lift-sin.f64N/A
lower-neg.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
(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(x - Float64(Float64(sin(y) * z) - cos(y))) end
function tmp = code(x, y, z) tmp = x - ((sin(y) * z) - cos(y)); end
code[x_, y_, z_] := N[(x - N[(N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\sin y \cdot z - \cos y\right)
\end{array}
Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (+ x 1.0) (* z (sin y))))) (if (<= z -460000000.0) t_0 (if (<= z 1.3e-19) (- x (- (cos y))) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + 1.0) - (z * sin(y));
double tmp;
if (z <= -460000000.0) {
tmp = t_0;
} else if (z <= 1.3e-19) {
tmp = x - -cos(y);
} 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 + 1.0d0) - (z * sin(y))
if (z <= (-460000000.0d0)) then
tmp = t_0
else if (z <= 1.3d-19) then
tmp = x - -cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + 1.0) - (z * Math.sin(y));
double tmp;
if (z <= -460000000.0) {
tmp = t_0;
} else if (z <= 1.3e-19) {
tmp = x - -Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + 1.0) - (z * math.sin(y)) tmp = 0 if z <= -460000000.0: tmp = t_0 elif z <= 1.3e-19: tmp = x - -math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + 1.0) - Float64(z * sin(y))) tmp = 0.0 if (z <= -460000000.0) tmp = t_0; elseif (z <= 1.3e-19) tmp = Float64(x - Float64(-cos(y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + 1.0) - (z * sin(y)); tmp = 0.0; if (z <= -460000000.0) tmp = t_0; elseif (z <= 1.3e-19) tmp = x - -cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + 1.0), $MachinePrecision] - N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -460000000.0], t$95$0, If[LessEqual[z, 1.3e-19], N[(x - (-N[Cos[y], $MachinePrecision])), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x + 1\right) - z \cdot \sin y\\
\mathbf{if}\;z \leq -460000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-19}:\\
\;\;\;\;x - \left(-\cos y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.6e8 or 1.30000000000000006e-19 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites88.5%
if -4.6e8 < z < 1.30000000000000006e-19Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6473.1
Applied rewrites73.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (* (sin y) z)))) (if (<= z -5.2e+151) t_0 (if (<= z 6.2e+133) (- x (- (cos y))) t_0))))
double code(double x, double y, double z) {
double t_0 = -(sin(y) * z);
double tmp;
if (z <= -5.2e+151) {
tmp = t_0;
} else if (z <= 6.2e+133) {
tmp = x - -cos(y);
} 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 = -(sin(y) * z)
if (z <= (-5.2d+151)) then
tmp = t_0
else if (z <= 6.2d+133) then
tmp = x - -cos(y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -(Math.sin(y) * z);
double tmp;
if (z <= -5.2e+151) {
tmp = t_0;
} else if (z <= 6.2e+133) {
tmp = x - -Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(math.sin(y) * z) tmp = 0 if z <= -5.2e+151: tmp = t_0 elif z <= 6.2e+133: tmp = x - -math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(sin(y) * z)) tmp = 0.0 if (z <= -5.2e+151) tmp = t_0; elseif (z <= 6.2e+133) tmp = Float64(x - Float64(-cos(y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(sin(y) * z); tmp = 0.0; if (z <= -5.2e+151) tmp = t_0; elseif (z <= 6.2e+133) tmp = x - -cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision])}, If[LessEqual[z, -5.2e+151], t$95$0, If[LessEqual[z, 6.2e+133], N[(x - (-N[Cos[y], $MachinePrecision])), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sin y \cdot z\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+133}:\\
\;\;\;\;x - \left(-\cos y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.20000000000000026e151 or 6.2e133 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6428.4
Applied rewrites28.4%
if -5.20000000000000026e151 < z < 6.2e133Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6473.1
Applied rewrites73.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (- (cos y)))))
(if (<= y -2.0)
t_0
(if (<= y 3e-44)
(- x (fma (fma (fma -0.16666666666666666 (* z y) 0.5) y z) y -1.0))
t_0))))
double code(double x, double y, double z) {
double t_0 = x - -cos(y);
double tmp;
if (y <= -2.0) {
tmp = t_0;
} else if (y <= 3e-44) {
tmp = x - fma(fma(fma(-0.16666666666666666, (z * y), 0.5), y, z), y, -1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x - Float64(-cos(y))) tmp = 0.0 if (y <= -2.0) tmp = t_0; elseif (y <= 3e-44) tmp = Float64(x - fma(fma(fma(-0.16666666666666666, Float64(z * y), 0.5), y, z), y, -1.0)); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - (-N[Cos[y], $MachinePrecision])), $MachinePrecision]}, If[LessEqual[y, -2.0], t$95$0, If[LessEqual[y, 3e-44], N[(x - N[(N[(N[(-0.16666666666666666 * N[(z * y), $MachinePrecision] + 0.5), $MachinePrecision] * y + z), $MachinePrecision] * y + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \left(-\cos y\right)\\
\mathbf{if}\;y \leq -2:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-44}:\\
\;\;\;\;x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, z \cdot y, 0.5\right), y, z\right), y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2 or 3.0000000000000002e-44 < y Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6473.1
Applied rewrites73.1%
if -2 < y < 3.0000000000000002e-44Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6454.5
Applied rewrites54.5%
(FPCore (x y z)
:precision binary64
(if (<= y -6500.0)
(- x -1.0)
(if (<= y 55000.0)
(- x (fma (fma (fma -0.16666666666666666 (* z y) 0.5) y z) y -1.0))
(- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6500.0) {
tmp = x - -1.0;
} else if (y <= 55000.0) {
tmp = x - fma(fma(fma(-0.16666666666666666, (z * y), 0.5), y, z), y, -1.0);
} else {
tmp = x - -1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6500.0) tmp = Float64(x - -1.0); elseif (y <= 55000.0) tmp = Float64(x - fma(fma(fma(-0.16666666666666666, Float64(z * y), 0.5), y, z), y, -1.0)); else tmp = Float64(x - -1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6500.0], N[(x - -1.0), $MachinePrecision], If[LessEqual[y, 55000.0], N[(x - N[(N[(N[(-0.16666666666666666 * N[(z * y), $MachinePrecision] + 0.5), $MachinePrecision] * y + z), $MachinePrecision] * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6500:\\
\;\;\;\;x - -1\\
\mathbf{elif}\;y \leq 55000:\\
\;\;\;\;x - \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(-0.16666666666666666, z \cdot y, 0.5\right), y, z\right), y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if y < -6500 or 55000 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
if -6500 < y < 55000Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f6454.5
Applied rewrites54.5%
(FPCore (x y z) :precision binary64 (if (<= y -10500.0) (- x -1.0) (if (<= y 9000.0) (- (fma (- (* -0.5 y) z) y x) -1.0) (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -10500.0) {
tmp = x - -1.0;
} else if (y <= 9000.0) {
tmp = fma(((-0.5 * y) - z), y, x) - -1.0;
} else {
tmp = x - -1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -10500.0) tmp = Float64(x - -1.0); elseif (y <= 9000.0) tmp = Float64(fma(Float64(Float64(-0.5 * y) - z), y, x) - -1.0); else tmp = Float64(x - -1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -10500.0], N[(x - -1.0), $MachinePrecision], If[LessEqual[y, 9000.0], N[(N[(N[(N[(-0.5 * y), $MachinePrecision] - z), $MachinePrecision] * y + x), $MachinePrecision] - -1.0), $MachinePrecision], N[(x - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -10500:\\
\;\;\;\;x - -1\\
\mathbf{elif}\;y \leq 9000:\\
\;\;\;\;\mathsf{fma}\left(-0.5 \cdot y - z, y, x\right) - -1\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if y < -10500 or 9e3 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
if -10500 < y < 9e3Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6455.6
Applied rewrites55.6%
(FPCore (x y z) :precision binary64 (if (<= y -2e+44) (- x -1.0) (if (<= y 1.2e+70) (- x (fma z y -1.0)) (- x -1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+44) {
tmp = x - -1.0;
} else if (y <= 1.2e+70) {
tmp = x - fma(z, y, -1.0);
} else {
tmp = x - -1.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2e+44) tmp = Float64(x - -1.0); elseif (y <= 1.2e+70) tmp = Float64(x - fma(z, y, -1.0)); else tmp = Float64(x - -1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2e+44], N[(x - -1.0), $MachinePrecision], If[LessEqual[y, 1.2e+70], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+44}:\\
\;\;\;\;x - -1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+70}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
\end{array}
if y < -2.0000000000000002e44 or 1.19999999999999993e70 < y Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
if -2.0000000000000002e44 < y < 1.19999999999999993e70Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
sub-flipN/A
mul-1-negN/A
associate-+r+N/A
add-flipN/A
lower--.f64N/A
mul-1-negN/A
sub-flipN/A
sub-negate-revN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f6499.9
Applied rewrites99.9%
Taylor expanded in y around 0
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6463.6
Applied rewrites63.6%
(FPCore (x y z) :precision binary64 (if (<= z 4.4e+176) (- x -1.0) (fma (- z) y 1.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= 4.4e+176) {
tmp = x - -1.0;
} else {
tmp = fma(-z, y, 1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 4.4e+176) tmp = Float64(x - -1.0); else tmp = fma(Float64(-z), y, 1.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 4.4e+176], N[(x - -1.0), $MachinePrecision], N[((-z) * y + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.4 \cdot 10^{+176}:\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-z, y, 1\right)\\
\end{array}
\end{array}
if z < 4.40000000000000015e176Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
if 4.40000000000000015e176 < z Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6455.6
Applied rewrites55.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
lift-*.f6428.3
Applied rewrites28.3%
Taylor expanded in y around 0
mul-1-negN/A
lower-neg.f6429.0
Applied rewrites29.0%
(FPCore (x y z) :precision binary64 (if (<= z 9.2e+232) (- x -1.0) (- (* y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 9.2e+232) {
tmp = x - -1.0;
} else {
tmp = -(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 <= 9.2d+232) then
tmp = x - (-1.0d0)
else
tmp = -(y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 9.2e+232) {
tmp = x - -1.0;
} else {
tmp = -(y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 9.2e+232: tmp = x - -1.0 else: tmp = -(y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 9.2e+232) tmp = Float64(x - -1.0); else tmp = Float64(-Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 9.2e+232) tmp = x - -1.0; else tmp = -(y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 9.2e+232], N[(x - -1.0), $MachinePrecision], (-N[(y * z), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 9.2 \cdot 10^{+232}:\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;-y \cdot z\\
\end{array}
\end{array}
if z < 9.20000000000000024e232Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
if 9.20000000000000024e232 < z Initial program 99.9%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6428.4
Applied rewrites28.4%
Taylor expanded in y around 0
Applied rewrites10.3%
(FPCore (x y z) :precision binary64 (- x -1.0))
double code(double x, double y, double z) {
return x - -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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - (-1.0d0)
end function
public static double code(double x, double y, double z) {
return x - -1.0;
}
def code(x, y, z): return x - -1.0
function code(x, y, z) return Float64(x - -1.0) end
function tmp = code(x, y, z) tmp = x - -1.0; end
code[x_, y_, z_] := N[(x - -1.0), $MachinePrecision]
\begin{array}{l}
\\
x - -1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
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, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6462.1
Applied rewrites62.1%
Taylor expanded in x around 0
Applied rewrites21.8%
herbie shell --seed 2025136
(FPCore (x y z)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, B"
:precision binary64
(- (+ x (cos y)) (* z (sin y))))