
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma d d (* c c)))
(t_1 (fma (/ (- d) t_0) a (* (/ b t_0) c)))
(t_2 (/ (- b (* (/ a c) d)) c)))
(if (<= c -4.9e+92)
t_2
(if (<= c -1.8e-102)
t_1
(if (<= c 4.8e-108)
(/ (- (* (/ c d) b) a) d)
(if (<= c 5.8e+117) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(d, d, (c * c));
double t_1 = fma((-d / t_0), a, ((b / t_0) * c));
double t_2 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4.9e+92) {
tmp = t_2;
} else if (c <= -1.8e-102) {
tmp = t_1;
} else if (c <= 4.8e-108) {
tmp = (((c / d) * b) - a) / d;
} else if (c <= 5.8e+117) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(d, d, Float64(c * c)) t_1 = fma(Float64(Float64(-d) / t_0), a, Float64(Float64(b / t_0) * c)) t_2 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -4.9e+92) tmp = t_2; elseif (c <= -1.8e-102) tmp = t_1; elseif (c <= 4.8e-108) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); elseif (c <= 5.8e+117) tmp = t_1; else tmp = t_2; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-d) / t$95$0), $MachinePrecision] * a + N[(N[(b / t$95$0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.9e+92], t$95$2, If[LessEqual[c, -1.8e-102], t$95$1, If[LessEqual[c, 4.8e-108], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.8e+117], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
t_1 := \mathsf{fma}\left(\frac{-d}{t\_0}, a, \frac{b}{t\_0} \cdot c\right)\\
t_2 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -4.9 \cdot 10^{+92}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;c \leq -1.8 \cdot 10^{-102}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{-108}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if c < -4.9000000000000002e92 or 5.80000000000000055e117 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4.9000000000000002e92 < c < -1.8e-102 or 4.80000000000000034e-108 < c < 5.80000000000000055e117Initial program 61.5%
lift-/.f64N/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
div-addN/A
frac-2negN/A
distribute-neg-frac2N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
distribute-neg-frac2N/A
lower-fma.f64N/A
Applied rewrites61.8%
if -1.8e-102 < c < 4.80000000000000034e-108Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)) (t_1 (fma d d (* c c))))
(if (<= c -4e+21)
t_0
(if (<= c 1.9e-82)
(/ (- (* (/ c d) b) a) d)
(if (<= c 5.8e+141) (fma (/ c t_1) b (* (/ a t_1) (- d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double t_1 = fma(d, d, (c * c));
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.9e-82) {
tmp = (((c / d) * b) - a) / d;
} else if (c <= 5.8e+141) {
tmp = fma((c / t_1), b, ((a / t_1) * -d));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) t_1 = fma(d, d, Float64(c * c)) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 1.9e-82) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); elseif (c <= 5.8e+141) tmp = fma(Float64(c / t_1), b, Float64(Float64(a / t_1) * Float64(-d))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$1 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 1.9e-82], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 5.8e+141], N[(N[(c / t$95$1), $MachinePrecision] * b + N[(N[(a / t$95$1), $MachinePrecision] * (-d)), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+141}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{t\_1}, b, \frac{a}{t\_1} \cdot \left(-d\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 5.80000000000000013e141 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 1.9000000000000001e-82Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
if 1.9000000000000001e-82 < c < 5.80000000000000013e141Initial program 61.5%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
div-addN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites61.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)) (t_1 (fma d d (* c c))))
(if (<= c -4e+21)
t_0
(if (<= c 1.9e-82)
(/ (- (* (/ c d) b) a) d)
(if (<= c 1e+138) (- (* (/ b t_1) c) (* (/ a t_1) d)) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double t_1 = fma(d, d, (c * c));
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.9e-82) {
tmp = (((c / d) * b) - a) / d;
} else if (c <= 1e+138) {
tmp = ((b / t_1) * c) - ((a / t_1) * d);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) t_1 = fma(d, d, Float64(c * c)) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 1.9e-82) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); elseif (c <= 1e+138) tmp = Float64(Float64(Float64(b / t_1) * c) - Float64(Float64(a / t_1) * d)); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, Block[{t$95$1 = N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 1.9e-82], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1e+138], N[(N[(N[(b / t$95$1), $MachinePrecision] * c), $MachinePrecision] - N[(N[(a / t$95$1), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
t_1 := \mathsf{fma}\left(d, d, c \cdot c\right)\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{elif}\;c \leq 10^{+138}:\\
\;\;\;\;\frac{b}{t\_1} \cdot c - \frac{a}{t\_1} \cdot d\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 1e138 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 1.9000000000000001e-82Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
if 1.9000000000000001e-82 < c < 1e138Initial program 61.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lower--.f64N/A
Applied rewrites58.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)))
(if (<= c -4e+21)
t_0
(if (<= c 2.4e-109)
(/ (- (* (/ c d) b) a) d)
(if (<= c 1.2e+48)
(* (/ 1.0 (fma d d (* c c))) (- (* c b) (* d a)))
t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 2.4e-109) {
tmp = (((c / d) * b) - a) / d;
} else if (c <= 1.2e+48) {
tmp = (1.0 / fma(d, d, (c * c))) * ((c * b) - (d * a));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 2.4e-109) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); elseif (c <= 1.2e+48) tmp = Float64(Float64(1.0 / fma(d, d, Float64(c * c))) * Float64(Float64(c * b) - Float64(d * a))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 2.4e-109], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.2e+48], N[(N[(1.0 / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{+48}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(d, d, c \cdot c\right)} \cdot \left(c \cdot b - d \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 1.2000000000000001e48 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 2.39999999999999989e-109Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
if 2.39999999999999989e-109 < c < 1.2000000000000001e48Initial program 61.5%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites61.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* (/ a c) d)) c)))
(if (<= c -4e+21)
t_0
(if (<= c 2.4e-109)
(/ (- (* (/ c d) b) a) d)
(if (<= c 1.2e+48) (/ (- (* c b) (* d a)) (fma d d (* c c))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 2.4e-109) {
tmp = (((c / d) * b) - a) / d;
} else if (c <= 1.2e+48) {
tmp = ((c * b) - (d * a)) / fma(d, d, (c * c));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 2.4e-109) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); elseif (c <= 1.2e+48) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(d, d, Float64(c * c))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 2.4e-109], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 1.2e+48], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 2.4 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{elif}\;c \leq 1.2 \cdot 10^{+48}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 1.2000000000000001e48 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 2.39999999999999989e-109Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
if 2.39999999999999989e-109 < c < 1.2000000000000001e48Initial program 61.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.5
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
sqr-abs-revN/A
sqr-neg-revN/A
fp-cancel-sign-sub-invN/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
distribute-lft-neg-inN/A
sqr-neg-revN/A
sqr-abs-revN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.5
Applied rewrites61.5%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (* (/ a c) d)) c))) (if (<= c -4e+21) t_0 (if (<= c 1.32e-12) (/ (- (* (/ c d) b) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.32e-12) {
tmp = (((c / d) * b) - a) / d;
} else {
tmp = t_0;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - ((a / c) * d)) / c
if (c <= (-4d+21)) then
tmp = t_0
else if (c <= 1.32d-12) then
tmp = (((c / d) * b) - a) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.32e-12) {
tmp = (((c / d) * b) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((a / c) * d)) / c tmp = 0 if c <= -4e+21: tmp = t_0 elif c <= 1.32e-12: tmp = (((c / d) * b) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 1.32e-12) tmp = Float64(Float64(Float64(Float64(c / d) * b) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((a / c) * d)) / c; tmp = 0.0; if (c <= -4e+21) tmp = t_0; elseif (c <= 1.32e-12) tmp = (((c / d) * b) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 1.32e-12], N[(N[(N[(N[(c / d), $MachinePrecision] * b), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.32 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{c}{d} \cdot b - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 1.32e-12 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 1.32e-12Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6454.4
Applied rewrites54.4%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- b (* (/ a c) d)) c))) (if (<= c -4e+21) t_0 (if (<= c 1.32e-12) (/ (- (* (/ b d) c) a) d) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.32e-12) {
tmp = (((b / d) * c) - a) / d;
} else {
tmp = t_0;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b - ((a / c) * d)) / c
if (c <= (-4d+21)) then
tmp = t_0
else if (c <= 1.32d-12) then
tmp = (((b / d) * c) - a) / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b - ((a / c) * d)) / c;
double tmp;
if (c <= -4e+21) {
tmp = t_0;
} else if (c <= 1.32e-12) {
tmp = (((b / d) * c) - a) / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - ((a / c) * d)) / c tmp = 0 if c <= -4e+21: tmp = t_0 elif c <= 1.32e-12: tmp = (((b / d) * c) - a) / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(Float64(a / c) * d)) / c) tmp = 0.0 if (c <= -4e+21) tmp = t_0; elseif (c <= 1.32e-12) tmp = Float64(Float64(Float64(Float64(b / d) * c) - a) / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - ((a / c) * d)) / c; tmp = 0.0; if (c <= -4e+21) tmp = t_0; elseif (c <= 1.32e-12) tmp = (((b / d) * c) - a) / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4e+21], t$95$0, If[LessEqual[c, 1.32e-12], N[(N[(N[(N[(b / d), $MachinePrecision] * c), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq 1.32 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{b}{d} \cdot c - a}{d}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4e21 or 1.32e-12 < c Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if -4e21 < c < 1.32e-12Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
frac-2negN/A
lift-neg.f64N/A
lower-/.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
*-lft-identity50.4
Applied rewrites50.4%
lift-fma.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
sub-flip-reverseN/A
lift-/.f64N/A
associate-*r/N/A
sub-divN/A
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6453.6
Applied rewrites53.6%
(FPCore (a b c d) :precision binary64 (if (<= d -5.8e+50) (/ 1.0 (/ d (- a))) (if (<= d 2e+45) (/ (- b (/ (* a d) c)) c) (/ (- a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.8e+50) {
tmp = 1.0 / (d / -a);
} else if (d <= 2e+45) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = -a / d;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-5.8d+50)) then
tmp = 1.0d0 / (d / -a)
else if (d <= 2d+45) then
tmp = (b - ((a * d) / c)) / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.8e+50) {
tmp = 1.0 / (d / -a);
} else if (d <= 2e+45) {
tmp = (b - ((a * d) / c)) / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.8e+50: tmp = 1.0 / (d / -a) elif d <= 2e+45: tmp = (b - ((a * d) / c)) / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.8e+50) tmp = Float64(1.0 / Float64(d / Float64(-a))); elseif (d <= 2e+45) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.8e+50) tmp = 1.0 / (d / -a); elseif (d <= 2e+45) tmp = (b - ((a * d) / c)) / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.8e+50], N[(1.0 / N[(d / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+45], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{+50}:\\
\;\;\;\;\frac{1}{\frac{d}{-a}}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+45}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -5.8e50Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6442.2
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.2
Applied rewrites42.2%
if -5.8e50 < d < 1.9999999999999999e45Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
if 1.9999999999999999e45 < d Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.4
Applied rewrites42.4%
(FPCore (a b c d) :precision binary64 (if (<= d -1.45e+51) (/ 1.0 (/ d (- a))) (if (<= d 2e+45) (/ (- b (* (/ a c) d)) c) (/ (- a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.45e+51) {
tmp = 1.0 / (d / -a);
} else if (d <= 2e+45) {
tmp = (b - ((a / c) * d)) / c;
} else {
tmp = -a / d;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1.45d+51)) then
tmp = 1.0d0 / (d / -a)
else if (d <= 2d+45) then
tmp = (b - ((a / c) * d)) / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.45e+51) {
tmp = 1.0 / (d / -a);
} else if (d <= 2e+45) {
tmp = (b - ((a / c) * d)) / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.45e+51: tmp = 1.0 / (d / -a) elif d <= 2e+45: tmp = (b - ((a / c) * d)) / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.45e+51) tmp = Float64(1.0 / Float64(d / Float64(-a))); elseif (d <= 2e+45) tmp = Float64(Float64(b - Float64(Float64(a / c) * d)) / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.45e+51) tmp = 1.0 / (d / -a); elseif (d <= 2e+45) tmp = (b - ((a / c) * d)) / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.45e+51], N[(1.0 / N[(d / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2e+45], N[(N[(b - N[(N[(a / c), $MachinePrecision] * d), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.45 \cdot 10^{+51}:\\
\;\;\;\;\frac{1}{\frac{d}{-a}}\\
\mathbf{elif}\;d \leq 2 \cdot 10^{+45}:\\
\;\;\;\;\frac{b - \frac{a}{c} \cdot d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -1.4499999999999999e51Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6442.2
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.2
Applied rewrites42.2%
if -1.4499999999999999e51 < d < 1.9999999999999999e45Initial program 61.5%
Taylor expanded in c around inf
lower-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6452.0
Applied rewrites52.0%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
distribute-frac-neg2N/A
frac-2negN/A
lift-/.f6452.0
Applied rewrites52.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6453.5
Applied rewrites53.5%
if 1.9999999999999999e45 < d Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.4
Applied rewrites42.4%
(FPCore (a b c d) :precision binary64 (if (<= d -5.8e+50) (/ 1.0 (/ d (- a))) (if (<= d 9.5e+18) (/ b c) (/ (- a) d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.8e+50) {
tmp = 1.0 / (d / -a);
} else if (d <= 9.5e+18) {
tmp = b / c;
} else {
tmp = -a / d;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-5.8d+50)) then
tmp = 1.0d0 / (d / -a)
else if (d <= 9.5d+18) then
tmp = b / c
else
tmp = -a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -5.8e+50) {
tmp = 1.0 / (d / -a);
} else if (d <= 9.5e+18) {
tmp = b / c;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -5.8e+50: tmp = 1.0 / (d / -a) elif d <= 9.5e+18: tmp = b / c else: tmp = -a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -5.8e+50) tmp = Float64(1.0 / Float64(d / Float64(-a))); elseif (d <= 9.5e+18) tmp = Float64(b / c); else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -5.8e+50) tmp = 1.0 / (d / -a); elseif (d <= 9.5e+18) tmp = b / c; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -5.8e+50], N[(1.0 / N[(d / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 9.5e+18], N[(b / c), $MachinePrecision], N[((-a) / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{+50}:\\
\;\;\;\;\frac{1}{\frac{d}{-a}}\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{+18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -5.8e50Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6442.2
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.2
Applied rewrites42.2%
if -5.8e50 < d < 9.5e18Initial program 61.5%
Taylor expanded in c around inf
lower-/.f6442.6
Applied rewrites42.6%
if 9.5e18 < d Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.4
Applied rewrites42.4%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- a) d))) (if (<= d -2.3e+38) t_0 (if (<= d 9.5e+18) (/ b c) t_0))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -2.3e+38) {
tmp = t_0;
} else if (d <= 9.5e+18) {
tmp = b / c;
} else {
tmp = t_0;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-2.3d+38)) then
tmp = t_0
else if (d <= 9.5d+18) then
tmp = b / c
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -2.3e+38) {
tmp = t_0;
} else if (d <= 9.5e+18) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -2.3e+38: tmp = t_0 elif d <= 9.5e+18: tmp = b / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -2.3e+38) tmp = t_0; elseif (d <= 9.5e+18) tmp = Float64(b / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -2.3e+38) tmp = t_0; elseif (d <= 9.5e+18) tmp = b / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -2.3e+38], t$95$0, If[LessEqual[d, 9.5e+18], N[(b / c), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -2.3 \cdot 10^{+38}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 9.5 \cdot 10^{+18}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -2.3000000000000001e38 or 9.5e18 < d Initial program 61.5%
Taylor expanded in d around inf
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f6452.3
Applied rewrites52.3%
Taylor expanded in a around inf
lower-*.f6442.4
Applied rewrites42.4%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6442.4
Applied rewrites42.4%
if -2.3000000000000001e38 < d < 9.5e18Initial program 61.5%
Taylor expanded in c around inf
lower-/.f6442.6
Applied rewrites42.6%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 61.5%
Taylor expanded in c around inf
lower-/.f6442.6
Applied rewrites42.6%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
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(a, b, c, d)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2025154
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform c (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))