
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
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)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- z a))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
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)) / (z - a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (z - a));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (z - a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(z - a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (z - a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{z - a}
\end{array}
(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(Float64(t - z) / Float64(a - z)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t - z}{a - z}, y, x\right)
\end{array}
Initial program 85.2%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
sub-negate-revN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6498.1
Applied rewrites98.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma y (/ z (- z a)) x))) (if (<= z -2.1e+73) t_1 (if (<= z 1.05e+95) (fma (/ t (- a z)) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (z - a)), x);
double tmp;
if (z <= -2.1e+73) {
tmp = t_1;
} else if (z <= 1.05e+95) {
tmp = fma((t / (a - z)), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(z - a)), x) tmp = 0.0 if (z <= -2.1e+73) tmp = t_1; elseif (z <= 1.05e+95) tmp = fma(Float64(t / Float64(a - z)), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.1e+73], t$95$1, If[LessEqual[z, 1.05e+95], N[(N[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{+73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a - z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.1000000000000001e73 or 1.05e95 < z Initial program 85.2%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6471.6
Applied rewrites71.6%
if -2.1000000000000001e73 < z < 1.05e95Initial program 85.2%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
sub-negate-revN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites76.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma y (/ z (- z a)) x)))
(if (<= z -3.3e+71)
t_1
(if (<= z -1.45e-9)
(fma (/ t (- z)) y x)
(if (<= z 4.2e+30) (fma t (/ y a) x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(y, (z / (z - a)), x);
double tmp;
if (z <= -3.3e+71) {
tmp = t_1;
} else if (z <= -1.45e-9) {
tmp = fma((t / -z), y, x);
} else if (z <= 4.2e+30) {
tmp = fma(t, (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(y, Float64(z / Float64(z - a)), x) tmp = 0.0 if (z <= -3.3e+71) tmp = t_1; elseif (z <= -1.45e-9) tmp = fma(Float64(t / Float64(-z)), y, x); elseif (z <= 4.2e+30) tmp = fma(t, Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -3.3e+71], t$95$1, If[LessEqual[z, -1.45e-9], N[(N[(t / (-z)), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 4.2e+30], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\mathbf{if}\;z \leq -3.3 \cdot 10^{+71}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{-z}, y, x\right)\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -3.2999999999999998e71 or 4.2e30 < z Initial program 85.2%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6471.6
Applied rewrites71.6%
if -3.2999999999999998e71 < z < -1.44999999999999996e-9Initial program 85.2%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
sub-negate-revN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites76.1%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6451.5
Applied rewrites51.5%
if -1.44999999999999996e-9 < z < 4.2e30Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.45e-9) (fma y (/ (- z t) z) x) (if (<= z 4.2e+30) (fma t (/ y a) x) (fma y (/ z (- z a)) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.45e-9) {
tmp = fma(y, ((z - t) / z), x);
} else if (z <= 4.2e+30) {
tmp = fma(t, (y / a), x);
} else {
tmp = fma(y, (z / (z - a)), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.45e-9) tmp = fma(y, Float64(Float64(z - t) / z), x); elseif (z <= 4.2e+30) tmp = fma(t, Float64(y / a), x); else tmp = fma(y, Float64(z / Float64(z - a)), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.45e-9], N[(y * N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 4.2e+30], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{z}, x\right)\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{z - a}, x\right)\\
\end{array}
\end{array}
if z < -1.44999999999999996e-9Initial program 85.2%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6466.4
Applied rewrites66.4%
if -1.44999999999999996e-9 < z < 4.2e30Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
if 4.2e30 < z Initial program 85.2%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6471.6
Applied rewrites71.6%
(FPCore (x y z t a)
:precision binary64
(if (<= z -2.3e+73)
(+ y x)
(if (<= z -1.45e-9)
(fma (/ t (- z)) y x)
(if (<= z 5.8e+103) (fma t (/ y a) x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -2.3e+73) {
tmp = y + x;
} else if (z <= -1.45e-9) {
tmp = fma((t / -z), y, x);
} else if (z <= 5.8e+103) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -2.3e+73) tmp = Float64(y + x); elseif (z <= -1.45e-9) tmp = fma(Float64(t / Float64(-z)), y, x); elseif (z <= 5.8e+103) tmp = fma(t, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -2.3e+73], N[(y + x), $MachinePrecision], If[LessEqual[z, -1.45e-9], N[(N[(t / (-z)), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 5.8e+103], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+73}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{-z}, y, x\right)\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -2.3e73 or 5.7999999999999997e103 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -2.3e73 < z < -1.44999999999999996e-9Initial program 85.2%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
sub-negate-revN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower--.f64N/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites76.1%
Taylor expanded in z around inf
mul-1-negN/A
lower-neg.f6451.5
Applied rewrites51.5%
if -1.44999999999999996e-9 < z < 5.7999999999999997e103Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -3e+72)
(+ y x)
(if (<= z -1e-10)
(* t (/ y (- a z)))
(if (<= z 5.8e+103) (fma t (/ y a) x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -3e+72) {
tmp = y + x;
} else if (z <= -1e-10) {
tmp = t * (y / (a - z));
} else if (z <= 5.8e+103) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -3e+72) tmp = Float64(y + x); elseif (z <= -1e-10) tmp = Float64(t * Float64(y / Float64(a - z))); elseif (z <= 5.8e+103) tmp = fma(t, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -3e+72], N[(y + x), $MachinePrecision], If[LessEqual[z, -1e-10], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e+103], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{+72}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-10}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -3.00000000000000003e72 or 5.7999999999999997e103 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -3.00000000000000003e72 < z < -1.00000000000000004e-10Initial program 85.2%
Taylor expanded in t around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
associate-/l*26.3
sub-div26.3
fp-cancel-sign-sub-inv26.3
sub-div26.3
sub-negate-rev26.3
sub-negate-rev26.3
frac-2neg26.3
fp-cancel-sign-sub-inv26.3
associate-/l*26.3
+-commutative26.3
associate-/l*26.3
*-commutative26.3
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-/l*N/A
frac-2negN/A
mul-1-negN/A
Applied rewrites28.5%
if -1.00000000000000004e-10 < z < 5.7999999999999997e103Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a)
:precision binary64
(if (<= z -9.5e+30)
(+ y x)
(if (<= z -1e-10)
(/ (* t y) (- a z))
(if (<= z 5.8e+103) (fma t (/ y a) x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -9.5e+30) {
tmp = y + x;
} else if (z <= -1e-10) {
tmp = (t * y) / (a - z);
} else if (z <= 5.8e+103) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -9.5e+30) tmp = Float64(y + x); elseif (z <= -1e-10) tmp = Float64(Float64(t * y) / Float64(a - z)); elseif (z <= 5.8e+103) tmp = fma(t, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -9.5e+30], N[(y + x), $MachinePrecision], If[LessEqual[z, -1e-10], N[(N[(t * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e+103], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+30}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-10}:\\
\;\;\;\;\frac{t \cdot y}{a - z}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -9.5000000000000003e30 or 5.7999999999999997e103 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -9.5000000000000003e30 < z < -1.00000000000000004e-10Initial program 85.2%
Taylor expanded in t around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
if -1.00000000000000004e-10 < z < 5.7999999999999997e103Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -6.3e-9) (+ y x) (if (<= z 5.8e+103) (fma t (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -6.3e-9) {
tmp = y + x;
} else if (z <= 5.8e+103) {
tmp = fma(t, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -6.3e-9) tmp = Float64(y + x); elseif (z <= 5.8e+103) tmp = fma(t, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -6.3e-9], N[(y + x), $MachinePrecision], If[LessEqual[z, 5.8e+103], N[(t * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.3 \cdot 10^{-9}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+103}:\\
\;\;\;\;\mathsf{fma}\left(t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -6.3000000000000002e-9 or 5.7999999999999997e103 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -6.3000000000000002e-9 < z < 5.7999999999999997e103Initial program 85.2%
Taylor expanded in z around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.45e-135) (+ y x) (if (<= z 1.55e-140) (* t (/ y a)) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.45e-135) {
tmp = y + x;
} else if (z <= 1.55e-140) {
tmp = t * (y / a);
} else {
tmp = y + 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, 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 (z <= (-1.45d-135)) then
tmp = y + x
else if (z <= 1.55d-140) then
tmp = t * (y / a)
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.45e-135) {
tmp = y + x;
} else if (z <= 1.55e-140) {
tmp = t * (y / a);
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.45e-135: tmp = y + x elif z <= 1.55e-140: tmp = t * (y / a) else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.45e-135) tmp = Float64(y + x); elseif (z <= 1.55e-140) tmp = Float64(t * Float64(y / a)); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.45e-135) tmp = y + x; elseif (z <= 1.55e-140) tmp = t * (y / a); else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.45e-135], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.55e-140], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{-135}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-140}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.4500000000000001e-135 or 1.55e-140 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -1.4500000000000001e-135 < z < 1.55e-140Initial program 85.2%
Taylor expanded in t around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
associate-/l*26.3
sub-div26.3
fp-cancel-sign-sub-inv26.3
sub-div26.3
sub-negate-rev26.3
sub-negate-rev26.3
frac-2neg26.3
fp-cancel-sign-sub-inv26.3
associate-/l*26.3
+-commutative26.3
associate-/l*26.3
*-commutative26.3
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-/l*N/A
frac-2negN/A
mul-1-negN/A
Applied rewrites28.5%
Taylor expanded in z around 0
Applied rewrites20.4%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.45e-135) (+ y x) (if (<= z 1.5e-140) (* y (/ t a)) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.45e-135) {
tmp = y + x;
} else if (z <= 1.5e-140) {
tmp = y * (t / a);
} else {
tmp = y + 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, 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 (z <= (-1.45d-135)) then
tmp = y + x
else if (z <= 1.5d-140) then
tmp = y * (t / a)
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.45e-135) {
tmp = y + x;
} else if (z <= 1.5e-140) {
tmp = y * (t / a);
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.45e-135: tmp = y + x elif z <= 1.5e-140: tmp = y * (t / a) else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.45e-135) tmp = Float64(y + x); elseif (z <= 1.5e-140) tmp = Float64(y * Float64(t / a)); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.45e-135) tmp = y + x; elseif (z <= 1.5e-140) tmp = y * (t / a); else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.45e-135], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.5e-140], N[(y * N[(t / a), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{-135}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-140}:\\
\;\;\;\;y \cdot \frac{t}{a}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.4500000000000001e-135 or 1.50000000000000009e-140 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -1.4500000000000001e-135 < z < 1.50000000000000009e-140Initial program 85.2%
Taylor expanded in t around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
associate-/l*26.3
sub-div26.3
fp-cancel-sign-sub-inv26.3
sub-div26.3
sub-negate-rev26.3
sub-negate-rev26.3
frac-2neg26.3
fp-cancel-sign-sub-inv26.3
associate-/l*26.3
+-commutative26.3
associate-/l*26.3
*-commutative26.3
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-/l*N/A
frac-2negN/A
mul-1-negN/A
Applied rewrites28.5%
Taylor expanded in z around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6418.7
Applied rewrites18.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f6420.7
Applied rewrites20.7%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.32e-135) (+ y x) (if (<= z 1.5e-140) (/ (* t y) a) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.32e-135) {
tmp = y + x;
} else if (z <= 1.5e-140) {
tmp = (t * y) / a;
} else {
tmp = y + 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, 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 (z <= (-1.32d-135)) then
tmp = y + x
else if (z <= 1.5d-140) then
tmp = (t * y) / a
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.32e-135) {
tmp = y + x;
} else if (z <= 1.5e-140) {
tmp = (t * y) / a;
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -1.32e-135: tmp = y + x elif z <= 1.5e-140: tmp = (t * y) / a else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.32e-135) tmp = Float64(y + x); elseif (z <= 1.5e-140) tmp = Float64(Float64(t * y) / a); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -1.32e-135) tmp = y + x; elseif (z <= 1.5e-140) tmp = (t * y) / a; else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.32e-135], N[(y + x), $MachinePrecision], If[LessEqual[z, 1.5e-140], N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.32 \cdot 10^{-135}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-140}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.32000000000000007e-135 or 1.50000000000000009e-140 < z Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
if -1.32000000000000007e-135 < z < 1.50000000000000009e-140Initial program 85.2%
Taylor expanded in t around inf
associate-*r/N/A
mul-1-negN/A
sub-negate-revN/A
frac-2neg-revN/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
Taylor expanded in z around 0
Applied rewrites18.7%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + 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, 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 = y + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
(FPCore (x y z t a) :precision binary64 y)
double code(double x, double y, double z, double t, double a) {
return 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, 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 = y
end function
public static double code(double x, double y, double z, double t, double a) {
return y;
}
def code(x, y, z, t, a): return y
function code(x, y, z, t, a) return y end
function tmp = code(x, y, z, t, a) tmp = y; end
code[x_, y_, z_, t_, a_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 85.2%
Taylor expanded in z around inf
+-commutativeN/A
lower-+.f6460.4
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites19.2%
herbie shell --seed 2025134
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, A"
:precision binary64
(+ x (/ (* y (- z t)) (- z a))))