
(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 12 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 (fma (cos y) z (+ (sin y) x)))
double code(double x, double y, double z) {
return fma(cos(y), z, (sin(y) + x));
}
function code(x, y, z) return fma(cos(y), z, Float64(sin(y) + x)) end
code[x_, y_, z_] := N[(N[Cos[y], $MachinePrecision] * z + N[(N[Sin[y], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\cos y, z, \sin y + x\right)
Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (cos y))))
(if (<= z -2.95e+178)
(fma (cos y) z (+ x y))
(if (<= z -9.8e+62)
t_0
(if (<= z 2.6e+78) (+ (+ 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 <= -2.95e+178) {
tmp = fma(cos(y), z, (x + y));
} else if (z <= -9.8e+62) {
tmp = t_0;
} else if (z <= 2.6e+78) {
tmp = (x + 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 <= -2.95e+178) tmp = fma(cos(y), z, Float64(x + y)); elseif (z <= -9.8e+62) tmp = t_0; elseif (z <= 2.6e+78) tmp = Float64(Float64(x + sin(y)) + z); else tmp = Float64(Float64(x + y) + t_0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.95e+178], N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -9.8e+62], t$95$0, If[LessEqual[z, 2.6e+78], 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 -2.95 \cdot 10^{+178}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{elif}\;z \leq -9.8 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+78}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) + t\_0\\
\end{array}
if z < -2.94999999999999992e178Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.4%
Applied rewrites70.4%
if -2.94999999999999992e178 < z < -9.7999999999999994e62Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-fma.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
add-to-fractionN/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
Applied rewrites96.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6443.0%
Applied rewrites43.0%
if -9.7999999999999994e62 < z < 2.6e78Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.1%
if 2.6e78 < z Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites70.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma (cos y) z (+ x y))))
(if (<= z -2.95e+178)
t_0
(if (<= z -9.8e+62)
(* z (cos y))
(if (<= z 2.6e+78) (+ (+ x (sin y)) z) t_0)))))double code(double x, double y, double z) {
double t_0 = fma(cos(y), z, (x + y));
double tmp;
if (z <= -2.95e+178) {
tmp = t_0;
} else if (z <= -9.8e+62) {
tmp = z * cos(y);
} else if (z <= 2.6e+78) {
tmp = (x + sin(y)) + z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = fma(cos(y), z, Float64(x + y)) tmp = 0.0 if (z <= -2.95e+178) tmp = t_0; elseif (z <= -9.8e+62) tmp = Float64(z * cos(y)); elseif (z <= 2.6e+78) tmp = Float64(Float64(x + sin(y)) + z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cos[y], $MachinePrecision] * z + N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.95e+178], t$95$0, If[LessEqual[z, -9.8e+62], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e+78], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos y, z, x + y\right)\\
\mathbf{if}\;z \leq -2.95 \cdot 10^{+178}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -9.8 \cdot 10^{+62}:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+78}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -2.94999999999999992e178 or 2.6e78 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in y around 0
lower-+.f6470.4%
Applied rewrites70.4%
if -2.94999999999999992e178 < z < -9.7999999999999994e62Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-fma.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
add-to-fractionN/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
Applied rewrites96.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6443.0%
Applied rewrites43.0%
if -9.7999999999999994e62 < z < 2.6e78Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.9e-135) (+ (+ x (sin y)) z) (if (<= x 4.1e-23) (fma (cos y) z (sin y)) (+ (+ x y) (* z (cos y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e-135) {
tmp = (x + sin(y)) + z;
} else if (x <= 4.1e-23) {
tmp = fma(cos(y), z, sin(y));
} else {
tmp = (x + y) + (z * cos(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.9e-135) tmp = Float64(Float64(x + sin(y)) + z); elseif (x <= 4.1e-23) tmp = fma(cos(y), z, sin(y)); else tmp = Float64(Float64(x + y) + Float64(z * cos(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.9e-135], N[(N[(x + N[Sin[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision], If[LessEqual[x, 4.1e-23], N[(N[Cos[y], $MachinePrecision] * z + N[Sin[y], $MachinePrecision]), $MachinePrecision], N[(N[(x + y), $MachinePrecision] + N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-135}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(\cos y, z, \sin y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + y\right) + z \cdot \cos y\\
\end{array}
if x < -1.9000000000000001e-135Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.1%
if -1.9000000000000001e-135 < x < 4.10000000000000029e-23Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
Taylor expanded in x around 0
lower-sin.f6458.5%
Applied rewrites58.5%
if 4.10000000000000029e-23 < x Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites70.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (cos y)))) (if (<= z -9.8e+62) t_0 (if (<= z 9e+80) (+ (+ x (sin y)) z) t_0))))
double code(double x, double y, double z) {
double t_0 = z * cos(y);
double tmp;
if (z <= -9.8e+62) {
tmp = t_0;
} else if (z <= 9e+80) {
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 <= (-9.8d+62)) then
tmp = t_0
else if (z <= 9d+80) 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 <= -9.8e+62) {
tmp = t_0;
} else if (z <= 9e+80) {
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 <= -9.8e+62: tmp = t_0 elif z <= 9e+80: 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 <= -9.8e+62) tmp = t_0; elseif (z <= 9e+80) 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 <= -9.8e+62) tmp = t_0; elseif (z <= 9e+80) 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, -9.8e+62], t$95$0, If[LessEqual[z, 9e+80], 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 -9.8 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+80}:\\
\;\;\;\;\left(x + \sin y\right) + z\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if z < -9.7999999999999994e62 or 9.00000000000000013e80 < z Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-fma.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
add-to-fractionN/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
Applied rewrites96.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6443.0%
Applied rewrites43.0%
if -9.7999999999999994e62 < z < 9.00000000000000013e80Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites82.1%
(FPCore (x y z) :precision binary64 (if (<= x -1.3e-108) (+ x z) (if (<= x 90.0) (* z (cos y)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e-108) {
tmp = x + z;
} else if (x <= 90.0) {
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 <= (-1.3d-108)) then
tmp = x + z
else if (x <= 90.0d0) 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 <= -1.3e-108) {
tmp = x + z;
} else if (x <= 90.0) {
tmp = z * Math.cos(y);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e-108: tmp = x + z elif x <= 90.0: tmp = z * math.cos(y) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e-108) tmp = Float64(x + z); elseif (x <= 90.0) 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 <= -1.3e-108) tmp = x + z; elseif (x <= 90.0) tmp = z * cos(y); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e-108], N[(x + z), $MachinePrecision], If[LessEqual[x, 90.0], N[(z * N[Cos[y], $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-108}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq 90:\\
\;\;\;\;z \cdot \cos y\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if x < -1.29999999999999992e-108 or 90 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6466.6%
Applied rewrites66.6%
if -1.29999999999999992e-108 < x < 90Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-fma.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
add-to-fractionN/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
Applied rewrites96.4%
Taylor expanded in z around inf
lower-*.f64N/A
lower-cos.f6443.0%
Applied rewrites43.0%
(FPCore (x y z)
:precision binary64
(if (<= y -4.0)
(+ x z)
(if (<= y 0.048)
(+ x (+ z (* y (+ 1.0 (* y (fma -0.5 z (* -0.16666666666666666 y)))))))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -4.0) {
tmp = x + z;
} else if (y <= 0.048) {
tmp = x + (z + (y * (1.0 + (y * fma(-0.5, z, (-0.16666666666666666 * y))))));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4.0) tmp = Float64(x + z); elseif (y <= 0.048) tmp = Float64(x + Float64(z + Float64(y * Float64(1.0 + Float64(y * fma(-0.5, z, Float64(-0.16666666666666666 * y))))))); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 0.048], N[(x + N[(z + N[(y * N[(1.0 + N[(y * N[(-0.5 * z + N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -4:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 0.048:\\
\;\;\;\;x + \left(z + y \cdot \left(1 + y \cdot \mathsf{fma}\left(-0.5, z, -0.16666666666666666 \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -4 or 0.048000000000000001 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6466.6%
Applied rewrites66.6%
if -4 < y < 0.048000000000000001Initial 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-fma.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
(FPCore (x y z)
:precision binary64
(if (<= y -4.0)
(+ x z)
(if (<= y 0.048)
(+ x (+ z (fma (fma -0.5 z (* -0.16666666666666666 y)) (* y y) y)))
(+ x z))))double code(double x, double y, double z) {
double tmp;
if (y <= -4.0) {
tmp = x + z;
} else if (y <= 0.048) {
tmp = x + (z + fma(fma(-0.5, z, (-0.16666666666666666 * y)), (y * y), y));
} else {
tmp = x + z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -4.0) tmp = Float64(x + z); elseif (y <= 0.048) tmp = Float64(x + Float64(z + fma(fma(-0.5, z, Float64(-0.16666666666666666 * y)), Float64(y * y), y))); else tmp = Float64(x + z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -4.0], N[(x + z), $MachinePrecision], If[LessEqual[y, 0.048], N[(x + N[(z + N[(N[(-0.5 * z + N[(-0.16666666666666666 * y), $MachinePrecision]), $MachinePrecision] * N[(y * y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -4:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 0.048:\\
\;\;\;\;x + \left(z + \mathsf{fma}\left(\mathsf{fma}\left(-0.5, z, -0.16666666666666666 \cdot y\right), y \cdot y, y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -4 or 0.048000000000000001 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6466.6%
Applied rewrites66.6%
if -4 < y < 0.048000000000000001Initial 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-fma.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-lft-identityN/A
lower-fma.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+82) (+ x z) (if (<= y 20000.0) (+ x (+ y z)) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+82) {
tmp = x + z;
} else if (y <= 20000.0) {
tmp = x + (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 <= (-8.2d+82)) then
tmp = x + z
else if (y <= 20000.0d0) then
tmp = x + (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 <= -8.2e+82) {
tmp = x + z;
} else if (y <= 20000.0) {
tmp = x + (y + z);
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+82: tmp = x + z elif y <= 20000.0: tmp = x + (y + z) else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+82) tmp = Float64(x + z); elseif (y <= 20000.0) tmp = Float64(x + Float64(y + z)); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+82) tmp = x + z; elseif (y <= 20000.0) tmp = x + (y + z); else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+82], N[(x + z), $MachinePrecision], If[LessEqual[y, 20000.0], N[(x + N[(y + z), $MachinePrecision]), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+82}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;y \leq 20000:\\
\;\;\;\;x + \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if y < -8.1999999999999999e82 or 2e4 < y Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6466.6%
Applied rewrites66.6%
if -8.1999999999999999e82 < y < 2e4Initial program 99.9%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f6461.3%
Applied rewrites61.3%
(FPCore (x y z) :precision binary64 (if (<= x -6.8e-90) (+ x z) (if (<= x 2.5e-145) (+ y z) (+ x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e-90) {
tmp = x + z;
} else if (x <= 2.5e-145) {
tmp = 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 (x <= (-6.8d-90)) then
tmp = x + z
else if (x <= 2.5d-145) then
tmp = 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 (x <= -6.8e-90) {
tmp = x + z;
} else if (x <= 2.5e-145) {
tmp = y + z;
} else {
tmp = x + z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.8e-90: tmp = x + z elif x <= 2.5e-145: tmp = y + z else: tmp = x + z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.8e-90) tmp = Float64(x + z); elseif (x <= 2.5e-145) tmp = Float64(y + z); else tmp = Float64(x + z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.8e-90) tmp = x + z; elseif (x <= 2.5e-145) tmp = y + z; else tmp = x + z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.8e-90], N[(x + z), $MachinePrecision], If[LessEqual[x, 2.5e-145], N[(y + z), $MachinePrecision], N[(x + z), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{-90}:\\
\;\;\;\;x + z\\
\mathbf{elif}\;x \leq 2.5 \cdot 10^{-145}:\\
\;\;\;\;y + z\\
\mathbf{else}:\\
\;\;\;\;x + z\\
\end{array}
if x < -6.79999999999999988e-90 or 2.4999999999999999e-145 < x Initial program 99.9%
Taylor expanded in y around 0
lower-+.f6466.6%
Applied rewrites66.6%
if -6.79999999999999988e-90 < x < 2.4999999999999999e-145Initial program 99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6499.9%
Applied rewrites99.9%
lift-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
lift-fma.f64N/A
+-commutativeN/A
sum-to-mult-revN/A
add-to-fractionN/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
lower-*.f64N/A
Applied rewrites96.4%
Taylor expanded in y around 0
lower-+.f64N/A
lower-+.f6461.3%
Applied rewrites61.3%
Taylor expanded in x around 0
lower-+.f6429.5%
Applied rewrites29.5%
(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-+.f6466.6%
Applied rewrites66.6%
(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-+.f6466.6%
Applied rewrites66.6%
Taylor expanded in x around 0
Applied rewrites26.3%
herbie shell --seed 2025183
(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))))