
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * 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(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * 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(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5e+152)
(/ (- b) a)
(if (<= b -1.7e-245)
(+ (/ (sqrt (fma (* c -4.0) a (* b b))) (+ a a)) (* (/ b a) -0.5))
(if (<= b -4.3e-270)
(/ (sqrt (- c)) (sqrt a))
(if (<= b 4.8e+128)
(/
(/ (* (* 4.0 a) c) (+ b (sqrt (fma (* -4.0 a) c (* b b)))))
(- (* 2.0 a)))
(/ (- c) b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+152) {
tmp = -b / a;
} else if (b <= -1.7e-245) {
tmp = (sqrt(fma((c * -4.0), a, (b * b))) / (a + a)) + ((b / a) * -0.5);
} else if (b <= -4.3e-270) {
tmp = sqrt(-c) / sqrt(a);
} else if (b <= 4.8e+128) {
tmp = (((4.0 * a) * c) / (b + sqrt(fma((-4.0 * a), c, (b * b))))) / -(2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+152) tmp = Float64(Float64(-b) / a); elseif (b <= -1.7e-245) tmp = Float64(Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) / Float64(a + a)) + Float64(Float64(b / a) * -0.5)); elseif (b <= -4.3e-270) tmp = Float64(sqrt(Float64(-c)) / sqrt(a)); elseif (b <= 4.8e+128) tmp = Float64(Float64(Float64(Float64(4.0 * a) * c) / Float64(b + sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))))) / Float64(-Float64(2.0 * a))); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+152], N[((-b) / a), $MachinePrecision], If[LessEqual[b, -1.7e-245], N[(N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -4.3e-270], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.8e+128], N[(N[(N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision] / N[(b + N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[(2.0 * a), $MachinePrecision])), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+152}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq -1.7 \cdot 10^{-245}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)}}{a + a} + \frac{b}{a} \cdot -0.5\\
\mathbf{elif}\;b \leq -4.3 \cdot 10^{-270}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{b + \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}}}{-2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5e152Initial program 39.3%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6498.9
Applied rewrites98.9%
if -5e152 < b < -1.7e-245Initial program 88.1%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites88.1%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
div-addN/A
lower-+.f64N/A
Applied rewrites88.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6488.2
Applied rewrites88.2%
lift-*.f64N/A
count-2-revN/A
lift-+.f6488.2
Applied rewrites88.2%
if -1.7e-245 < b < -4.3000000000000002e-270Initial program 16.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites13.4%
Taylor expanded in a around -inf
Applied rewrites75.3%
lift-sqrt.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-neg.f64N/A
lower-sqrt.f6486.6
Applied rewrites86.6%
if -4.3000000000000002e-270 < b < 4.8000000000000004e128Initial program 47.4%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites47.1%
Taylor expanded in a around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f6480.8
Applied rewrites80.8%
if 4.8000000000000004e128 < b Initial program 7.4%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6496.4
Applied rewrites96.4%
Final simplification90.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+152)
(/ (- b) a)
(if (<= b 5.1e-87)
(+ (/ (sqrt (fma (* c -4.0) a (* b b))) (+ a a)) (* (/ b a) -0.5))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+152) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = (sqrt(fma((c * -4.0), a, (b * b))) / (a + a)) + ((b / a) * -0.5);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+152) tmp = Float64(Float64(-b) / a); elseif (b <= 5.1e-87) tmp = Float64(Float64(sqrt(fma(Float64(c * -4.0), a, Float64(b * b))) / Float64(a + a)) + Float64(Float64(b / a) * -0.5)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+152], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.1e-87], N[(N[(N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+152}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c \cdot -4, a, b \cdot b\right)}}{a + a} + \frac{b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5e152Initial program 39.3%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6498.9
Applied rewrites98.9%
if -5e152 < b < 5.10000000000000023e-87Initial program 78.5%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites78.5%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
div-addN/A
lower-+.f64N/A
Applied rewrites78.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6478.5
Applied rewrites78.5%
lift-*.f64N/A
count-2-revN/A
lift-+.f6478.5
Applied rewrites78.5%
if 5.10000000000000023e-87 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+152)
(/ (- b) a)
(if (<= b 5.1e-87)
(/ (- (sqrt (fma (* -4.0 a) c (* b b))) b) (+ a a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+152) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = (sqrt(fma((-4.0 * a), c, (b * b))) - b) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+152) tmp = Float64(Float64(-b) / a); elseif (b <= 5.1e-87) tmp = Float64(Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) - b) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+152], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.1e-87], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+152}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} - b}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5e152Initial program 39.3%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6498.9
Applied rewrites98.9%
if -5e152 < b < 5.10000000000000023e-87Initial program 78.5%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites78.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f6478.5
Applied rewrites78.5%
if 5.10000000000000023e-87 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.22e-57)
(/ (- b) a)
(if (<= b 5.1e-87)
(/ (+ (- b) (sqrt (* -4.0 (* c a)))) (+ a a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.22e-57) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = (-b + sqrt((-4.0 * (c * a)))) / (a + a);
} else {
tmp = -c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.22d-57)) then
tmp = -b / a
else if (b <= 5.1d-87) then
tmp = (-b + sqrt(((-4.0d0) * (c * a)))) / (a + a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.22e-57) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = (-b + Math.sqrt((-4.0 * (c * a)))) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.22e-57: tmp = -b / a elif b <= 5.1e-87: tmp = (-b + math.sqrt((-4.0 * (c * a)))) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.22e-57) tmp = Float64(Float64(-b) / a); elseif (b <= 5.1e-87) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-4.0 * Float64(c * a)))) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.22e-57) tmp = -b / a; elseif (b <= 5.1e-87) tmp = (-b + sqrt((-4.0 * (c * a)))) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.22e-57], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.1e-87], N[(N[((-b) + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.22 \cdot 10^{-57}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-87}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.2200000000000001e-57Initial program 61.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6492.3
Applied rewrites92.3%
if -1.2200000000000001e-57 < b < 5.10000000000000023e-87Initial program 65.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6461.3
Applied rewrites61.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f6461.3
Applied rewrites61.3%
if 5.10000000000000023e-87 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
(FPCore (a b c) :precision binary64 (if (<= b -4.5e-81) (/ (- b) a) (if (<= b 5.1e-87) (/ (sqrt (* (* c a) -4.0)) (+ a a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-81) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = sqrt(((c * a) * -4.0)) / (a + a);
} else {
tmp = -c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-4.5d-81)) then
tmp = -b / a
else if (b <= 5.1d-87) then
tmp = sqrt(((c * a) * (-4.0d0))) / (a + a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-81) {
tmp = -b / a;
} else if (b <= 5.1e-87) {
tmp = Math.sqrt(((c * a) * -4.0)) / (a + a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-81: tmp = -b / a elif b <= 5.1e-87: tmp = math.sqrt(((c * a) * -4.0)) / (a + a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-81) tmp = Float64(Float64(-b) / a); elseif (b <= 5.1e-87) tmp = Float64(sqrt(Float64(Float64(c * a) * -4.0)) / Float64(a + a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-81) tmp = -b / a; elseif (b <= 5.1e-87) tmp = sqrt(((c * a) * -4.0)) / (a + a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-81], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.1e-87], N[(N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-81}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-87}:\\
\;\;\;\;\frac{\sqrt{\left(c \cdot a\right) \cdot -4}}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.5e-81Initial program 62.8%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6491.4
Applied rewrites91.4%
if -4.5e-81 < b < 5.10000000000000023e-87Initial program 64.2%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites64.2%
lift-*.f64N/A
count-2-revN/A
lower-+.f6464.2
Applied rewrites64.2%
Taylor expanded in a around inf
*-commutativeN/A
sqrt-prodN/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6460.1
Applied rewrites60.1%
if 5.10000000000000023e-87 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
(FPCore (a b c) :precision binary64 (if (<= b -9.5e-166) (/ (- b) a) (if (<= b 6e-90) (/ (sqrt (- c)) (sqrt a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-166) {
tmp = -b / a;
} else if (b <= 6e-90) {
tmp = sqrt(-c) / sqrt(a);
} else {
tmp = -c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-9.5d-166)) then
tmp = -b / a
else if (b <= 6d-90) then
tmp = sqrt(-c) / sqrt(a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.5e-166) {
tmp = -b / a;
} else if (b <= 6e-90) {
tmp = Math.sqrt(-c) / Math.sqrt(a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.5e-166: tmp = -b / a elif b <= 6e-90: tmp = math.sqrt(-c) / math.sqrt(a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.5e-166) tmp = Float64(Float64(-b) / a); elseif (b <= 6e-90) tmp = Float64(sqrt(Float64(-c)) / sqrt(a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.5e-166) tmp = -b / a; elseif (b <= 6e-90) tmp = sqrt(-c) / sqrt(a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.5e-166], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 6e-90], N[(N[Sqrt[(-c)], $MachinePrecision] / N[Sqrt[a], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{-166}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{-c}}{\sqrt{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.50000000000000046e-166Initial program 63.5%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6485.6
Applied rewrites85.6%
if -9.50000000000000046e-166 < b < 6.00000000000000041e-90Initial program 62.8%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites61.3%
Taylor expanded in a around -inf
Applied rewrites45.7%
lift-sqrt.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-neg.f64N/A
lower-sqrt.f6450.6
Applied rewrites50.6%
if 6.00000000000000041e-90 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.4e-167) (/ (- b) a) (if (<= b 5.9e-90) (sqrt (/ (- c) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-167) {
tmp = -b / a;
} else if (b <= 5.9e-90) {
tmp = sqrt((-c / a));
} else {
tmp = -c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.4d-167)) then
tmp = -b / a
else if (b <= 5.9d-90) then
tmp = sqrt((-c / a))
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-167) {
tmp = -b / a;
} else if (b <= 5.9e-90) {
tmp = Math.sqrt((-c / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.4e-167: tmp = -b / a elif b <= 5.9e-90: tmp = math.sqrt((-c / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.4e-167) tmp = Float64(Float64(-b) / a); elseif (b <= 5.9e-90) tmp = sqrt(Float64(Float64(-c) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.4e-167) tmp = -b / a; elseif (b <= 5.9e-90) tmp = sqrt((-c / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.4e-167], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.9e-90], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.4 \cdot 10^{-167}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.9 \cdot 10^{-90}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.39999999999999993e-167Initial program 63.5%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6485.6
Applied rewrites85.6%
if -1.39999999999999993e-167 < b < 5.90000000000000004e-90Initial program 62.8%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip-+N/A
lower-/.f64N/A
Applied rewrites61.3%
Taylor expanded in a around -inf
Applied rewrites45.7%
if 5.90000000000000004e-90 < b Initial program 20.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6484.6
Applied rewrites84.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1d-310)) then
tmp = -b / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 62.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6471.0
Applied rewrites71.0%
if -9.999999999999969e-311 < b Initial program 28.5%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6472.2
Applied rewrites72.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-49) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-49) {
tmp = -b / a;
} else {
tmp = 0.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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.7d-49) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-49) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-49: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-49) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.7e-49) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-49], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-49}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < 1.70000000000000002e-49Initial program 62.2%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lift-neg.f6459.1
Applied rewrites59.1%
if 1.70000000000000002e-49 < b Initial program 19.4%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites19.4%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
div-addN/A
lower-+.f64N/A
Applied rewrites17.9%
Taylor expanded in a around 0
associate-*l*N/A
*-commutativeN/A
count-2-revN/A
count-2-revN/A
div-addN/A
div-addN/A
associate-*r/N/A
associate-*r/N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f6417.1
Applied rewrites17.1%
Taylor expanded in a around 0
Applied rewrites26.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 45.0%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites45.0%
lift-*.f64N/A
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
div-addN/A
lower-+.f64N/A
Applied rewrites44.5%
Taylor expanded in a around 0
associate-*l*N/A
*-commutativeN/A
count-2-revN/A
count-2-revN/A
div-addN/A
div-addN/A
associate-*r/N/A
associate-*r/N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f648.4
Applied rewrites8.4%
Taylor expanded in a around 0
Applied rewrites12.3%
herbie shell --seed 2025076
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))