
(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]
\left(x + \cos y\right) - z \cdot \sin y
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]
\left(x + \cos y\right) - z \cdot \sin y
(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]
x - \left(\sin y \cdot z - \cos y\right)
Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- 1.0 (* (sin y) z)) x))) (if (<= z -18.5) t_0 (if (<= z 2.8e-7) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = (1.0 - (sin(y) * z)) + x;
double tmp;
if (z <= -18.5) {
tmp = t_0;
} else if (z <= 2.8e-7) {
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 = (1.0d0 - (sin(y) * z)) + x
if (z <= (-18.5d0)) then
tmp = t_0
else if (z <= 2.8d-7) 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 = (1.0 - (Math.sin(y) * z)) + x;
double tmp;
if (z <= -18.5) {
tmp = t_0;
} else if (z <= 2.8e-7) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - (math.sin(y) * z)) + x tmp = 0 if z <= -18.5: tmp = t_0 elif z <= 2.8e-7: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - Float64(sin(y) * z)) + x) tmp = 0.0 if (z <= -18.5) tmp = t_0; elseif (z <= 2.8e-7) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 - (sin(y) * z)) + x; tmp = 0.0; if (z <= -18.5) tmp = t_0; elseif (z <= 2.8e-7) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - N[(N[Sin[y], $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -18.5], t$95$0, If[LessEqual[z, 2.8e-7], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \left(1 - \sin y \cdot z\right) + x\\
\mathbf{if}\;z \leq -18.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-7}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -18.5 or 2.80000000000000019e-7 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites87.5%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lower-+.f64N/A
lower--.f6487.5%
lift-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6487.5%
Applied rewrites87.5%
if -18.5 < z < 2.80000000000000019e-7Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
sub-to-mult-revN/A
lift-/.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flipN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites92.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-cos.f6472.1%
Applied rewrites72.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* -1.0 (* z (sin y))))) (if (<= z -3.3e+140) t_0 (if (<= z 2.25e+182) (+ x (cos y)) t_0))))
double code(double x, double y, double z) {
double t_0 = -1.0 * (z * sin(y));
double tmp;
if (z <= -3.3e+140) {
tmp = t_0;
} else if (z <= 2.25e+182) {
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 = (-1.0d0) * (z * sin(y))
if (z <= (-3.3d+140)) then
tmp = t_0
else if (z <= 2.25d+182) 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 = -1.0 * (z * Math.sin(y));
double tmp;
if (z <= -3.3e+140) {
tmp = t_0;
} else if (z <= 2.25e+182) {
tmp = x + Math.cos(y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -1.0 * (z * math.sin(y)) tmp = 0 if z <= -3.3e+140: tmp = t_0 elif z <= 2.25e+182: tmp = x + math.cos(y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-1.0 * Float64(z * sin(y))) tmp = 0.0 if (z <= -3.3e+140) tmp = t_0; elseif (z <= 2.25e+182) tmp = Float64(x + cos(y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -1.0 * (z * sin(y)); tmp = 0.0; if (z <= -3.3e+140) tmp = t_0; elseif (z <= 2.25e+182) tmp = x + cos(y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-1.0 * N[(z * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.3e+140], t$95$0, If[LessEqual[z, 2.25e+182], N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := -1 \cdot \left(z \cdot \sin y\right)\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{+182}:\\
\;\;\;\;x + \cos y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -3.3000000000000002e140 or 2.25000000000000015e182 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6429.2%
Applied rewrites29.2%
if -3.3000000000000002e140 < z < 2.25000000000000015e182Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
sub-to-mult-revN/A
lift-/.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flipN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites92.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-cos.f6472.1%
Applied rewrites72.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (cos y))))
(if (<= y -0.000115)
t_0
(if (<= y 1.7e+29)
(+ 1.0 (+ x (* y (- (* y (- (* 0.16666666666666666 (* y z)) 0.5)) z))))
t_0))))double code(double x, double y, double z) {
double t_0 = x + cos(y);
double tmp;
if (y <= -0.000115) {
tmp = t_0;
} else if (y <= 1.7e+29) {
tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - 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 + cos(y)
if (y <= (-0.000115d0)) then
tmp = t_0
else if (y <= 1.7d+29) then
tmp = 1.0d0 + (x + (y * ((y * ((0.16666666666666666d0 * (y * z)) - 0.5d0)) - 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 + Math.cos(y);
double tmp;
if (y <= -0.000115) {
tmp = t_0;
} else if (y <= 1.7e+29) {
tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z)));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + math.cos(y) tmp = 0 if y <= -0.000115: tmp = t_0 elif y <= 1.7e+29: tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z))) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + cos(y)) tmp = 0.0 if (y <= -0.000115) tmp = t_0; elseif (y <= 1.7e+29) tmp = Float64(1.0 + Float64(x + Float64(y * Float64(Float64(y * Float64(Float64(0.16666666666666666 * Float64(y * z)) - 0.5)) - z)))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + cos(y); tmp = 0.0; if (y <= -0.000115) tmp = t_0; elseif (y <= 1.7e+29) tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.000115], t$95$0, If[LessEqual[y, 1.7e+29], N[(1.0 + N[(x + N[(y * N[(N[(y * N[(N[(0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x + \cos y\\
\mathbf{if}\;y \leq -0.000115:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+29}:\\
\;\;\;\;1 + \left(x + y \cdot \left(y \cdot \left(0.16666666666666666 \cdot \left(y \cdot z\right) - 0.5\right) - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.15e-4 or 1.69999999999999991e29 < y Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
lift--.f64N/A
sub-to-mult-revN/A
lift-/.f64N/A
sub-flipN/A
+-commutativeN/A
distribute-rgt1-inN/A
+-commutativeN/A
*-commutativeN/A
lift-/.f64N/A
distribute-neg-frac2N/A
mult-flipN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites92.0%
Taylor expanded in z around 0
lower-+.f64N/A
lower-cos.f6472.1%
Applied rewrites72.1%
if -1.15e-4 < y < 1.69999999999999991e29Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6454.3%
Applied rewrites54.3%
(FPCore (x y z)
:precision binary64
(if (<= y -5.4e+29)
(- x -1.0)
(if (<= y 1.7e+29)
(+ 1.0 (+ x (* y (- (* y (- (* 0.16666666666666666 (* y z)) 0.5)) z))))
(- x -1.0))))double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e+29) {
tmp = x - -1.0;
} else if (y <= 1.7e+29) {
tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z)));
} else {
tmp = x - -1.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) :: tmp
if (y <= (-5.4d+29)) then
tmp = x - (-1.0d0)
else if (y <= 1.7d+29) then
tmp = 1.0d0 + (x + (y * ((y * ((0.16666666666666666d0 * (y * z)) - 0.5d0)) - z)))
else
tmp = x - (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e+29) {
tmp = x - -1.0;
} else if (y <= 1.7e+29) {
tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z)));
} else {
tmp = x - -1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.4e+29: tmp = x - -1.0 elif y <= 1.7e+29: tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z))) else: tmp = x - -1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.4e+29) tmp = Float64(x - -1.0); elseif (y <= 1.7e+29) tmp = Float64(1.0 + Float64(x + Float64(y * Float64(Float64(y * Float64(Float64(0.16666666666666666 * Float64(y * z)) - 0.5)) - z)))); else tmp = Float64(x - -1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.4e+29) tmp = x - -1.0; elseif (y <= 1.7e+29) tmp = 1.0 + (x + (y * ((y * ((0.16666666666666666 * (y * z)) - 0.5)) - z))); else tmp = x - -1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.4e+29], N[(x - -1.0), $MachinePrecision], If[LessEqual[y, 1.7e+29], N[(1.0 + N[(x + N[(y * N[(N[(y * N[(N[(0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - -1.0), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+29}:\\
\;\;\;\;x - -1\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+29}:\\
\;\;\;\;1 + \left(x + y \cdot \left(y \cdot \left(0.16666666666666666 \cdot \left(y \cdot z\right) - 0.5\right) - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - -1\\
\end{array}
if y < -5.4e29 or 1.69999999999999991e29 < y Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites60.3%
if -5.4e29 < y < 1.69999999999999991e29Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6454.3%
Applied rewrites54.3%
(FPCore (x y z)
:precision binary64
(if (<= y -7e+34)
(- x -1.0)
(if (<= y 1.3e-26)
(- x (- (* y (+ z (* 0.5 y))) 1.0))
(* (- 1.0 (/ -1.0 x)) x))))double code(double x, double y, double z) {
double tmp;
if (y <= -7e+34) {
tmp = x - -1.0;
} else if (y <= 1.3e-26) {
tmp = x - ((y * (z + (0.5 * y))) - 1.0);
} else {
tmp = (1.0 - (-1.0 / x)) * 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 <= (-7d+34)) then
tmp = x - (-1.0d0)
else if (y <= 1.3d-26) then
tmp = x - ((y * (z + (0.5d0 * y))) - 1.0d0)
else
tmp = (1.0d0 - ((-1.0d0) / x)) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7e+34) {
tmp = x - -1.0;
} else if (y <= 1.3e-26) {
tmp = x - ((y * (z + (0.5 * y))) - 1.0);
} else {
tmp = (1.0 - (-1.0 / x)) * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e+34: tmp = x - -1.0 elif y <= 1.3e-26: tmp = x - ((y * (z + (0.5 * y))) - 1.0) else: tmp = (1.0 - (-1.0 / x)) * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e+34) tmp = Float64(x - -1.0); elseif (y <= 1.3e-26) tmp = Float64(x - Float64(Float64(y * Float64(z + Float64(0.5 * y))) - 1.0)); else tmp = Float64(Float64(1.0 - Float64(-1.0 / x)) * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7e+34) tmp = x - -1.0; elseif (y <= 1.3e-26) tmp = x - ((y * (z + (0.5 * y))) - 1.0); else tmp = (1.0 - (-1.0 / x)) * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e+34], N[(x - -1.0), $MachinePrecision], If[LessEqual[y, 1.3e-26], N[(x - N[(N[(y * N[(z + N[(0.5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+34}:\\
\;\;\;\;x - -1\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-26}:\\
\;\;\;\;x - \left(y \cdot \left(z + 0.5 \cdot y\right) - 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{-1}{x}\right) \cdot x\\
\end{array}
if y < -6.99999999999999996e34Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites60.3%
if -6.99999999999999996e34 < y < 1.30000000000000005e-26Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6455.2%
Applied rewrites55.2%
if 1.30000000000000005e-26 < y Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
add-flipN/A
associate--l-N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites91.7%
Taylor expanded in y around 0
Applied rewrites60.2%
(FPCore (x y z) :precision binary64 (if (<= y -8.5e+59) (- x -1.0) (- x (fma z y -1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.5e+59) {
tmp = x - -1.0;
} else {
tmp = x - fma(z, y, -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -8.5e+59) tmp = Float64(x - -1.0); else tmp = Float64(x - fma(z, y, -1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -8.5e+59], N[(x - -1.0), $MachinePrecision], N[(x - N[(z * y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+59}:\\
\;\;\;\;x - -1\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{fma}\left(z, y, -1\right)\\
\end{array}
if y < -8.4999999999999999e59Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites60.3%
if -8.4999999999999999e59 < y Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
add-flipN/A
associate--l-N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites91.7%
Taylor expanded in y around 0
lower--.f64N/A
lower-*.f6460.6%
Applied rewrites60.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
sub-to-mult-revN/A
lower--.f6462.8%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6462.8%
Applied rewrites62.8%
(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]
x - -1
Initial program 99.9%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
add-flipN/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6499.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites60.3%
(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
1
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6460.3%
Applied rewrites60.3%
Taylor expanded in x around 0
Applied rewrites21.1%
herbie shell --seed 2025188
(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))))