
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - 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, t, a)
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), intent (in) :: a
code = x + (((y - z) * t) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{\left(y - z\right) \cdot t}{a - z}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - 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, t, a)
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), intent (in) :: a
code = x + (((y - z) * t) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{\left(y - z\right) \cdot t}{a - z}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- z a)) t x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - y) / (z - a)), t, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - y) / Float64(z - a)), t, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]
\mathsf{fma}\left(\frac{z - y}{z - a}, t, x\right)
Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
(FPCore (x y z t a) :precision binary64 (fma (/ t (- z a)) (- z y) x))
double code(double x, double y, double z, double t, double a) {
return fma((t / (z - a)), (z - y), x);
}
function code(x, y, z, t, a) return fma(Float64(t / Float64(z - a)), Float64(z - y), x) end
code[x_, y_, z_, t_, a_] := N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(\frac{t}{z - a}, z - y, x\right)
Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
remove-double-negN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6495.5%
Applied rewrites95.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* (- y z) t) (- a z))))
(if (<= t_1 -5e+39)
(/ t (/ (- a z) (- y z)))
(if (<= t_1 1e+135)
(fma (/ z (- z a)) t x)
(* (/ t (- z a)) (- z y))))))double code(double x, double y, double z, double t, double a) {
double t_1 = ((y - z) * t) / (a - z);
double tmp;
if (t_1 <= -5e+39) {
tmp = t / ((a - z) / (y - z));
} else if (t_1 <= 1e+135) {
tmp = fma((z / (z - a)), t, x);
} else {
tmp = (t / (z - a)) * (z - y);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(y - z) * t) / Float64(a - z)) tmp = 0.0 if (t_1 <= -5e+39) tmp = Float64(t / Float64(Float64(a - z) / Float64(y - z))); elseif (t_1 <= 1e+135) tmp = fma(Float64(z / Float64(z - a)), t, x); else tmp = Float64(Float64(t / Float64(z - a)) * Float64(z - y)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+39], N[(t / N[(N[(a - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+135], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+39}:\\
\;\;\;\;\frac{t}{\frac{a - z}{y - z}}\\
\mathbf{elif}\;t\_1 \leq 10^{+135}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t}{z - a} \cdot \left(z - y\right)\\
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -5.0000000000000002e39Initial program 85.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.6%
Applied rewrites38.6%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
frac-2negN/A
lower-/.f6446.1%
Applied rewrites46.1%
lift-*.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-/.f64N/A
lower-/.f6449.1%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6449.1%
Applied rewrites49.1%
if -5.0000000000000002e39 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 9.9999999999999996e134Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
if 9.9999999999999996e134 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 85.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.6%
Applied rewrites38.6%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
frac-2negN/A
lower-/.f6446.1%
Applied rewrites46.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ t (- z a)) (- z y)))
(t_2 (/ (* (- y z) t) (- a z))))
(if (<= t_2 -2e+48)
t_1
(if (<= t_2 1e+135) (fma (/ z (- z a)) t x) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = (t / (z - a)) * (z - y);
double t_2 = ((y - z) * t) / (a - z);
double tmp;
if (t_2 <= -2e+48) {
tmp = t_1;
} else if (t_2 <= 1e+135) {
tmp = fma((z / (z - a)), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(t / Float64(z - a)) * Float64(z - y)) t_2 = Float64(Float64(Float64(y - z) * t) / Float64(a - z)) tmp = 0.0 if (t_2 <= -2e+48) tmp = t_1; elseif (t_2 <= 1e+135) tmp = fma(Float64(z / Float64(z - a)), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+48], t$95$1, If[LessEqual[t$95$2, 1e+135], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_1 := \frac{t}{z - a} \cdot \left(z - y\right)\\
t_2 := \frac{\left(y - z\right) \cdot t}{a - z}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+135}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < -2.0000000000000001e48 or 9.9999999999999996e134 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) Initial program 85.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.6%
Applied rewrites38.6%
lift-/.f64N/A
frac-2negN/A
mul-1-negN/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
distribute-neg-frac2N/A
mul-1-negN/A
frac-2negN/A
lower-/.f6446.1%
Applied rewrites46.1%
if -2.0000000000000001e48 < (/.f64 (*.f64 (-.f64 y z) t) (-.f64 a z)) < 9.9999999999999996e134Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -3.9e+21)
(fma (- 1.0 (/ y z)) t x)
(if (<= z 5.1e-11)
(+ x (/ (* t y) (- a z)))
(fma (/ z (- z a)) t x))))double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3.9e+21) {
tmp = fma((1.0 - (y / z)), t, x);
} else if (z <= 5.1e-11) {
tmp = x + ((t * y) / (a - z));
} else {
tmp = fma((z / (z - a)), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3.9e+21) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); elseif (z <= 5.1e-11) tmp = Float64(x + Float64(Float64(t * y) / Float64(a - z))); else tmp = fma(Float64(z / Float64(z - a)), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3.9e+21], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], If[LessEqual[z, 5.1e-11], N[(x + N[(N[(t * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{-11}:\\
\;\;\;\;x + \frac{t \cdot y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\end{array}
if z < -3.9e21Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.7%
Applied rewrites67.7%
lift--.f64N/A
lift-/.f64N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f6467.7%
Applied rewrites67.7%
if -3.9e21 < z < 5.0999999999999998e-11Initial program 85.4%
Taylor expanded in y around inf
lower-*.f6473.2%
Applied rewrites73.2%
if 5.0999999999999998e-11 < z Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.2e-64)
(fma (- 1.0 (/ y z)) t x)
(if (<= z 6.5e-199)
(fma (* (/ 1.0 a) y) t x)
(fma (/ z (- z a)) t x))))double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.2e-64) {
tmp = fma((1.0 - (y / z)), t, x);
} else if (z <= 6.5e-199) {
tmp = fma(((1.0 / a) * y), t, x);
} else {
tmp = fma((z / (z - a)), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.2e-64) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); elseif (z <= 6.5e-199) tmp = fma(Float64(Float64(1.0 / a) * y), t, x); else tmp = fma(Float64(z / Float64(z - a)), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.2e-64], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], If[LessEqual[z, 6.5e-199], N[(N[(N[(1.0 / a), $MachinePrecision] * y), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-199}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a} \cdot y, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\end{array}
if z < -2.2e-64Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.7%
Applied rewrites67.7%
lift--.f64N/A
lift-/.f64N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f6467.7%
Applied rewrites67.7%
if -2.2e-64 < z < 6.5000000000000002e-199Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in z around 0
lower-/.f6462.2%
Applied rewrites62.2%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.2%
Applied rewrites62.2%
if 6.5000000000000002e-199 < z Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.2e-64) (fma (- 1.0 (/ y z)) t x) (if (<= z 6.5e-199) (fma (/ y a) t x) (fma (/ z (- z a)) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.2e-64) {
tmp = fma((1.0 - (y / z)), t, x);
} else if (z <= 6.5e-199) {
tmp = fma((y / a), t, x);
} else {
tmp = fma((z / (z - a)), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.2e-64) tmp = fma(Float64(1.0 - Float64(y / z)), t, x); elseif (z <= 6.5e-199) tmp = fma(Float64(y / a), t, x); else tmp = fma(Float64(z / Float64(z - a)), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.2e-64], N[(N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision], If[LessEqual[z, 6.5e-199], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{y}{z}, t, x\right)\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-199}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\end{array}
if z < -2.2e-64Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.7%
Applied rewrites67.7%
lift--.f64N/A
lift-/.f64N/A
div-subN/A
*-inversesN/A
lower--.f64N/A
lower-/.f6467.7%
Applied rewrites67.7%
if -2.2e-64 < z < 6.5000000000000002e-199Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in z around 0
lower-/.f6462.2%
Applied rewrites62.2%
if 6.5000000000000002e-199 < z Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -2.2e-64) (fma (/ (- z y) z) t x) (if (<= z 6.5e-199) (fma (/ y a) t x) (fma (/ z (- z a)) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.2e-64) {
tmp = fma(((z - y) / z), t, x);
} else if (z <= 6.5e-199) {
tmp = fma((y / a), t, x);
} else {
tmp = fma((z / (z - a)), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.2e-64) tmp = fma(Float64(Float64(z - y) / z), t, x); elseif (z <= 6.5e-199) tmp = fma(Float64(y / a), t, x); else tmp = fma(Float64(z / Float64(z - a)), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.2e-64], N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * t + x), $MachinePrecision], If[LessEqual[z, 6.5e-199], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - y}{z}, t, x\right)\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{-199}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, t, x\right)\\
\end{array}
if z < -2.2e-64Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.7%
Applied rewrites67.7%
if -2.2e-64 < z < 6.5000000000000002e-199Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in z around 0
lower-/.f6462.2%
Applied rewrites62.2%
if 6.5000000000000002e-199 < z Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in y around 0
Applied rewrites72.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z y) z) t x))) (if (<= z -2.2e-64) t_1 (if (<= z 8.8e-17) (fma (/ y a) t x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / z), t, x);
double tmp;
if (z <= -2.2e-64) {
tmp = t_1;
} else if (z <= 8.8e-17) {
tmp = fma((y / a), t, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / z), t, x) tmp = 0.0 if (z <= -2.2e-64) tmp = t_1; elseif (z <= 8.8e-17) tmp = fma(Float64(y / a), t, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[z, -2.2e-64], t$95$1, If[LessEqual[z, 8.8e-17], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{z}, t, x\right)\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-17}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if z < -2.2e-64 or 8.8e-17 < z Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.7%
Applied rewrites67.7%
if -2.2e-64 < z < 8.8e-17Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in z around 0
lower-/.f6462.2%
Applied rewrites62.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.2e+21) (+ x t) (if (<= z 5.1e-11) (fma (/ y a) t x) (+ x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.2e+21) {
tmp = x + t;
} else if (z <= 5.1e-11) {
tmp = fma((y / a), t, x);
} else {
tmp = x + t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.2e+21) tmp = Float64(x + t); elseif (z <= 5.1e-11) tmp = fma(Float64(y / a), t, x); else tmp = Float64(x + t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.2e+21], N[(x + t), $MachinePrecision], If[LessEqual[z, 5.1e-11], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(x + t), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+21}:\\
\;\;\;\;x + t\\
\mathbf{elif}\;z \leq 5.1 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
if z < -4.2e21 or 5.0999999999999998e-11 < z Initial program 85.4%
Taylor expanded in z around inf
Applied rewrites61.8%
if -4.2e21 < z < 5.0999999999999998e-11Initial program 85.4%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
mult-flip-revN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.4%
Applied rewrites98.4%
Taylor expanded in z around 0
lower-/.f6462.2%
Applied rewrites62.2%
(FPCore (x y z t a) :precision binary64 (if (<= y -1.05e+243) (/ (* t y) a) (+ x t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.05e+243) {
tmp = (t * y) / a;
} else {
tmp = x + t;
}
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, a)
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), intent (in) :: a
real(8) :: tmp
if (y <= (-1.05d+243)) then
tmp = (t * y) / a
else
tmp = x + t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= -1.05e+243) {
tmp = (t * y) / a;
} else {
tmp = x + t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= -1.05e+243: tmp = (t * y) / a else: tmp = x + t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= -1.05e+243) tmp = Float64(Float64(t * y) / a); else tmp = Float64(x + t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= -1.05e+243) tmp = (t * y) / a; else tmp = x + t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -1.05e+243], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision], N[(x + t), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+243}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
if y < -1.05e243Initial program 85.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.6%
Applied rewrites38.6%
Taylor expanded in z around 0
Applied rewrites21.6%
Taylor expanded in y around inf
lower-*.f6418.2%
Applied rewrites18.2%
if -1.05e243 < y Initial program 85.4%
Taylor expanded in z around inf
Applied rewrites61.8%
(FPCore (x y z t a) :precision binary64 (+ x t))
double code(double x, double y, double z, double t, double a) {
return x + t;
}
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, a)
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), intent (in) :: a
code = x + t
end function
public static double code(double x, double y, double z, double t, double a) {
return x + t;
}
def code(x, y, z, t, a): return x + t
function code(x, y, z, t, a) return Float64(x + t) end
function tmp = code(x, y, z, t, a) tmp = x + t; end
code[x_, y_, z_, t_, a_] := N[(x + t), $MachinePrecision]
x + t
Initial program 85.4%
Taylor expanded in z around inf
Applied rewrites61.8%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return t;
}
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, a)
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), intent (in) :: a
code = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
t
Initial program 85.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.6%
Applied rewrites38.6%
Taylor expanded in z around 0
Applied rewrites21.6%
Taylor expanded in z around inf
Applied rewrites19.1%
herbie shell --seed 2025212
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
:precision binary64
(+ x (/ (* (- y z) t) (- a z))))