
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - 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 + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - 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 + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- t z) (- t a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((t - z) / (t - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(t - z) / Float64(t - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t - z}{t - a}, y, x\right)
\end{array}
Initial program 85.0%
Applied rewrites98.1%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- t a)) (- t z) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (t - a)), (t - z), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(t - a)), Float64(t - z), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{t - a}, t - z, x\right)
\end{array}
Initial program 85.0%
Applied rewrites95.8%
(FPCore (x y z t a) :precision binary64 (if (<= t -4e+47) (fma (- 1.0 (/ z t)) y x) (if (<= t 9.5e+52) (+ x (/ (* y z) (- a t))) (fma (/ t (- t a)) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4e+47) {
tmp = fma((1.0 - (z / t)), y, x);
} else if (t <= 9.5e+52) {
tmp = x + ((y * z) / (a - t));
} else {
tmp = fma((t / (t - a)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4e+47) tmp = fma(Float64(1.0 - Float64(z / t)), y, x); elseif (t <= 9.5e+52) tmp = Float64(x + Float64(Float64(y * z) / Float64(a - t))); else tmp = fma(Float64(t / Float64(t - a)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4e+47], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 9.5e+52], N[(x + N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{+47}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 9.5 \cdot 10^{+52}:\\
\;\;\;\;x + \frac{y \cdot z}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{t - a}, y, x\right)\\
\end{array}
\end{array}
if t < -4.0000000000000002e47Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
Applied rewrites66.9%
if -4.0000000000000002e47 < t < 9.49999999999999994e52Initial program 85.0%
Taylor expanded in z around inf
Applied rewrites73.4%
if 9.49999999999999994e52 < t Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites71.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.8e-13) (fma (- 1.0 (/ z t)) y x) (if (<= t 1.05e-59) (fma (/ z a) y x) (fma (/ t (- t a)) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.8e-13) {
tmp = fma((1.0 - (z / t)), y, x);
} else if (t <= 1.05e-59) {
tmp = fma((z / a), y, x);
} else {
tmp = fma((t / (t - a)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.8e-13) tmp = fma(Float64(1.0 - Float64(z / t)), y, x); elseif (t <= 1.05e-59) tmp = fma(Float64(z / a), y, x); else tmp = fma(Float64(t / Float64(t - a)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.8e-13], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 1.05e-59], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 1.05 \cdot 10^{-59}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{t - a}, y, x\right)\\
\end{array}
\end{array}
if t < -1.7999999999999999e-13Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
Applied rewrites66.9%
if -1.7999999999999999e-13 < t < 1.04999999999999998e-59Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
if 1.04999999999999998e-59 < t Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in z around 0
Applied rewrites71.3%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.8e-13) (fma (- 1.0 (/ z t)) y x) (if (<= t 1.1e-59) (fma (/ z a) y x) (fma (/ y (- t a)) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.8e-13) {
tmp = fma((1.0 - (z / t)), y, x);
} else if (t <= 1.1e-59) {
tmp = fma((z / a), y, x);
} else {
tmp = fma((y / (t - a)), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.8e-13) tmp = fma(Float64(1.0 - Float64(z / t)), y, x); elseif (t <= 1.1e-59) tmp = fma(Float64(z / a), y, x); else tmp = fma(Float64(y / Float64(t - a)), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.8e-13], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 1.1e-59], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{-59}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t - a}, t, x\right)\\
\end{array}
\end{array}
if t < -1.7999999999999999e-13Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
Applied rewrites66.9%
if -1.7999999999999999e-13 < t < 1.0999999999999999e-59Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
if 1.0999999999999999e-59 < t Initial program 85.0%
Applied rewrites95.8%
Taylor expanded in z around 0
Applied rewrites70.2%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.8e-13) (fma (- 1.0 (/ z t)) y x) (if (<= t 8e-50) (fma (/ z a) y x) (fma (/ (- t z) t) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.8e-13) {
tmp = fma((1.0 - (z / t)), y, x);
} else if (t <= 8e-50) {
tmp = fma((z / a), y, x);
} else {
tmp = fma(((t - z) / t), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.8e-13) tmp = fma(Float64(1.0 - Float64(z / t)), y, x); elseif (t <= 8e-50) tmp = fma(Float64(z / a), y, x); else tmp = fma(Float64(Float64(t - z) / t), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.8e-13], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 8e-50], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 8 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{t}, y, x\right)\\
\end{array}
\end{array}
if t < -1.7999999999999999e-13Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
Applied rewrites66.9%
if -1.7999999999999999e-13 < t < 8.00000000000000006e-50Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
if 8.00000000000000006e-50 < t Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z t)) y x))) (if (<= t -1.8e-13) t_1 (if (<= t 8e-50) (fma (/ z a) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -1.8e-13) {
tmp = t_1;
} else if (t <= 8e-50) {
tmp = fma((z / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -1.8e-13) tmp = t_1; elseif (t <= 8e-50) tmp = fma(Float64(z / a), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -1.8e-13], t$95$1, If[LessEqual[t, 8e-50], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 8 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.7999999999999999e-13 or 8.00000000000000006e-50 < t Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in a around 0
Applied rewrites66.9%
Applied rewrites66.9%
if -1.7999999999999999e-13 < t < 8.00000000000000006e-50Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ y t) (- t z) x))) (if (<= t -1.8e-13) t_1 (if (<= t 8e-50) (fma (/ z a) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y / t), (t - z), x);
double tmp;
if (t <= -1.8e-13) {
tmp = t_1;
} else if (t <= 8e-50) {
tmp = fma((z / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y / t), Float64(t - z), x) tmp = 0.0 if (t <= -1.8e-13) tmp = t_1; elseif (t <= 8e-50) tmp = fma(Float64(z / a), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / t), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.8e-13], t$95$1, If[LessEqual[t, 8e-50], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{t}, t - z, x\right)\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 8 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.7999999999999999e-13 or 8.00000000000000006e-50 < t Initial program 85.0%
Applied rewrites95.8%
Taylor expanded in t around inf
Applied rewrites65.4%
if -1.7999999999999999e-13 < t < 8.00000000000000006e-50Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (if (<= t -2.1e-11) (+ x y) (if (<= t 1.8e+20) (fma (/ z a) y x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -2.1e-11) {
tmp = x + y;
} else if (t <= 1.8e+20) {
tmp = fma((z / a), y, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -2.1e-11) tmp = Float64(x + y); elseif (t <= 1.8e+20) tmp = fma(Float64(z / a), y, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.1e-11], N[(x + y), $MachinePrecision], If[LessEqual[t, 1.8e+20], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.1 \cdot 10^{-11}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 1.8 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if t < -2.0999999999999999e-11 or 1.8e20 < t Initial program 85.0%
Taylor expanded in t around inf
Applied rewrites60.1%
if -2.0999999999999999e-11 < t < 1.8e20Initial program 85.0%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.12e-264) (+ x y) (if (<= t 8.5e-107) (/ (* y z) a) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.12e-264) {
tmp = x + y;
} else if (t <= 8.5e-107) {
tmp = (y * z) / a;
} else {
tmp = x + y;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, 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 (t <= (-1.12d-264)) then
tmp = x + y
else if (t <= 8.5d-107) then
tmp = (y * z) / a
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.12e-264) {
tmp = x + y;
} else if (t <= 8.5e-107) {
tmp = (y * z) / a;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -1.12e-264: tmp = x + y elif t <= 8.5e-107: tmp = (y * z) / a else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.12e-264) tmp = Float64(x + y); elseif (t <= 8.5e-107) tmp = Float64(Float64(y * z) / a); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -1.12e-264) tmp = x + y; elseif (t <= 8.5e-107) tmp = (y * z) / a; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.12e-264], N[(x + y), $MachinePrecision], If[LessEqual[t, 8.5e-107], N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.12 \cdot 10^{-264}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 8.5 \cdot 10^{-107}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if t < -1.12000000000000009e-264 or 8.49999999999999956e-107 < t Initial program 85.0%
Taylor expanded in t around inf
Applied rewrites60.1%
if -1.12000000000000009e-264 < t < 8.49999999999999956e-107Initial program 85.0%
Taylor expanded in z around inf
Applied rewrites26.4%
Taylor expanded in t around 0
Applied rewrites18.6%
(FPCore (x y z t a) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a) {
return x + 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 = x + y
end function
public static double code(double x, double y, double z, double t, double a) {
return x + y;
}
def code(x, y, z, t, a): return x + y
function code(x, y, z, t, a) return Float64(x + y) end
function tmp = code(x, y, z, t, a) tmp = x + y; end
code[x_, y_, z_, t_, a_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 85.0%
Taylor expanded in t around inf
Applied rewrites60.1%
(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.0%
Taylor expanded in t around inf
Applied rewrites60.1%
Taylor expanded in x around 0
Applied rewrites18.8%
herbie shell --seed 2025153
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
:precision binary64
(+ x (/ (* y (- z t)) (- a t))))