
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
Herbie found 13 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (+ b (sqrt (fma -4.0 (* c a) (* b b)))) (* -2.0 a)))
(t_1
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(t_2 (fma -0.5 (/ (+ b (fabs b)) a) (/ c (fabs b)))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -1e-198)
t_0
(if (<= t_1 0.0)
(* -1.0 (/ c b))
(if (<= t_1 1e+290) t_0 t_2))))))double code(double a, double b, double c) {
double t_0 = (b + sqrt(fma(-4.0, (c * a), (b * b)))) / (-2.0 * a);
double t_1 = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
double t_2 = fma(-0.5, ((b + fabs(b)) / a), (c / fabs(b)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -1e-198) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = -1.0 * (c / b);
} else if (t_1 <= 1e+290) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(Float64(b + sqrt(fma(-4.0, Float64(c * a), Float64(b * b)))) / Float64(-2.0 * a)) t_1 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) t_2 = fma(-0.5, Float64(Float64(b + abs(b)) / a), Float64(c / abs(b))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -1e-198) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(-1.0 * Float64(c / b)); elseif (t_1 <= 1e+290) tmp = t_0; else tmp = t_2; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-0.5 * N[(N[(b + N[Abs[b], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] + N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -1e-198], t$95$0, If[LessEqual[t$95$1, 0.0], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+290], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
t_0 := \frac{b + \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}}{-2 \cdot a}\\
t_1 := \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
t_2 := \mathsf{fma}\left(-0.5, \frac{b + \left|b\right|}{a}, \frac{c}{\left|b\right|}\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;t\_1 \leq 10^{+290}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < -inf.0 or 1.0000000000000001e290 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) Initial program 52.5%
Taylor expanded in a around inf
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites38.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.8%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6468.4%
Applied rewrites68.4%
if -inf.0 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < -9.9999999999999991e-199 or 0.0 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < 1.0000000000000001e290Initial program 52.5%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
Applied rewrites52.5%
if -9.9999999999999991e-199 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < 0.0Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -0.5 (/ (+ b (fabs b)) a) (/ c (fabs b))))
(t_1
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(t_2 (* (/ -0.5 a) (+ b (sqrt (fma -4.0 (* c a) (* b b)))))))
(if (<= t_1 -2e+272)
t_0
(if (<= t_1 -1e-198)
t_2
(if (<= t_1 0.0)
(* -1.0 (/ c b))
(if (<= t_1 1e+290) t_2 t_0))))))double code(double a, double b, double c) {
double t_0 = fma(-0.5, ((b + fabs(b)) / a), (c / fabs(b)));
double t_1 = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
double t_2 = (-0.5 / a) * (b + sqrt(fma(-4.0, (c * a), (b * b))));
double tmp;
if (t_1 <= -2e+272) {
tmp = t_0;
} else if (t_1 <= -1e-198) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = -1.0 * (c / b);
} else if (t_1 <= 1e+290) {
tmp = t_2;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c) t_0 = fma(-0.5, Float64(Float64(b + abs(b)) / a), Float64(c / abs(b))) t_1 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) t_2 = Float64(Float64(-0.5 / a) * Float64(b + sqrt(fma(-4.0, Float64(c * a), Float64(b * b))))) tmp = 0.0 if (t_1 <= -2e+272) tmp = t_0; elseif (t_1 <= -1e-198) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(-1.0 * Float64(c / b)); elseif (t_1 <= 1e+290) tmp = t_2; else tmp = t_0; end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(-0.5 * N[(N[(b + N[Abs[b], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] + N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+272], t$95$0, If[LessEqual[t$95$1, -1e-198], t$95$2, If[LessEqual[t$95$1, 0.0], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+290], t$95$2, t$95$0]]]]]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(-0.5, \frac{b + \left|b\right|}{a}, \frac{c}{\left|b\right|}\right)\\
t_1 := \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\
t_2 := \frac{-0.5}{a} \cdot \left(b + \sqrt{\mathsf{fma}\left(-4, c \cdot a, b \cdot b\right)}\right)\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+272}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{-198}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;t\_1 \leq 10^{+290}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < -2.0000000000000001e272 or 1.0000000000000001e290 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) Initial program 52.5%
Taylor expanded in a around inf
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites38.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.8%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6468.4%
Applied rewrites68.4%
if -2.0000000000000001e272 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < -9.9999999999999991e-199 or 0.0 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < 1.0000000000000001e290Initial program 52.5%
lift-/.f64N/A
frac-2negN/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
lift--.f64N/A
sub-negate-revN/A
sub-flipN/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites52.4%
if -9.9999999999999991e-199 < (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 #s(literal 4 binary64) (*.f64 a c))))) (*.f64 #s(literal 2 binary64) a)) < 0.0Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(/ (+ b (sqrt (* -4.0 (* a c)))) (* -2.0 a))
(fma -0.5 (/ (+ b (fabs b)) a) (/ c (fabs b))))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = (b + sqrt((-4.0 * (a * c)))) / (-2.0 * a);
} else {
tmp = fma(-0.5, ((b + fabs(b)) / a), (c / fabs(b)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(Float64(b + sqrt(Float64(-4.0 * Float64(a * c)))) / Float64(-2.0 * a)); else tmp = fma(-0.5, Float64(Float64(b + abs(b)) / a), Float64(c / abs(b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(N[(b + N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-2.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(b + N[Abs[b], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] + N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;\frac{b + \sqrt{-4 \cdot \left(a \cdot c\right)}}{-2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{b + \left|b\right|}{a}, \frac{c}{\left|b\right|}\right)\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
Applied rewrites52.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6434.1%
Applied rewrites34.1%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in a around inf
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites38.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.8%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6468.4%
Applied rewrites68.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(* -0.5 (/ (sqrt (fabs (* -4.0 (* c a)))) a))
(fma -0.5 (/ (+ b (fabs b)) a) (/ c (fabs b))))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = -0.5 * (sqrt(fabs((-4.0 * (c * a)))) / a);
} else {
tmp = fma(-0.5, ((b + fabs(b)) / a), (c / fabs(b)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(-0.5 * Float64(sqrt(abs(Float64(-4.0 * Float64(c * a)))) / a)); else tmp = fma(-0.5, Float64(Float64(b + abs(b)) / a), Float64(c / abs(b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(-0.5 * N[(N[Sqrt[N[Abs[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(b + N[Abs[b], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] + N[(c / N[Abs[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{\left|-4 \cdot \left(c \cdot a\right)\right|}}{a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \frac{b + \left|b\right|}{a}, \frac{c}{\left|b\right|}\right)\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.9%
Applied rewrites28.9%
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
rem-square-sqrtN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
Applied rewrites30.0%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in a around inf
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites38.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites62.8%
Taylor expanded in c around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f6468.4%
Applied rewrites68.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(* -0.5 (/ (sqrt (fabs (* -4.0 (* c a)))) a))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = -0.5 * (sqrt(fabs((-4.0 * (c * a)))) / a);
} else {
tmp = -b / a;
}
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 <= (-6.5d-96)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.8d-134) then
tmp = (-0.5d0) * (sqrt(abs(((-4.0d0) * (c * a)))) / a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = -0.5 * (Math.sqrt(Math.abs((-4.0 * (c * a)))) / a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-96: tmp = -1.0 * (c / b) elif b <= 1.8e-134: tmp = -0.5 * (math.sqrt(math.fabs((-4.0 * (c * a)))) / a) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(-0.5 * Float64(sqrt(abs(Float64(-4.0 * Float64(c * a)))) / a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-96) tmp = -1.0 * (c / b); elseif (b <= 1.8e-134) tmp = -0.5 * (sqrt(abs((-4.0 * (c * a)))) / a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(-0.5 * N[(N[Sqrt[N[Abs[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{\left|-4 \cdot \left(c \cdot a\right)\right|}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.9%
Applied rewrites28.9%
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
rem-square-sqrtN/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
metadata-evalN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
Applied rewrites30.0%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(/ (* (sqrt (* -4.0 (* c a))) -0.5) a)
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = (sqrt((-4.0 * (c * a))) * -0.5) / a;
} else {
tmp = -b / a;
}
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 <= (-6.5d-96)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.8d-134) then
tmp = (sqrt(((-4.0d0) * (c * a))) * (-0.5d0)) / a
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = (Math.sqrt((-4.0 * (c * a))) * -0.5) / a;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-96: tmp = -1.0 * (c / b) elif b <= 1.8e-134: tmp = (math.sqrt((-4.0 * (c * a))) * -0.5) / a else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(Float64(sqrt(Float64(-4.0 * Float64(c * a))) * -0.5) / a); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-96) tmp = -1.0 * (c / b); elseif (b <= 1.8e-134) tmp = (sqrt((-4.0 * (c * a))) * -0.5) / a; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision] / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;\frac{\sqrt{-4 \cdot \left(c \cdot a\right)} \cdot -0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.9%
Applied rewrites28.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6428.9%
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f6428.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f6428.9%
Applied rewrites28.9%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(* (sqrt (* -4.0 (* c a))) (/ -0.5 a))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = sqrt((-4.0 * (c * a))) * (-0.5 / a);
} else {
tmp = -b / a;
}
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 <= (-6.5d-96)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.8d-134) then
tmp = sqrt(((-4.0d0) * (c * a))) * ((-0.5d0) / a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = Math.sqrt((-4.0 * (c * a))) * (-0.5 / a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-96: tmp = -1.0 * (c / b) elif b <= 1.8e-134: tmp = math.sqrt((-4.0 * (c * a))) * (-0.5 / a) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(sqrt(Float64(-4.0 * Float64(c * a))) * Float64(-0.5 / a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-96) tmp = -1.0 * (c / b); elseif (b <= 1.8e-134) tmp = sqrt((-4.0 * (c * a))) * (-0.5 / a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;\sqrt{-4 \cdot \left(c \cdot a\right)} \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6428.9%
Applied rewrites28.9%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
metadata-evalN/A
frac-timesN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6428.9%
Applied rewrites28.9%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-96)
(* -1.0 (/ c b))
(if (<= b 1.8e-134)
(* 0.5 (* c (sqrt (/ -4.0 (* a c)))))
(/ (- b) a))))double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = 0.5 * (c * sqrt((-4.0 / (a * c))));
} else {
tmp = -b / a;
}
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 <= (-6.5d-96)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.8d-134) then
tmp = 0.5d0 * (c * sqrt(((-4.0d0) / (a * c))))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-96) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = 0.5 * (c * Math.sqrt((-4.0 / (a * c))));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.5e-96: tmp = -1.0 * (c / b) elif b <= 1.8e-134: tmp = 0.5 * (c * math.sqrt((-4.0 / (a * c)))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.5e-96) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(0.5 * Float64(c * sqrt(Float64(-4.0 / Float64(a * c))))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.5e-96) tmp = -1.0 * (c / b); elseif (b <= 1.8e-134) tmp = 0.5 * (c * sqrt((-4.0 / (a * c)))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.5e-96], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(0.5 * N[(c * N[Sqrt[N[(-4.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.5 \cdot 10^{-96}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;0.5 \cdot \left(c \cdot \sqrt{\frac{-4}{a \cdot c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5e-96Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5e-96 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in a around inf
lower-fma.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Taylor expanded in c around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6427.6%
Applied rewrites27.6%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c) :precision binary64 (if (<= b -3.8e-172) (* -1.0 (/ c b)) (if (<= b 1.8e-134) (* 0.5 (sqrt (* -4.0 (/ c a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-172) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = 0.5 * sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
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 <= (-3.8d-172)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.8d-134) then
tmp = 0.5d0 * sqrt(((-4.0d0) * (c / a)))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-172) {
tmp = -1.0 * (c / b);
} else if (b <= 1.8e-134) {
tmp = 0.5 * Math.sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-172: tmp = -1.0 * (c / b) elif b <= 1.8e-134: tmp = 0.5 * math.sqrt((-4.0 * (c / a))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-172) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.8e-134) tmp = Float64(0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-172) tmp = -1.0 * (c / b); elseif (b <= 1.8e-134) tmp = 0.5 * sqrt((-4.0 * (c / a))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-172], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-134], N[(0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-172}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-134}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -3.7999999999999999e-172Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -3.7999999999999999e-172 < b < 1.7999999999999999e-134Initial program 52.5%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.8%
Applied rewrites16.8%
if 1.7999999999999999e-134 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c) :precision binary64 (if (<= b -6.6e-124) (* -1.0 (/ c b)) (if (<= b 1.35e-135) (* -0.5 (sqrt (* c (/ -4.0 a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-124) {
tmp = -1.0 * (c / b);
} else if (b <= 1.35e-135) {
tmp = -0.5 * sqrt((c * (-4.0 / a)));
} else {
tmp = -b / a;
}
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 <= (-6.6d-124)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.35d-135) then
tmp = (-0.5d0) * sqrt((c * ((-4.0d0) / a)))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-124) {
tmp = -1.0 * (c / b);
} else if (b <= 1.35e-135) {
tmp = -0.5 * Math.sqrt((c * (-4.0 / a)));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.6e-124: tmp = -1.0 * (c / b) elif b <= 1.35e-135: tmp = -0.5 * math.sqrt((c * (-4.0 / a))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.6e-124) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.35e-135) tmp = Float64(-0.5 * sqrt(Float64(c * Float64(-4.0 / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.6e-124) tmp = -1.0 * (c / b); elseif (b <= 1.35e-135) tmp = -0.5 * sqrt((c * (-4.0 / a))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.6e-124], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-135], N[(-0.5 * N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-124}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-135}:\\
\;\;\;\;-0.5 \cdot \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5999999999999997e-124Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5999999999999997e-124 < b < 1.35e-135Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.8%
Applied rewrites16.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6416.8%
Applied rewrites16.8%
if 1.35e-135 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c) :precision binary64 (if (<= b -6.6e-124) (* -1.0 (/ c b)) (if (<= b 1.35e-135) (* -0.5 (sqrt (* -4.0 (/ c a)))) (/ (- b) a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-124) {
tmp = -1.0 * (c / b);
} else if (b <= 1.35e-135) {
tmp = -0.5 * sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
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 <= (-6.6d-124)) then
tmp = (-1.0d0) * (c / b)
else if (b <= 1.35d-135) then
tmp = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-124) {
tmp = -1.0 * (c / b);
} else if (b <= 1.35e-135) {
tmp = -0.5 * Math.sqrt((-4.0 * (c / a)));
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.6e-124: tmp = -1.0 * (c / b) elif b <= 1.35e-135: tmp = -0.5 * math.sqrt((-4.0 * (c / a))) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.6e-124) tmp = Float64(-1.0 * Float64(c / b)); elseif (b <= 1.35e-135) tmp = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.6e-124) tmp = -1.0 * (c / b); elseif (b <= 1.35e-135) tmp = -0.5 * sqrt((-4.0 * (c / a))); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.6e-124], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-135], N[(-0.5 * N[Sqrt[N[(-4.0 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-124}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-135}:\\
\;\;\;\;-0.5 \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -6.5999999999999997e-124Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -6.5999999999999997e-124 < b < 1.35e-135Initial program 52.5%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.8%
Applied rewrites16.8%
if 1.35e-135 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-308) (* -1.0 (/ c b)) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-308) {
tmp = -1.0 * (c / b);
} else {
tmp = -b / a;
}
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 <= (-5d-308)) then
tmp = (-1.0d0) * (c / b)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-308) {
tmp = -1.0 * (c / b);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-308: tmp = -1.0 * (c / b) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-308) tmp = Float64(-1.0 * Float64(c / b)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-308) tmp = -1.0 * (c / b); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-308], N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-308}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
if b < -4.9999999999999995e-308Initial program 52.5%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6434.4%
Applied rewrites34.4%
if -4.9999999999999995e-308 < b Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c) :precision binary64 (/ (- b) a))
double code(double a, double b, double c) {
return -b / 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 / a
end function
public static double code(double a, double b, double c) {
return -b / a;
}
def code(a, b, c): return -b / a
function code(a, b, c) return Float64(Float64(-b) / a) end
function tmp = code(a, b, c) tmp = -b / a; end
code[a_, b_, c_] := N[((-b) / a), $MachinePrecision]
\frac{-b}{a}
Initial program 52.5%
Taylor expanded in b around inf
lower-*.f64N/A
lower-/.f6436.4%
Applied rewrites36.4%
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6436.4%
Applied rewrites36.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (< b 0.0)
(/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
(/ (- (- b) t_0) (* 2.0 a)))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b < 0.0d0) then
tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
else
tmp = (-b - t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp = 0 if b < 0.0: tmp = c / (a * ((-b + t_0) / (2.0 * a))) else: tmp = (-b - t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)))); else tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp = 0.0; if (b < 0.0) tmp = c / (a * ((-b + t_0) / (2.0 * a))); else tmp = (-b - t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\end{array}
herbie shell --seed 2025253
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:alt
(! :herbie-platform c (let ((d (sqrt (- (* b b) (* 4 (* a c)))))) (let ((r1 (/ (+ (- b) d) (* 2 a)))) (let ((r2 (/ (- (- b) d) (* 2 a)))) (if (< b 0) (/ c (* a r1)) r2)))))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))