
(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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{a - t}
\end{array}
Herbie found 9 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(y * Float64(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[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) (- a t)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (a - t)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(a - t)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)
\end{array}
Initial program 98.1%
Applied rewrites98.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- a t))) (t_2 (fma (/ z (- a t)) y x)))
(if (<= t_1 -5e+35)
t_2
(if (<= t_1 0.4) (fma (/ (- z t) a) y x) (if (<= t_1 2.0) (+ x y) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (a - t);
double t_2 = fma((z / (a - t)), y, x);
double tmp;
if (t_1 <= -5e+35) {
tmp = t_2;
} else if (t_1 <= 0.4) {
tmp = fma(((z - t) / a), y, x);
} else if (t_1 <= 2.0) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(a - t)) t_2 = fma(Float64(z / Float64(a - t)), y, x) tmp = 0.0 if (t_1 <= -5e+35) tmp = t_2; elseif (t_1 <= 0.4) tmp = fma(Float64(Float64(z - t) / a), y, x); elseif (t_1 <= 2.0) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+35], t$95$2, If[LessEqual[t$95$1, 0.4], N[(N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(x + y), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{a - t}\\
t_2 := \mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+35}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.4:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 a t)) < -5.00000000000000021e35 or 2 < (/.f64 (-.f64 z t) (-.f64 a t)) Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in t around inf
Applied rewrites94.9%
Taylor expanded in z around inf
Applied rewrites76.6%
if -5.00000000000000021e35 < (/.f64 (-.f64 z t) (-.f64 a t)) < 0.40000000000000002Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in t around 0
Applied rewrites59.8%
if 0.40000000000000002 < (/.f64 (-.f64 z t) (-.f64 a t)) < 2Initial program 98.1%
Taylor expanded in t around inf
Applied rewrites60.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 98.1%
Applied rewrites95.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- a t))) (t_2 (fma (/ z (- a t)) y x))) (if (<= t_1 2e-11) t_2 (if (<= t_1 2.0) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (a - t);
double t_2 = fma((z / (a - t)), y, x);
double tmp;
if (t_1 <= 2e-11) {
tmp = t_2;
} else if (t_1 <= 2.0) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(a - t)) t_2 = fma(Float64(z / Float64(a - t)), y, x) tmp = 0.0 if (t_1 <= 2e-11) tmp = t_2; elseif (t_1 <= 2.0) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-11], t$95$2, If[LessEqual[t$95$1, 2.0], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{a - t}\\
t_2 := \mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 a t)) < 1.99999999999999988e-11 or 2 < (/.f64 (-.f64 z t) (-.f64 a t)) Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in t around inf
Applied rewrites94.9%
Taylor expanded in z around inf
Applied rewrites76.6%
if 1.99999999999999988e-11 < (/.f64 (-.f64 z t) (-.f64 a t)) < 2Initial program 98.1%
Taylor expanded in t around inf
Applied rewrites60.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z a) y x))
(t_2 (/ (- z t) (- a t)))
(t_3 (/ (* y z) (- a t))))
(if (<= t_2 -5e+116)
t_3
(if (<= t_2 2e-11)
t_1
(if (<= t_2 2.0) (+ x y) (if (<= t_2 5e+166) t_1 t_3))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / a), y, x);
double t_2 = (z - t) / (a - t);
double t_3 = (y * z) / (a - t);
double tmp;
if (t_2 <= -5e+116) {
tmp = t_3;
} else if (t_2 <= 2e-11) {
tmp = t_1;
} else if (t_2 <= 2.0) {
tmp = x + y;
} else if (t_2 <= 5e+166) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / a), y, x) t_2 = Float64(Float64(z - t) / Float64(a - t)) t_3 = Float64(Float64(y * z) / Float64(a - t)) tmp = 0.0 if (t_2 <= -5e+116) tmp = t_3; elseif (t_2 <= 2e-11) tmp = t_1; elseif (t_2 <= 2.0) tmp = Float64(x + y); elseif (t_2 <= 5e+166) tmp = t_1; else tmp = t_3; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+116], t$95$3, If[LessEqual[t$95$2, 2e-11], t$95$1, If[LessEqual[t$95$2, 2.0], N[(x + y), $MachinePrecision], If[LessEqual[t$95$2, 5e+166], t$95$1, t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
t_2 := \frac{z - t}{a - t}\\
t_3 := \frac{y \cdot z}{a - t}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+116}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+166}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 a t)) < -5.00000000000000025e116 or 5.0000000000000002e166 < (/.f64 (-.f64 z t) (-.f64 a t)) Initial program 98.1%
Taylor expanded in z around inf
Applied rewrites26.4%
if -5.00000000000000025e116 < (/.f64 (-.f64 z t) (-.f64 a t)) < 1.99999999999999988e-11 or 2 < (/.f64 (-.f64 z t) (-.f64 a t)) < 5.0000000000000002e166Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in t around inf
Applied rewrites94.9%
Taylor expanded in z around inf
Applied rewrites76.6%
Taylor expanded in t around 0
Applied rewrites61.5%
if 1.99999999999999988e-11 < (/.f64 (-.f64 z t) (-.f64 a t)) < 2Initial program 98.1%
Taylor expanded in t around inf
Applied rewrites60.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- a t))) (t_2 (fma (/ z a) y x))) (if (<= t_1 2e-11) t_2 (if (<= t_1 2.0) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (a - t);
double t_2 = fma((z / a), y, x);
double tmp;
if (t_1 <= 2e-11) {
tmp = t_2;
} else if (t_1 <= 2.0) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(a - t)) t_2 = fma(Float64(z / a), y, x) tmp = 0.0 if (t_1 <= 2e-11) tmp = t_2; elseif (t_1 <= 2.0) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-11], t$95$2, If[LessEqual[t$95$1, 2.0], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{a - t}\\
t_2 := \mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 a t)) < 1.99999999999999988e-11 or 2 < (/.f64 (-.f64 z t) (-.f64 a t)) Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in t around inf
Applied rewrites94.9%
Taylor expanded in z around inf
Applied rewrites76.6%
Taylor expanded in t around 0
Applied rewrites61.5%
if 1.99999999999999988e-11 < (/.f64 (-.f64 z t) (-.f64 a t)) < 2Initial program 98.1%
Taylor expanded in t around inf
Applied rewrites60.1%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y z) a)) (t_2 (+ x (* y (/ (- z t) (- a t)))))) (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+307) (+ x y) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * z) / a;
double t_2 = x + (y * ((z - t) / (a - t)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * z) / a;
double t_2 = x + (y * ((z - t) / (a - t)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+307) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * z) / a t_2 = x + (y * ((z - t) / (a - t))) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+307: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * z) / a) t_2 = Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+307) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * z) / a; t_2 = x + (y * ((z - t) / (a - t))); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 2e+307) tmp = x + y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+307], N[(x + y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y \cdot z}{a}\\
t_2 := x + y \cdot \frac{z - t}{a - t}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t)))) < -inf.0 or 1.99999999999999997e307 < (+.f64 x (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t)))) Initial program 98.1%
Applied rewrites98.1%
Taylor expanded in x around 0
Applied rewrites39.3%
Taylor expanded in t around 0
Applied rewrites18.6%
if -inf.0 < (+.f64 x (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t)))) < 1.99999999999999997e307Initial program 98.1%
Taylor expanded in t around inf
Applied rewrites60.1%
(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 98.1%
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 98.1%
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:renderAxisLine from plot-0.2.3.4, B"
:precision binary64
(+ x (* y (/ (- z t) (- a t)))))