
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
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) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
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) + z) + y) + t)) + (y * 5.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
def code(x, y, z, t): return (x * ((((y + z) + z) + y) + t)) + (y * 5.0)
function code(x, y, z, t) return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0)) end
function tmp = code(x, y, z, t) tmp = (x * ((((y + z) + z) + y) + t)) + (y * 5.0); end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\end{array}
(FPCore (x y z t) :precision binary64 (fma y 5.0 (* x (fma (+ y z) 2.0 t))))
double code(double x, double y, double z, double t) {
return fma(y, 5.0, (x * fma((y + z), 2.0, t)));
}
function code(x, y, z, t) return fma(y, 5.0, Float64(x * fma(Float64(y + z), 2.0, t))) end
code[x_, y_, z_, t_] := N[(y * 5.0 + N[(x * N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, 5, x \cdot \mathsf{fma}\left(y + z, 2, t\right)\right)
\end{array}
Initial program 99.9%
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (fma (+ y z) 2.0 t) x)))
(if (<= x -3.5)
t_1
(if (<= x 1.05e-14) (+ (* x (+ (* 2.0 z) t)) (* y 5.0)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y + z), 2.0, t) * x;
double tmp;
if (x <= -3.5) {
tmp = t_1;
} else if (x <= 1.05e-14) {
tmp = (x * ((2.0 * z) + t)) + (y * 5.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(y + z), 2.0, t) * x) tmp = 0.0 if (x <= -3.5) tmp = t_1; elseif (x <= 1.05e-14) tmp = Float64(Float64(x * Float64(Float64(2.0 * z) + t)) + Float64(y * 5.0)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -3.5], t$95$1, If[LessEqual[x, 1.05e-14], N[(N[(x * N[(N[(2.0 * z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + z, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.05 \cdot 10^{-14}:\\
\;\;\;\;x \cdot \left(2 \cdot z + t\right) + y \cdot 5\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.5 or 1.0499999999999999e-14 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites71.4%
Applied rewrites71.4%
if -3.5 < x < 1.0499999999999999e-14Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites84.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (fma (+ y z) 2.0 t) x)))
(if (<= x -330000.0)
t_1
(if (<= x 7.4e-16) (fma y 5.0 (* x (* 2.0 (+ y z)))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y + z), 2.0, t) * x;
double tmp;
if (x <= -330000.0) {
tmp = t_1;
} else if (x <= 7.4e-16) {
tmp = fma(y, 5.0, (x * (2.0 * (y + z))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(y + z), 2.0, t) * x) tmp = 0.0 if (x <= -330000.0) tmp = t_1; elseif (x <= 7.4e-16) tmp = fma(y, 5.0, Float64(x * Float64(2.0 * Float64(y + z)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -330000.0], t$95$1, If[LessEqual[x, 7.4e-16], N[(y * 5.0 + N[(x * N[(2.0 * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + z, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -330000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, x \cdot \left(2 \cdot \left(y + z\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.3e5 or 7.3999999999999999e-16 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites71.4%
Applied rewrites71.4%
if -3.3e5 < x < 7.3999999999999999e-16Initial program 99.9%
Applied rewrites100.0%
Taylor expanded in t around 0
Applied rewrites74.6%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma (+ y z) 2.0 t) x))) (if (<= x -3.5) t_1 (if (<= x 7.4e-16) (fma y 5.0 (* x (+ z z))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y + z), 2.0, t) * x;
double tmp;
if (x <= -3.5) {
tmp = t_1;
} else if (x <= 7.4e-16) {
tmp = fma(y, 5.0, (x * (z + z)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(y + z), 2.0, t) * x) tmp = 0.0 if (x <= -3.5) tmp = t_1; elseif (x <= 7.4e-16) tmp = fma(y, 5.0, Float64(x * Float64(z + z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -3.5], t$95$1, If[LessEqual[x, 7.4e-16], N[(y * 5.0 + N[(x * N[(z + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + z, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(y, 5, x \cdot \left(z + z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.5 or 7.3999999999999999e-16 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites71.4%
Applied rewrites71.4%
if -3.5 < x < 7.3999999999999999e-16Initial program 99.9%
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites58.9%
Applied rewrites58.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (fma (+ y z) 2.0 t) x))) (if (<= x -1.5e-9) t_1 (if (<= x 1.9e-51) (fma 5.0 y (* x t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y + z), 2.0, t) * x;
double tmp;
if (x <= -1.5e-9) {
tmp = t_1;
} else if (x <= 1.9e-51) {
tmp = fma(5.0, y, (x * t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(fma(Float64(y + z), 2.0, t) * x) tmp = 0.0 if (x <= -1.5e-9) tmp = t_1; elseif (x <= 1.9e-51) tmp = fma(5.0, y, Float64(x * t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(y + z), $MachinePrecision] * 2.0 + t), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.5e-9], t$95$1, If[LessEqual[x, 1.9e-51], N[(5.0 * y + N[(x * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y + z, 2, t\right) \cdot x\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.49999999999999999e-9 or 1.90000000000000001e-51 < x Initial program 99.9%
Applied rewrites99.9%
Taylor expanded in x around inf
Applied rewrites71.4%
Applied rewrites71.4%
if -1.49999999999999999e-9 < x < 1.90000000000000001e-51Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites73.9%
Taylor expanded in y around 0
Applied rewrites57.8%
(FPCore (x y z t) :precision binary64 (if (<= y -3.4e+53) (fma (+ x 5.0) y (* y x)) (if (<= y 2.15e-82) (* x (+ t (* 2.0 z))) (fma 5.0 y (* x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.4e+53) {
tmp = fma((x + 5.0), y, (y * x));
} else if (y <= 2.15e-82) {
tmp = x * (t + (2.0 * z));
} else {
tmp = fma(5.0, y, (x * t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -3.4e+53) tmp = fma(Float64(x + 5.0), y, Float64(y * x)); elseif (y <= 2.15e-82) tmp = Float64(x * Float64(t + Float64(2.0 * z))); else tmp = fma(5.0, y, Float64(x * t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.4e+53], N[(N[(x + 5.0), $MachinePrecision] * y + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.15e-82], N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(5.0 * y + N[(x * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;\mathsf{fma}\left(x + 5, y, y \cdot x\right)\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-82}:\\
\;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot t\right)\\
\end{array}
\end{array}
if y < -3.39999999999999998e53Initial program 99.9%
Taylor expanded in y around inf
Applied rewrites47.9%
Applied rewrites47.9%
if -3.39999999999999998e53 < y < 2.15000000000000009e-82Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites56.7%
if 2.15000000000000009e-82 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites73.9%
Taylor expanded in y around 0
Applied rewrites57.8%
(FPCore (x y z t) :precision binary64 (if (<= y -3.4e+53) (* y (fma x 2.0 5.0)) (if (<= y 2.15e-82) (* x (+ t (* 2.0 z))) (fma 5.0 y (* x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.4e+53) {
tmp = y * fma(x, 2.0, 5.0);
} else if (y <= 2.15e-82) {
tmp = x * (t + (2.0 * z));
} else {
tmp = fma(5.0, y, (x * t));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -3.4e+53) tmp = Float64(y * fma(x, 2.0, 5.0)); elseif (y <= 2.15e-82) tmp = Float64(x * Float64(t + Float64(2.0 * z))); else tmp = fma(5.0, y, Float64(x * t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.4e+53], N[(y * N[(x * 2.0 + 5.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.15e-82], N[(x * N[(t + N[(2.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(5.0 * y + N[(x * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+53}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(x, 2, 5\right)\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-82}:\\
\;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot t\right)\\
\end{array}
\end{array}
if y < -3.39999999999999998e53Initial program 99.9%
Taylor expanded in y around inf
Applied rewrites47.9%
Applied rewrites47.9%
if -3.39999999999999998e53 < y < 2.15000000000000009e-82Initial program 99.9%
Taylor expanded in y around 0
Applied rewrites56.7%
if 2.15000000000000009e-82 < y Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites73.9%
Taylor expanded in y around 0
Applied rewrites57.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (+ x x) z))) (if (<= z -1.3e+81) t_1 (if (<= z 4.9e+42) (fma 5.0 y (* x t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x + x) * z;
double tmp;
if (z <= -1.3e+81) {
tmp = t_1;
} else if (z <= 4.9e+42) {
tmp = fma(5.0, y, (x * t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x + x) * z) tmp = 0.0 if (z <= -1.3e+81) tmp = t_1; elseif (z <= 4.9e+42) tmp = fma(5.0, y, Float64(x * t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.3e+81], t$95$1, If[LessEqual[z, 4.9e+42], N[(5.0 * y + N[(x * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot z\\
\mathbf{if}\;z \leq -1.3 \cdot 10^{+81}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.9 \cdot 10^{+42}:\\
\;\;\;\;\mathsf{fma}\left(5, y, x \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.29999999999999996e81 or 4.9000000000000002e42 < z Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites30.9%
Applied rewrites30.9%
if -1.29999999999999996e81 < z < 4.9000000000000002e42Initial program 99.9%
Taylor expanded in z around 0
Applied rewrites73.9%
Taylor expanded in y around 0
Applied rewrites57.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (+ x x) z)))
(if (<= x -2.5e+45)
(* t x)
(if (<= x -1.45e-9) t_1 (if (<= x 1.9e-51) (* 5.0 y) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (x + x) * z;
double tmp;
if (x <= -2.5e+45) {
tmp = t * x;
} else if (x <= -1.45e-9) {
tmp = t_1;
} else if (x <= 1.9e-51) {
tmp = 5.0 * y;
} else {
tmp = t_1;
}
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 + x) * z
if (x <= (-2.5d+45)) then
tmp = t * x
else if (x <= (-1.45d-9)) then
tmp = t_1
else if (x <= 1.9d-51) then
tmp = 5.0d0 * y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x + x) * z;
double tmp;
if (x <= -2.5e+45) {
tmp = t * x;
} else if (x <= -1.45e-9) {
tmp = t_1;
} else if (x <= 1.9e-51) {
tmp = 5.0 * y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x + x) * z tmp = 0 if x <= -2.5e+45: tmp = t * x elif x <= -1.45e-9: tmp = t_1 elif x <= 1.9e-51: tmp = 5.0 * y else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x + x) * z) tmp = 0.0 if (x <= -2.5e+45) tmp = Float64(t * x); elseif (x <= -1.45e-9) tmp = t_1; elseif (x <= 1.9e-51) tmp = Float64(5.0 * y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x + x) * z; tmp = 0.0; if (x <= -2.5e+45) tmp = t * x; elseif (x <= -1.45e-9) tmp = t_1; elseif (x <= 1.9e-51) tmp = 5.0 * y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x + x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[x, -2.5e+45], N[(t * x), $MachinePrecision], If[LessEqual[x, -1.45e-9], t$95$1, If[LessEqual[x, 1.9e-51], N[(5.0 * y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + x\right) \cdot z\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{+45}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq -1.45 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.5e45Initial program 99.9%
Taylor expanded in t around inf
Applied rewrites29.9%
if -2.5e45 < x < -1.44999999999999996e-9 or 1.90000000000000001e-51 < x Initial program 99.9%
Taylor expanded in z around inf
Applied rewrites30.9%
Applied rewrites30.9%
if -1.44999999999999996e-9 < x < 1.90000000000000001e-51Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites30.3%
(FPCore (x y z t) :precision binary64 (if (<= x -1.5e-6) (* t x) (if (<= x 7.4e-16) (* 5.0 y) (* t x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.5e-6) {
tmp = t * x;
} else if (x <= 7.4e-16) {
tmp = 5.0 * y;
} else {
tmp = t * 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 (x <= (-1.5d-6)) then
tmp = t * x
else if (x <= 7.4d-16) then
tmp = 5.0d0 * y
else
tmp = t * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.5e-6) {
tmp = t * x;
} else if (x <= 7.4e-16) {
tmp = 5.0 * y;
} else {
tmp = t * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.5e-6: tmp = t * x elif x <= 7.4e-16: tmp = 5.0 * y else: tmp = t * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.5e-6) tmp = Float64(t * x); elseif (x <= 7.4e-16) tmp = Float64(5.0 * y); else tmp = Float64(t * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.5e-6) tmp = t * x; elseif (x <= 7.4e-16) tmp = 5.0 * y; else tmp = t * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.5e-6], N[(t * x), $MachinePrecision], If[LessEqual[x, 7.4e-16], N[(5.0 * y), $MachinePrecision], N[(t * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-6}:\\
\;\;\;\;t \cdot x\\
\mathbf{elif}\;x \leq 7.4 \cdot 10^{-16}:\\
\;\;\;\;5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;t \cdot x\\
\end{array}
\end{array}
if x < -1.5e-6 or 7.3999999999999999e-16 < x Initial program 99.9%
Taylor expanded in t around inf
Applied rewrites29.9%
if -1.5e-6 < x < 7.3999999999999999e-16Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites30.3%
(FPCore (x y z t) :precision binary64 (* 5.0 y))
double code(double x, double y, double z, double t) {
return 5.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 = 5.0d0 * y
end function
public static double code(double x, double y, double z, double t) {
return 5.0 * y;
}
def code(x, y, z, t): return 5.0 * y
function code(x, y, z, t) return Float64(5.0 * y) end
function tmp = code(x, y, z, t) tmp = 5.0 * y; end
code[x_, y_, z_, t_] := N[(5.0 * y), $MachinePrecision]
\begin{array}{l}
\\
5 \cdot y
\end{array}
Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites30.3%
herbie shell --seed 2025153
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
:precision binary64
(+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))