
(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]
\left(x + \sin y\right) + z \cdot \cos y
Herbie found 10 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]
\left(x + \sin y\right) + z \cdot \cos y
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ x (sin y)) z)) (t_1 (* z (cos y))))
(if (<=
x
-25000000000000001224418164378763014489305675088268597218626059364754206589834618904030788231181911594827826617037756919051335822966564630427556904960)
(+ (+ x y) t_1)
(if (<= x -1436010445571041/4951760157141521099596496896)
t_0
(if (<=
x
2785010123894805/1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224)
(+ (sin y) t_1)
t_0)))))double code(double x, double y, double z) {
double t_0 = (x + sin(y)) + z;
double t_1 = z * cos(y);
double tmp;
if (x <= -2.5e+148) {
tmp = (x + y) + t_1;
} else if (x <= -2.9e-13) {
tmp = t_0;
} else if (x <= 1.4e-72) {
tmp = sin(y) + t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (x + sin(y)) + z
t_1 = z * cos(y)
if (x <= (-2.5d+148)) then
tmp = (x + y) + t_1
else if (x <= (-2.9d-13)) then
tmp = t_0
else if (x <= 1.4d-72) then
tmp = sin(y) + t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + Math.sin(y)) + z;
double t_1 = z * Math.cos(y);
double tmp;
if (x <= -2.5e+148) {
tmp = (x + y) + t_1;
} else if (x <= -2.9e-13) {
tmp = t_0;
} else if (x <= 1.4e-72) {
tmp = Math.sin(y) + t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + math.sin(y)) + z t_1 = z * math.cos(y) tmp = 0 if x <= -2.5e+148: tmp = (x + y) + t_1 elif x <= -2.9e-13: tmp = t_0 elif x <= 1.4e-72: tmp = math.sin(y) + t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + sin(y)) + z) t_1 = Float64(z * cos(y)) tmp = 0.0 if (x <= -2.5e+148) tmp = Float64(Float64(x + y) + t_1); elseif (x <= -2.9e-13) tmp = t_0; elseif (x <= 1.4e-72) tmp = Float64(sin(y) + t_1); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + sin(y)) + z; t_1 = z * cos(y); tmp = 0.0; if (x <= -2.5e+148) tmp = (x + y) + t_1; elseif (x <= -2.9e-13) tmp = t_0; elseif (x <= 1.4e-72) tmp = sin(y) + t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -25000000000000001224418164378763014489305675088268597218626059364754206589834618904030788231181911594827826617037756919051335822966564630427556904960], N[(N[(x + y), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[x, -1436010445571041/4951760157141521099596496896], t$95$0, If[LessEqual[x, 2785010123894805/1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224], N[(N[Sin[y], $MachinePrecision] + t$95$1), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
t_0 := \left(x + \sin y\right) + z\\
t_1 := z \cdot \cos y\\
\mathbf{if}\;x \leq -25000000000000001224418164378763014489305675088268597218626059364754206589834618904030788231181911594827826617037756919051335822966564630427556904960:\\
\;\;\;\;\left(x + y\right) + t\_1\\
\mathbf{elif}\;x \leq \frac{-1436010445571041}{4951760157141521099596496896}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq \frac{2785010123894805}{1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224}:\\
\;\;\;\;\sin y + t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -2.5000000000000001e148Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6470.5%
Applied rewrites70.5%
if -2.5000000000000001e148 < x < -2.8999999999999998e-13 or 1.3999999999999999e-72 < x Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.2%
if -2.8999999999999998e-13 < x < 1.3999999999999999e-72Initial program 99.9%
Taylor expanded in x around 0
lower-sin.f6458.6%
Applied rewrites58.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -44999999999999999694942690346273258940776879887482880)
t_0
(if (<= z 195000000000000013240246614634307269691441152)
(+ (+ x (sin y)) z)
(+ (+ x y) t_0)))))double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -4.5e+52) {
tmp = t_0;
} else if (z <= 1.95e+44) {
tmp = (x + sin(y)) + z;
} else {
tmp = (x + y) + 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 = z * cos(y)
if (z <= (-4.5d+52)) then
tmp = t_0
else if (z <= 1.95d+44) then
tmp = (x + sin(y)) + z
else
tmp = (x + y) + t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * Math.cos(y);
double tmp;
if (z <= -4.5e+52) {
tmp = t_0;
} else if (z <= 1.95e+44) {
tmp = (x + Math.sin(y)) + z;
} else {
tmp = (x + y) + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -4.5e+52: tmp = t_0 elif z <= 1.95e+44: tmp = (x + math.sin(y)) + z else: tmp = (x + y) + t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -4.5e+52) tmp = t_0; elseif (z <= 1.95e+44) tmp = Float64(Float64(x + sin(y)) + z); else tmp = Float64(Float64(x + y) + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -4.5e+52) tmp = t_0; elseif (z <= 1.95e+44) tmp = (x + sin(y)) + z; else tmp = (x + y) + t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -44999999999999999694942690346273258940776879887482880], t$95$0, If[LessEqual[z, 195000000000000013240246614634307269691441152], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], N[(N[(x + y), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -44999999999999999694942690346273258940776879887482880:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 195000000000000013240246614634307269691441152:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) + t\_0\\
\end{array}
if z < -4.5e52Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f6487.9%
Applied rewrites87.9%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6483.9%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6483.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.8%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
Applied rewrites83.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
if -4.5e52 < z < 1.9500000000000001e44Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.2%
if 1.9500000000000001e44 < z Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6470.5%
Applied rewrites70.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -44999999999999999694942690346273258940776879887482880)
t_0
(if (<=
z
900000000000000042038738549023005289861289802492459741531608433724750463326305802962540899773738019948769863095006895570489159275084260631696359380724753273726825992370916201716464484352)
(+ (+ x (sin y)) z)
t_0))))double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -4.5e+52) {
tmp = t_0;
} else if (z <= 9e+185) {
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 = z * cos(y)
if (z <= (-4.5d+52)) then
tmp = t_0
else if (z <= 9d+185) 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 = z * Math.cos(y);
double tmp;
if (z <= -4.5e+52) {
tmp = t_0;
} else if (z <= 9e+185) {
tmp = (x + Math.sin(y)) + z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * math.cos(y) tmp = 0 if z <= -4.5e+52: tmp = t_0 elif z <= 9e+185: tmp = (x + math.sin(y)) + z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * cos(y)) tmp = 0.0 if (z <= -4.5e+52) tmp = t_0; elseif (z <= 9e+185) tmp = Float64(Float64(x + sin(y)) + z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * cos(y); tmp = 0.0; if (z <= -4.5e+52) tmp = t_0; elseif (z <= 9e+185) tmp = (x + sin(y)) + z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -44999999999999999694942690346273258940776879887482880], t$95$0, If[LessEqual[z, 900000000000000042038738549023005289861289802492459741531608433724750463326305802962540899773738019948769863095006895570489159275084260631696359380724753273726825992370916201716464484352], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := z \cdot \cos y\\
\mathbf{if}\;z \leq -44999999999999999694942690346273258940776879887482880:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 900000000000000042038738549023005289861289802492459741531608433724750463326305802962540899773738019948769863095006895570489159275084260631696359380724753273726825992370916201716464484352:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -4.5e52 or 9.0000000000000004e185 < z Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f6487.9%
Applied rewrites87.9%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6483.9%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6483.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.8%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
Applied rewrites83.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
if -4.5e52 < z < 9.0000000000000004e185Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.2%
(FPCore (x y z)
:precision binary64
(if (<= x -1436010445571041/4951760157141521099596496896)
(+ x z)
(if (<=
x
2785010123894805/1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224)
(* z (cos y))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (x <= -2.9e-13) {
tmp = x + z;
} else if (x <= 1.4e-72) {
tmp = z * cos(y);
} else {
tmp = x + 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 (x <= (-2.9d-13)) then
tmp = x + z
else if (x <= 1.4d-72) then
tmp = z * cos(y)
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.9e-13) {
tmp = x + z;
} else if (x <= 1.4e-72) {
tmp = z * Math.cos(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.9e-13: tmp = x + z elif x <= 1.4e-72: tmp = z * math.cos(y) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.9e-13) tmp = Float64(x + z); elseif (x <= 1.4e-72) tmp = Float64(z * cos(y)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.9e-13) tmp = x + z; elseif (x <= 1.4e-72) tmp = z * cos(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1436010445571041/4951760157141521099596496896], N[(x + z), $MachinePrecision], If[LessEqual[x, 2785010123894805/1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{-1436010445571041}{4951760157141521099596496896}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq \frac{2785010123894805}{1989292945639146568621528992587283360401824603189390869761855907572637988050133502132224}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if x < -2.8999999999999998e-13 or 1.3999999999999999e-72 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
if -2.8999999999999998e-13 < x < 1.3999999999999999e-72Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f6487.9%
Applied rewrites87.9%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6483.9%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6483.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.8%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
Applied rewrites83.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6442.4%
Applied rewrites42.4%
(FPCore (x y z)
:precision binary64
(if (<= y -122)
(* (+ z x) (* (- z x) (/ -1 (- x z))))
(if (<= y 65000000000)
(+ x (+ z (* y (+ 1 (* y (+ (* -1/2 z) (* -1/6 y)))))))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = (z + x) * ((z - x) * (-1.0 / (x - z)));
} else if (y <= 65000000000.0) {
tmp = x + (z + (y * (1.0 + (y * ((-0.5 * z) + (-0.16666666666666666 * y))))));
} else {
tmp = x + 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 (y <= (-122.0d0)) then
tmp = (z + x) * ((z - x) * ((-1.0d0) / (x - z)))
else if (y <= 65000000000.0d0) then
tmp = x + (z + (y * (1.0d0 + (y * (((-0.5d0) * z) + ((-0.16666666666666666d0) * y))))))
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = (z + x) * ((z - x) * (-1.0 / (x - z)));
} else if (y <= 65000000000.0) {
tmp = x + (z + (y * (1.0 + (y * ((-0.5 * z) + (-0.16666666666666666 * y))))));
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -122.0: tmp = (z + x) * ((z - x) * (-1.0 / (x - z))) elif y <= 65000000000.0: tmp = x + (z + (y * (1.0 + (y * ((-0.5 * z) + (-0.16666666666666666 * y)))))) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -122.0) tmp = Float64(Float64(z + x) * Float64(Float64(z - x) * Float64(-1.0 / Float64(x - z)))); elseif (y <= 65000000000.0) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * Float64(Float64(-0.5 * z) + Float64(-0.16666666666666666 * y))))))); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -122.0) tmp = (z + x) * ((z - x) * (-1.0 / (x - z))); elseif (y <= 65000000000.0) tmp = x + (z + (y * (1.0 + (y * ((-0.5 * z) + (-0.16666666666666666 * y)))))); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -122], N[(N[(z + x), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] * N[(-1 / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 65000000000], N[(x + N[(z + N[(y * N[(1 + N[(y * N[(N[(-1/2 * z), $MachinePrecision] + N[(-1/6 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -122:\\
\;\;\;\;\left(z + x\right) \cdot \left(\left(z - x\right) \cdot \frac{-1}{x - z}\right)\\
\mathbf{elif}\;y \leq 65000000000:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \left(\frac{-1}{2} \cdot z + \frac{-1}{6} \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -122Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
lower-unsound--.f64N/A
lower-*.f64N/A
lower-unsound-*.f64N/A
lower-unsound--.f6433.0%
Applied rewrites33.0%
lift-/.f64N/A
mult-flipN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift--.f64N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
frac-2neg-revN/A
sub-negate-revN/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6465.8%
Applied rewrites65.8%
if -122 < y < 6.5e10Initial program 99.9%
Taylor expanded in z around inf
lower-*.f64N/A
lower-+.f64N/A
lower-cos.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-sin.f6487.9%
Applied rewrites87.9%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f6483.9%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
lift-+.f64N/A
lower-/.f6483.8%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6483.8%
lift-+.f64N/A
lift-/.f64N/A
lift-/.f64N/A
div-add-revN/A
Applied rewrites83.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.0%
Applied rewrites54.0%
if 6.5e10 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
(FPCore (x y z)
:precision binary64
(if (<= y -122)
(* (+ z x) (* (- z x) (/ -1 (- x z))))
(if (<= y 4457913959828945/151115727451828646838272)
(+ x (+ z (* y (+ 1 (* -1/2 (* y z))))))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = (z + x) * ((z - x) * (-1.0 / (x - z)));
} else if (y <= 2.95e-8) {
tmp = x + (z + (y * (1.0 + (-0.5 * (y * z)))));
} else {
tmp = x + 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 (y <= (-122.0d0)) then
tmp = (z + x) * ((z - x) * ((-1.0d0) / (x - z)))
else if (y <= 2.95d-8) then
tmp = x + (z + (y * (1.0d0 + ((-0.5d0) * (y * z)))))
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = (z + x) * ((z - x) * (-1.0 / (x - z)));
} else if (y <= 2.95e-8) {
tmp = x + (z + (y * (1.0 + (-0.5 * (y * z)))));
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -122.0: tmp = (z + x) * ((z - x) * (-1.0 / (x - z))) elif y <= 2.95e-8: tmp = x + (z + (y * (1.0 + (-0.5 * (y * z))))) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -122.0) tmp = Float64(Float64(z + x) * Float64(Float64(z - x) * Float64(-1.0 / Float64(x - z)))); elseif (y <= 2.95e-8) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(-0.5 * Float64(y * z)))))); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -122.0) tmp = (z + x) * ((z - x) * (-1.0 / (x - z))); elseif (y <= 2.95e-8) tmp = x + (z + (y * (1.0 + (-0.5 * (y * z))))); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -122], N[(N[(z + x), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] * N[(-1 / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4457913959828945/151115727451828646838272], N[(x + N[(z + N[(y * N[(1 + N[(-1/2 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -122:\\
\;\;\;\;\left(z + x\right) \cdot \left(\left(z - x\right) \cdot \frac{-1}{x - z}\right)\\
\mathbf{elif}\;y \leq \frac{4457913959828945}{151115727451828646838272}:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + \frac{-1}{2} \cdot \left(y \cdot z\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -122Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
lift-+.f64N/A
+-commutativeN/A
flip-+N/A
lower-unsound-/.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
lower-unsound--.f64N/A
lower-*.f64N/A
lower-unsound-*.f64N/A
lower-unsound--.f6433.0%
Applied rewrites33.0%
lift-/.f64N/A
mult-flipN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
+-commutativeN/A
lift--.f64N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
frac-2neg-revN/A
sub-negate-revN/A
lift--.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6465.8%
Applied rewrites65.8%
if -122 < y < 2.9499999999999999e-8Initial 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-*.f6456.9%
Applied rewrites56.9%
if 2.9499999999999999e-8 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
(FPCore (x y z)
:precision binary64
(if (<= y -122)
(+ x z)
(if (<= y 4457913959828945/151115727451828646838272)
(+ x (+ z (* y (+ 1 (* -1/2 (* y z))))))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = x + z;
} else if (y <= 2.95e-8) {
tmp = x + (z + (y * (1.0 + (-0.5 * (y * z)))));
} else {
tmp = x + 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 (y <= (-122.0d0)) then
tmp = x + z
else if (y <= 2.95d-8) then
tmp = x + (z + (y * (1.0d0 + ((-0.5d0) * (y * z)))))
else
tmp = x + z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -122.0) {
tmp = x + z;
} else if (y <= 2.95e-8) {
tmp = x + (z + (y * (1.0 + (-0.5 * (y * z)))));
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -122.0: tmp = x + z elif y <= 2.95e-8: tmp = x + (z + (y * (1.0 + (-0.5 * (y * z))))) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -122.0) tmp = Float64(x + z); elseif (y <= 2.95e-8) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(-0.5 * Float64(y * z)))))); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -122.0) tmp = x + z; elseif (y <= 2.95e-8) tmp = x + (z + (y * (1.0 + (-0.5 * (y * z))))); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -122], N[(x + z), $MachinePrecision], If[LessEqual[y, 4457913959828945/151115727451828646838272], N[(x + N[(z + N[(y * N[(1 + N[(-1/2 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -122:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq \frac{4457913959828945}{151115727451828646838272}:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + \frac{-1}{2} \cdot \left(y \cdot z\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -122 or 2.9499999999999999e-8 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
if -122 < y < 2.9499999999999999e-8Initial 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-*.f6456.9%
Applied rewrites56.9%
(FPCore (x y z) :precision binary64 (+ x z))
double code(double x, double y, double z) {
return x + 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 = x + z
end function
public static double code(double x, double y, double z) {
return x + z;
}
def code(x, y, z): return x + z
function code(x, y, z) return Float64(x + z) end
function tmp = code(x, y, z) tmp = x + z; end
code[x_, y_, z_] := N[(x + z), $MachinePrecision]
x + z
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
(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
z
Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6465.9%
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites25.8%
herbie shell --seed 2025271 -o generate:evaluate
(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))))