
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / 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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
x - \frac{y \cdot \left(z - t\right)}{a}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / 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)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x - ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x - ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
x - \frac{y \cdot \left(z - t\right)}{a}
(FPCore (x y z t a) :precision binary64 (fma (/ y a) (- t z) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / a), (t - z), x);
}
function code(x, y, z, t, a) return fma(Float64(y / a), Float64(t - z), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(\frac{y}{a}, t - z, x\right)
Initial program 93.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.3%
Applied rewrites97.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ y a) t x))) (if (<= t -4.05e+46) t_1 (if (<= t 3.5e-9) (- x (/ (* y z) a)) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y / a), t, x);
double tmp;
if (t <= -4.05e+46) {
tmp = t_1;
} else if (t <= 3.5e-9) {
tmp = x - ((y * z) / a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y / a), t, x) tmp = 0.0 if (t <= -4.05e+46) tmp = t_1; elseif (t <= 3.5e-9) tmp = Float64(x - Float64(Float64(y * z) / a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t, -4.05e+46], t$95$1, If[LessEqual[t, 3.5e-9], N[(x - N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{if}\;t \leq -4.05 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3.5 \cdot 10^{-9}:\\
\;\;\;\;x - \frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -4.05000000000000024e46 or 3.4999999999999999e-9 < t Initial program 93.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.3%
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites70.9%
if -4.05000000000000024e46 < t < 3.4999999999999999e-9Initial program 93.0%
Taylor expanded in z around inf
lower-*.f6468.2%
Applied rewrites68.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (* y (- z t)) a)))
(if (<= t_1 -5e+239)
(* (/ (- t z) a) y)
(if (<= t_1 200000000.0) (fma (/ y a) t x) (* (/ y a) (- t z))))))double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double tmp;
if (t_1 <= -5e+239) {
tmp = ((t - z) / a) * y;
} else if (t_1 <= 200000000.0) {
tmp = fma((y / a), t, x);
} else {
tmp = (y / a) * (t - z);
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) tmp = 0.0 if (t_1 <= -5e+239) tmp = Float64(Float64(Float64(t - z) / a) * y); elseif (t_1 <= 200000000.0) tmp = fma(Float64(y / a), t, x); else tmp = Float64(Float64(y / a) * Float64(t - z)); end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+239], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 200000000.0], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+239}:\\
\;\;\;\;\frac{t - z}{a} \cdot y\\
\mathbf{elif}\;t\_1 \leq 200000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(t - z\right)\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000007e239Initial program 93.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6456.2%
Applied rewrites56.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6456.2%
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
lift-/.f6457.7%
Applied rewrites57.7%
if -5.00000000000000007e239 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2e8Initial program 93.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.3%
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites70.9%
if 2e8 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6456.2%
Applied rewrites56.2%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6460.2%
Applied rewrites60.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) (- t z)))) (if (<= t_1 -5e+239) t_2 (if (<= t_1 200000000.0) (fma (/ y a) t x) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y / a) * (t - z);
double tmp;
if (t_1 <= -5e+239) {
tmp = t_2;
} else if (t_1 <= 200000000.0) {
tmp = fma((y / a), t, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(y / a) * Float64(t - z)) tmp = 0.0 if (t_1 <= -5e+239) tmp = t_2; elseif (t_1 <= 200000000.0) tmp = fma(Float64(y / a), t, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+239], t$95$2, If[LessEqual[t$95$1, 200000000.0], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y}{a} \cdot \left(t - z\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+239}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 200000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000007e239 or 2e8 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6456.2%
Applied rewrites56.2%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
sub-divN/A
lift--.f64N/A
associate-/l*N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6460.2%
Applied rewrites60.2%
if -5.00000000000000007e239 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2e8Initial program 93.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.3%
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites70.9%
(FPCore (x y z t a) :precision binary64 (fma (/ y a) t x))
double code(double x, double y, double z, double t, double a) {
return fma((y / a), t, x);
}
function code(x, y, z, t, a) return fma(Float64(y / a), t, x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision]
\mathsf{fma}\left(\frac{y}{a}, t, x\right)
Initial program 93.0%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
*-commutativeN/A
lower-fma.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lower--.f6497.3%
Applied rewrites97.3%
Taylor expanded in z around 0
Applied rewrites70.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ y a) t))) (if (<= t_1 -2e+119) t_2 (if (<= t_1 2e+44) x t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -2e+119) {
tmp = t_2;
} else if (t_1 <= 2e+44) {
tmp = x;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = (y / a) * t
if (t_1 <= (-2d+119)) then
tmp = t_2
else if (t_1 <= 2d+44) then
tmp = x
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (y / a) * t;
double tmp;
if (t_1 <= -2e+119) {
tmp = t_2;
} else if (t_1 <= 2e+44) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (y / a) * t tmp = 0 if t_1 <= -2e+119: tmp = t_2 elif t_1 <= 2e+44: tmp = x else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(y / a) * t) tmp = 0.0 if (t_1 <= -2e+119) tmp = t_2; elseif (t_1 <= 2e+44) tmp = x; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = (y / a) * t; tmp = 0.0; if (t_1 <= -2e+119) tmp = t_2; elseif (t_1 <= 2e+44) tmp = x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / a), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+119], t$95$2, If[LessEqual[t$95$1, 2e+44], x, t$95$2]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{y}{a} \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+119}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+44}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -1.99999999999999989e119 or 2.0000000000000002e44 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.0%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6431.5%
Applied rewrites31.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6434.4%
Applied rewrites34.4%
if -1.99999999999999989e119 < (/.f64 (*.f64 y (-.f64 z t)) a) < 2.0000000000000002e44Initial program 93.0%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6431.5%
Applied rewrites31.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6434.4%
Applied rewrites34.4%
Taylor expanded in x around inf
Applied rewrites39.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (* y (- z t)) a)) (t_2 (* (/ t a) y))) (if (<= t_1 -5e+239) t_2 (if (<= t_1 1e+167) x t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (t / a) * y;
double tmp;
if (t_1 <= -5e+239) {
tmp = t_2;
} else if (t_1 <= 1e+167) {
tmp = x;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y * (z - t)) / a
t_2 = (t / a) * y
if (t_1 <= (-5d+239)) then
tmp = t_2
else if (t_1 <= 1d+167) then
tmp = x
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y * (z - t)) / a;
double t_2 = (t / a) * y;
double tmp;
if (t_1 <= -5e+239) {
tmp = t_2;
} else if (t_1 <= 1e+167) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y * (z - t)) / a t_2 = (t / a) * y tmp = 0 if t_1 <= -5e+239: tmp = t_2 elif t_1 <= 1e+167: tmp = x else: tmp = t_2 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y * Float64(z - t)) / a) t_2 = Float64(Float64(t / a) * y) tmp = 0.0 if (t_1 <= -5e+239) tmp = t_2; elseif (t_1 <= 1e+167) tmp = x; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y * (z - t)) / a; t_2 = (t / a) * y; tmp = 0.0; if (t_1 <= -5e+239) tmp = t_2; elseif (t_1 <= 1e+167) tmp = x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+239], t$95$2, If[LessEqual[t$95$1, 1e+167], x, t$95$2]]]]
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a}\\
t_2 := \frac{t}{a} \cdot y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+239}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{+167}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) a) < -5.00000000000000007e239 or 1e167 < (/.f64 (*.f64 y (-.f64 z t)) a) Initial program 93.0%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6431.5%
Applied rewrites31.5%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6432.0%
Applied rewrites32.0%
if -5.00000000000000007e239 < (/.f64 (*.f64 y (-.f64 z t)) a) < 1e167Initial program 93.0%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6431.5%
Applied rewrites31.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6434.4%
Applied rewrites34.4%
Taylor expanded in x around inf
Applied rewrites39.0%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return 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 = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
x
Initial program 93.0%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f6431.5%
Applied rewrites31.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6434.4%
Applied rewrites34.4%
Taylor expanded in x around inf
Applied rewrites39.0%
herbie shell --seed 2025188
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, F"
:precision binary64
(- x (/ (* y (- z t)) a)))