
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= z -200000000.0)
(+ t_1 (/ t (* (* z 3.0) y)))
(if (<= z 5e-95)
(/ (fma z x (* (- (/ t y) y) 0.3333333333333333)) z)
(+ t_1 (/ t (* (* z y) 3.0)))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (z <= -200000000.0) {
tmp = t_1 + (t / ((z * 3.0) * y));
} else if (z <= 5e-95) {
tmp = fma(z, x, (((t / y) - y) * 0.3333333333333333)) / z;
} else {
tmp = t_1 + (t / ((z * y) * 3.0));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (z <= -200000000.0) tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y))); elseif (z <= 5e-95) tmp = Float64(fma(z, x, Float64(Float64(Float64(t / y) - y) * 0.3333333333333333)) / z); else tmp = Float64(t_1 + Float64(t / Float64(Float64(z * y) * 3.0))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -200000000.0], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5e-95], N[(N[(z * x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(z * y), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \leq -200000000:\\
\;\;\;\;t\_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{-95}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, \left(\frac{t}{y} - y\right) \cdot 0.3333333333333333\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{t}{\left(z \cdot y\right) \cdot 3}\\
\end{array}
\end{array}
if z < -2e8Initial program 99.8%
if -2e8 < z < 4.9999999999999998e-95Initial program 91.9%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
if 4.9999999999999998e-95 < z Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -200000000.0) (not (<= z 2.2e-89))) (+ (- x (/ y (* z 3.0))) (/ t (* (* 3.0 y) z))) (/ (fma z x (* (- (/ t y) y) 0.3333333333333333)) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -200000000.0) || !(z <= 2.2e-89)) {
tmp = (x - (y / (z * 3.0))) + (t / ((3.0 * y) * z));
} else {
tmp = fma(z, x, (((t / y) - y) * 0.3333333333333333)) / z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -200000000.0) || !(z <= 2.2e-89)) tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(3.0 * y) * z))); else tmp = Float64(fma(z, x, Float64(Float64(Float64(t / y) - y) * 0.3333333333333333)) / z); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -200000000.0], N[Not[LessEqual[z, 2.2e-89]], $MachinePrecision]], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(3.0 * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -200000000 \lor \neg \left(z \leq 2.2 \cdot 10^{-89}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(3 \cdot y\right) \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, \left(\frac{t}{y} - y\right) \cdot 0.3333333333333333\right)}{z}\\
\end{array}
\end{array}
if z < -2e8 or 2.20000000000000012e-89 < z Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
if -2e8 < z < 2.20000000000000012e-89Initial program 91.9%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification99.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= z -200000000.0)
(+ t_1 (/ t (* (* z 3.0) y)))
(if (<= z 2.2e-89)
(/ (fma z x (* (- (/ t y) y) 0.3333333333333333)) z)
(+ t_1 (/ t (* (* 3.0 y) z)))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (z <= -200000000.0) {
tmp = t_1 + (t / ((z * 3.0) * y));
} else if (z <= 2.2e-89) {
tmp = fma(z, x, (((t / y) - y) * 0.3333333333333333)) / z;
} else {
tmp = t_1 + (t / ((3.0 * y) * z));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (z <= -200000000.0) tmp = Float64(t_1 + Float64(t / Float64(Float64(z * 3.0) * y))); elseif (z <= 2.2e-89) tmp = Float64(fma(z, x, Float64(Float64(Float64(t / y) - y) * 0.3333333333333333)) / z); else tmp = Float64(t_1 + Float64(t / Float64(Float64(3.0 * y) * z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -200000000.0], N[(t$95$1 + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.2e-89], N[(N[(z * x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(3.0 * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \leq -200000000:\\
\;\;\;\;t\_1 + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-89}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, \left(\frac{t}{y} - y\right) \cdot 0.3333333333333333\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{t}{\left(3 \cdot y\right) \cdot z}\\
\end{array}
\end{array}
if z < -2e8Initial program 99.8%
if -2e8 < z < 2.20000000000000012e-89Initial program 91.9%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
if 2.20000000000000012e-89 < z Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (x y z t) :precision binary64 (if (<= z 3.5e-36) (+ (- x (/ y (* z 3.0))) (/ (/ t y) (* 3.0 z))) (+ (- x (/ (/ y 3.0) z)) (/ t (* (* z 3.0) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.5e-36) {
tmp = (x - (y / (z * 3.0))) + ((t / y) / (3.0 * z));
} else {
tmp = (x - ((y / 3.0) / z)) + (t / ((z * 3.0) * y));
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 3.5d-36) then
tmp = (x - (y / (z * 3.0d0))) + ((t / y) / (3.0d0 * z))
else
tmp = (x - ((y / 3.0d0) / z)) + (t / ((z * 3.0d0) * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.5e-36) {
tmp = (x - (y / (z * 3.0))) + ((t / y) / (3.0 * z));
} else {
tmp = (x - ((y / 3.0) / z)) + (t / ((z * 3.0) * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.5e-36: tmp = (x - (y / (z * 3.0))) + ((t / y) / (3.0 * z)) else: tmp = (x - ((y / 3.0) / z)) + (t / ((z * 3.0) * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.5e-36) tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / y) / Float64(3.0 * z))); else tmp = Float64(Float64(x - Float64(Float64(y / 3.0) / z)) + Float64(t / Float64(Float64(z * 3.0) * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.5e-36) tmp = (x - (y / (z * 3.0))) + ((t / y) / (3.0 * z)); else tmp = (x - ((y / 3.0) / z)) + (t / ((z * 3.0) * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.5e-36], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / y), $MachinePrecision] / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(N[(y / 3.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.5 \cdot 10^{-36}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{y}}{3 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\left(x - \frac{\frac{y}{3}}{z}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\
\end{array}
\end{array}
if z < 3.5e-36Initial program 94.7%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.7
Applied rewrites97.7%
if 3.5e-36 < z Initial program 99.6%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= z 1e-93)
(+ t_1 (/ (/ t y) (* 3.0 z)))
(+ t_1 (/ t (* (* z y) 3.0))))))
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (z <= 1e-93) {
tmp = t_1 + ((t / y) / (3.0 * z));
} else {
tmp = t_1 + (t / ((z * y) * 3.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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if (z <= 1d-93) then
tmp = t_1 + ((t / y) / (3.0d0 * z))
else
tmp = t_1 + (t / ((z * y) * 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (z <= 1e-93) {
tmp = t_1 + ((t / y) / (3.0 * z));
} else {
tmp = t_1 + (t / ((z * y) * 3.0));
}
return tmp;
}
def code(x, y, z, t): t_1 = x - (y / (z * 3.0)) tmp = 0 if z <= 1e-93: tmp = t_1 + ((t / y) / (3.0 * z)) else: tmp = t_1 + (t / ((z * y) * 3.0)) return tmp
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (z <= 1e-93) tmp = Float64(t_1 + Float64(Float64(t / y) / Float64(3.0 * z))); else tmp = Float64(t_1 + Float64(t / Float64(Float64(z * y) * 3.0))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / (z * 3.0)); tmp = 0.0; if (z <= 1e-93) tmp = t_1 + ((t / y) / (3.0 * z)); else tmp = t_1 + (t / ((z * y) * 3.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1e-93], N[(t$95$1 + N[(N[(t / y), $MachinePrecision] / N[(3.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t / N[(N[(z * y), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;z \leq 10^{-93}:\\
\;\;\;\;t\_1 + \frac{\frac{t}{y}}{3 \cdot z}\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \frac{t}{\left(z \cdot y\right) \cdot 3}\\
\end{array}
\end{array}
if z < 9.999999999999999e-94Initial program 94.5%
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6497.6
Applied rewrites97.6%
if 9.999999999999999e-94 < z Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.65e+32) (not (<= y 22500000000000.0))) (fma -0.3333333333333333 (/ y z) x) (/ (fma (/ t z) 0.3333333333333333 (* y x)) y)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.65e+32) || !(y <= 22500000000000.0)) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else {
tmp = fma((t / z), 0.3333333333333333, (y * x)) / y;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.65e+32) || !(y <= 22500000000000.0)) tmp = fma(-0.3333333333333333, Float64(y / z), x); else tmp = Float64(fma(Float64(t / z), 0.3333333333333333, Float64(y * x)) / y); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.65e+32], N[Not[LessEqual[y, 22500000000000.0]], $MachinePrecision]], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(t / z), $MachinePrecision] * 0.3333333333333333 + N[(y * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+32} \lor \neg \left(y \leq 22500000000000\right):\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{t}{z}, 0.3333333333333333, y \cdot x\right)}{y}\\
\end{array}
\end{array}
if y < -1.6500000000000001e32 or 2.25e13 < y Initial program 99.8%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
if -1.6500000000000001e32 < y < 2.25e13Initial program 93.8%
Taylor expanded in y around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.0
Applied rewrites90.0%
Final simplification92.4%
(FPCore (x y z t) :precision binary64 (if (<= x -1.45e+124) (+ x (/ t (* z (* 3.0 y)))) (/ (fma z x (* (- (/ t y) y) 0.3333333333333333)) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.45e+124) {
tmp = x + (t / (z * (3.0 * y)));
} else {
tmp = fma(z, x, (((t / y) - y) * 0.3333333333333333)) / z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -1.45e+124) tmp = Float64(x + Float64(t / Float64(z * Float64(3.0 * y)))); else tmp = Float64(fma(z, x, Float64(Float64(Float64(t / y) - y) * 0.3333333333333333)) / z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.45e+124], N[(x + N[(t / N[(z * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * x + N[(N[(N[(t / y), $MachinePrecision] - y), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+124}:\\
\;\;\;\;x + \frac{t}{z \cdot \left(3 \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, x, \left(\frac{t}{y} - y\right) \cdot 0.3333333333333333\right)}{z}\\
\end{array}
\end{array}
if x < -1.45000000000000011e124Initial program 97.2%
Taylor expanded in x around inf
Applied rewrites88.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6488.2
Applied rewrites88.2%
if -1.45000000000000011e124 < x Initial program 96.1%
Taylor expanded in z around 0
lower-/.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6492.9
Applied rewrites92.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -5.4e+32) (not (<= y 5.1e+14))) (fma -0.3333333333333333 (/ y z) x) (+ x (/ t (* z (* 3.0 y))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.4e+32) || !(y <= 5.1e+14)) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else {
tmp = x + (t / (z * (3.0 * y)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.4e+32) || !(y <= 5.1e+14)) tmp = fma(-0.3333333333333333, Float64(y / z), x); else tmp = Float64(x + Float64(t / Float64(z * Float64(3.0 * y)))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.4e+32], N[Not[LessEqual[y, 5.1e+14]], $MachinePrecision]], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t / N[(z * N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+32} \lor \neg \left(y \leq 5.1 \cdot 10^{+14}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t}{z \cdot \left(3 \cdot y\right)}\\
\end{array}
\end{array}
if y < -5.40000000000000025e32 or 5.1e14 < y Initial program 99.8%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
if -5.40000000000000025e32 < y < 5.1e14Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites87.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6487.4
Applied rewrites87.4%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.2e+29) (not (<= y 7.6e-93))) (fma -0.3333333333333333 (/ y z) x) (/ (* 0.3333333333333333 t) (* z y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+29) || !(y <= 7.6e-93)) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else {
tmp = (0.3333333333333333 * t) / (z * y);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.2e+29) || !(y <= 7.6e-93)) tmp = fma(-0.3333333333333333, Float64(y / z), x); else tmp = Float64(Float64(0.3333333333333333 * t) / Float64(z * y)); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.2e+29], N[Not[LessEqual[y, 7.6e-93]], $MachinePrecision]], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], N[(N[(0.3333333333333333 * t), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+29} \lor \neg \left(y \leq 7.6 \cdot 10^{-93}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot t}{z \cdot y}\\
\end{array}
\end{array}
if y < -6.1999999999999998e29 or 7.5999999999999998e-93 < y Initial program 99.7%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if -6.1999999999999998e29 < y < 7.5999999999999998e-93Initial program 92.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6470.3
Applied rewrites70.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6470.4
Applied rewrites70.4%
Final simplification80.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -6.2e+29) (not (<= y 7.6e-93))) (fma -0.3333333333333333 (/ y z) x) (* (/ t (* z y)) 0.3333333333333333)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -6.2e+29) || !(y <= 7.6e-93)) {
tmp = fma(-0.3333333333333333, (y / z), x);
} else {
tmp = (t / (z * y)) * 0.3333333333333333;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((y <= -6.2e+29) || !(y <= 7.6e-93)) tmp = fma(-0.3333333333333333, Float64(y / z), x); else tmp = Float64(Float64(t / Float64(z * y)) * 0.3333333333333333); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -6.2e+29], N[Not[LessEqual[y, 7.6e-93]], $MachinePrecision]], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision], N[(N[(t / N[(z * y), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+29} \lor \neg \left(y \leq 7.6 \cdot 10^{-93}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t}{z \cdot y} \cdot 0.3333333333333333\\
\end{array}
\end{array}
if y < -6.1999999999999998e29 or 7.5999999999999998e-93 < y Initial program 99.7%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if -6.1999999999999998e29 < y < 7.5999999999999998e-93Initial program 92.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6470.3
Applied rewrites70.3%
Final simplification80.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.04e-13) (not (<= y 9.5e+95))) (* -0.3333333333333333 (/ y z)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.04e-13) || !(y <= 9.5e+95)) {
tmp = -0.3333333333333333 * (y / z);
} else {
tmp = 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-1.04d-13)) .or. (.not. (y <= 9.5d+95))) then
tmp = (-0.3333333333333333d0) * (y / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.04e-13) || !(y <= 9.5e+95)) {
tmp = -0.3333333333333333 * (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.04e-13) or not (y <= 9.5e+95): tmp = -0.3333333333333333 * (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.04e-13) || !(y <= 9.5e+95)) tmp = Float64(-0.3333333333333333 * Float64(y / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.04e-13) || ~((y <= 9.5e+95))) tmp = -0.3333333333333333 * (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.04e-13], N[Not[LessEqual[y, 9.5e+95]], $MachinePrecision]], N[(-0.3333333333333333 * N[(y / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.04 \cdot 10^{-13} \lor \neg \left(y \leq 9.5 \cdot 10^{+95}\right):\\
\;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.03999999999999999e-13 or 9.5000000000000004e95 < y Initial program 99.7%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6473.3
Applied rewrites73.3%
if -1.03999999999999999e-13 < y < 9.5000000000000004e95Initial program 94.1%
Taylor expanded in x around inf
Applied rewrites31.1%
Final simplification47.1%
(FPCore (x y z t) :precision binary64 (if (<= y -1.04e-13) (/ (* -0.3333333333333333 y) z) (if (<= y 9.5e+95) x (* -0.3333333333333333 (/ y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.04e-13) {
tmp = (-0.3333333333333333 * y) / z;
} else if (y <= 9.5e+95) {
tmp = x;
} else {
tmp = -0.3333333333333333 * (y / z);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-1.04d-13)) then
tmp = ((-0.3333333333333333d0) * y) / z
else if (y <= 9.5d+95) then
tmp = x
else
tmp = (-0.3333333333333333d0) * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.04e-13) {
tmp = (-0.3333333333333333 * y) / z;
} else if (y <= 9.5e+95) {
tmp = x;
} else {
tmp = -0.3333333333333333 * (y / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.04e-13: tmp = (-0.3333333333333333 * y) / z elif y <= 9.5e+95: tmp = x else: tmp = -0.3333333333333333 * (y / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.04e-13) tmp = Float64(Float64(-0.3333333333333333 * y) / z); elseif (y <= 9.5e+95) tmp = x; else tmp = Float64(-0.3333333333333333 * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.04e-13) tmp = (-0.3333333333333333 * y) / z; elseif (y <= 9.5e+95) tmp = x; else tmp = -0.3333333333333333 * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.04e-13], N[(N[(-0.3333333333333333 * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 9.5e+95], x, N[(-0.3333333333333333 * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.04 \cdot 10^{-13}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot y}{z}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+95}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -1.03999999999999999e-13Initial program 99.7%
Taylor expanded in x around 0
associate-/r*N/A
associate-*r/N/A
associate-*r/N/A
div-subN/A
lower-/.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f6483.0
Applied rewrites83.0%
Taylor expanded in y around inf
lower-*.f6474.9
Applied rewrites74.9%
if -1.03999999999999999e-13 < y < 9.5000000000000004e95Initial program 94.1%
Taylor expanded in x around inf
Applied rewrites31.1%
if 9.5000000000000004e95 < y Initial program 99.8%
Taylor expanded in y around inf
lower-*.f64N/A
lower-/.f6471.2
Applied rewrites71.2%
(FPCore (x y z t) :precision binary64 (fma -0.3333333333333333 (/ y z) x))
double code(double x, double y, double z, double t) {
return fma(-0.3333333333333333, (y / z), x);
}
function code(x, y, z, t) return fma(-0.3333333333333333, Float64(y / z), x) end
code[x_, y_, z_, t_] := N[(-0.3333333333333333 * N[(y / z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, \frac{y}{z}, x\right)
\end{array}
Initial program 96.3%
Taylor expanded in t around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f6458.7
Applied rewrites58.7%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 96.3%
Taylor expanded in x around inf
Applied rewrites27.3%
(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y)))
double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x - (y / (z * 3.0d0))) + ((t / (z * 3.0d0)) / y)
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y);
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y)
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(t / Float64(z * 3.0)) / y)) end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + ((t / (z * 3.0)) / y); end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t / N[(z * 3.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}
\end{array}
herbie shell --seed 2025037
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:alt
(! :herbie-platform default (+ (- x (/ y (* z 3))) (/ (/ t (* z 3)) y)))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))