
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4 a) c))))) (if (>= b 0) (/ (* 2 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2 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 = (2.0 * c) / (-b - t_0);
} 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 = (2.0d0 * c) / (-b - t_0)
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 = (2.0 * c) / (-b - t_0);
} 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 = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); 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 = (2.0 * c) / (-b - t_0); 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[(N[(4 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4 a) c))))) (if (>= b 0) (/ (* 2 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2 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 = (2.0 * c) / (-b - t_0);
} 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 = (2.0d0 * c) / (-b - t_0)
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 = (2.0 * c) / (-b - t_0);
} 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 = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); 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 = (2.0 * c) / (-b - t_0); 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[(N[(4 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b)))))
(t_1 (sqrt (- (* b b) (* (* a 4) c)))))
(if (<=
b
-10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432)
t_0
(if (<=
b
155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440)
(if (>= b 0) (/ (* -2 c) (+ b t_1)) (/ (- t_1 b) (+ a a)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_0;
} else if (b <= 1.55e+95) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + t_1);
} else {
tmp_2 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
t_1 = sqrt(((b * b) - ((a * 4.0d0) * c)))
if (b <= (-1d+154)) then
tmp_1 = t_0
else if (b <= 1.55d+95) then
if (b >= 0.0d0) then
tmp_2 = ((-2.0d0) * c) / (b + t_1)
else
tmp_2 = (t_1 - b) / (a + a)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_0;
} else if (b <= 1.55e+95) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + t_1);
} else {
tmp_2 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp t_1 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp_1 = 0 if b <= -1e+154: tmp_1 = t_0 elif b <= 1.55e+95: tmp_2 = 0 if b >= 0.0: tmp_2 = (-2.0 * c) / (b + t_1) else: tmp_2 = (t_1 - b) / (a + a) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp t_1 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp_1 = 0.0 if (b <= -1e+154) tmp_1 = t_0; elseif (b <= 1.55e+95) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + t_1)); else tmp_2 = Float64(Float64(t_1 - b) / Float64(a + a)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; t_1 = sqrt(((b * b) - ((a * 4.0) * c))); tmp_2 = 0.0; if (b <= -1e+154) tmp_2 = t_0; elseif (b <= 1.55e+95) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-2.0 * c) / (b + t_1); else tmp_3 = (t_1 - b) / (a + a); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432], t$95$0, If[LessEqual[b, 155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440], If[GreaterEqual[b, 0], N[(N[(-2 * c), $MachinePrecision] / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
t_1 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
\mathbf{if}\;b \leq -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a + a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -1e154 or 1.5500000000000001e95 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -1e154 < b < 1.5500000000000001e95Initial program 72.6%
Applied rewrites72.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* a 4) c))))
(t_1 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432)
t_1
(if (<=
b
6511732844609233/1627933211152308172382776316094057079381044512284157265721742629825204403764070329961287158415906809263410622703474912218234570716337735615323084973713581554222450580936038710562274972146438970881094974642550439936936217782587026682413056)
(if (>= b 0)
(/ (* -2 c) (+ b (sqrt (- (* 4 (* a c))))))
(/ (- t_0 b) (+ a a)))
(if (<=
b
155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440)
(if (>= b 0)
(* c (/ -2 (+ t_0 b)))
(* (* (sqrt (* (/ a c) -4)) (/ c a)) -1/2))
t_1)))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_1 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_1;
} else if (b <= 4e-222) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 1.55e+95) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (t_0 + b));
} else {
tmp_3 = (sqrt(((a / c) * -4.0)) * (c / a)) * -0.5;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - ((a * 4.0d0) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_1 = tmp
if (b <= (-1d+154)) then
tmp_1 = t_1
else if (b <= 4d-222) then
if (b >= 0.0d0) then
tmp_2 = ((-2.0d0) * c) / (b + sqrt(-(4.0d0 * (a * c))))
else
tmp_2 = (t_0 - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b <= 1.55d+95) then
if (b >= 0.0d0) then
tmp_3 = c * ((-2.0d0) / (t_0 + b))
else
tmp_3 = (sqrt(((a / c) * (-4.0d0))) * (c / a)) * (-0.5d0)
end if
tmp_1 = tmp_3
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_1 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_1;
} else if (b <= 4e-222) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 1.55e+95) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (t_0 + b));
} else {
tmp_3 = (Math.sqrt(((a / c) * -4.0)) * (c / a)) * -0.5;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_1 = tmp tmp_1 = 0 if b <= -1e+154: tmp_1 = t_1 elif b <= 4e-222: tmp_2 = 0 if b >= 0.0: tmp_2 = (-2.0 * c) / (b + math.sqrt(-(4.0 * (a * c)))) else: tmp_2 = (t_0 - b) / (a + a) tmp_1 = tmp_2 elif b <= 1.55e+95: tmp_3 = 0 if b >= 0.0: tmp_3 = c * (-2.0 / (t_0 + b)) else: tmp_3 = (math.sqrt(((a / c) * -4.0)) * (c / a)) * -0.5 tmp_1 = tmp_3 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_1 = tmp tmp_1 = 0.0 if (b <= -1e+154) tmp_1 = t_1; elseif (b <= 4e-222) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_2 = Float64(Float64(t_0 - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b <= 1.55e+95) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / Float64(t_0 + b))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(a / c) * -4.0)) * Float64(c / a)) * -0.5); end tmp_1 = tmp_3; else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((a * 4.0) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_1 = tmp; tmp_2 = 0.0; if (b <= -1e+154) tmp_2 = t_1; elseif (b <= 4e-222) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-2.0 * c) / (b + sqrt(-(4.0 * (a * c)))); else tmp_3 = (t_0 - b) / (a + a); end tmp_2 = tmp_3; elseif (b <= 1.55e+95) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = c * (-2.0 / (t_0 + b)); else tmp_4 = (sqrt(((a / c) * -4.0)) * (c / a)) * -0.5; end tmp_2 = tmp_4; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432], t$95$1, If[LessEqual[b, 6511732844609233/1627933211152308172382776316094057079381044512284157265721742629825204403764070329961287158415906809263410622703474912218234570716337735615323084973713581554222450580936038710562274972146438970881094974642550439936936217782587026682413056], If[GreaterEqual[b, 0], N[(N[(-2 * c), $MachinePrecision] / N[(b + N[Sqrt[(-N[(4 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440], If[GreaterEqual[b, 0], N[(c * N[(-2 / N[(t$95$0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(a / c), $MachinePrecision] * -4), $MachinePrecision]], $MachinePrecision] * N[(c / a), $MachinePrecision]), $MachinePrecision] * -1/2), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq \frac{6511732844609233}{1627933211152308172382776316094057079381044512284157265721742629825204403764070329961287158415906809263410622703474912218234570716337735615323084973713581554222450580936038710562274972146438970881094974642550439936936217782587026682413056}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + \sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 155000000000000014249966831491526543892109490932264603790273940613734768562643532710258608701440:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{t\_0 + b}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{a}{c} \cdot -4} \cdot \frac{c}{a}\right) \cdot \frac{-1}{2}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -1e154 or 1.5500000000000001e95 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -1e154 < b < 4.0000000000000002e-222Initial program 72.6%
Applied rewrites72.6%
Taylor expanded in b around 0
lower-+.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6457.0%
Applied rewrites57.0%
if 4.0000000000000002e-222 < b < 1.5500000000000001e95Initial program 72.6%
Taylor expanded in c around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
Applied rewrites43.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432)
t_0
(if (<=
b
1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296)
(if (>= b 0)
(/ (* -2 c) (+ b (sqrt (- (* 4 (* a c))))))
(/ (- (sqrt (- (* b b) (* (* a 4) c))) b) (+ a a)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-1d+154)) then
tmp_1 = t_0
else if (b <= 2.5d-55) then
if (b >= 0.0d0) then
tmp_2 = ((-2.0d0) * c) / (b + sqrt(-(4.0d0 * (a * c))))
else
tmp_2 = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a + a)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-2.0 * c) / (b + Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -1e+154: tmp_1 = t_0 elif b <= 2.5e-55: tmp_2 = 0 if b >= 0.0: tmp_2 = (-2.0 * c) / (b + math.sqrt(-(4.0 * (a * c)))) else: tmp_2 = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -1e+154) tmp_1 = t_0; elseif (b <= 2.5e-55) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-2.0 * c) / Float64(b + sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a + a)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -1e+154) tmp_2 = t_0; elseif (b <= 2.5e-55) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-2.0 * c) / (b + sqrt(-(4.0 * (a * c)))); else tmp_3 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432], t$95$0, If[LessEqual[b, 1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296], If[GreaterEqual[b, 0], N[(N[(-2 * c), $MachinePrecision] / N[(b + N[Sqrt[(-N[(4 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], t$95$0]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq -10000000000000000369475456880582265409809179829842688451922778552150543659347219597216513109705408327446511753687232667314337003349573404171046192448274432:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{1725436586697641}{6901746346790563787434755862277025452451108972170386555162524223799296}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + \sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a + a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -1e154 or 2.5000000000000001e-55 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -1e154 < b < 2.5000000000000001e-55Initial program 72.6%
Applied rewrites72.6%
Taylor expanded in b around 0
lower-+.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6457.0%
Applied rewrites57.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b)))))
(t_1 (sqrt (* (* -4 a) c))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296)
(if (>= b 0) (* c (/ -2 (+ t_1 b))) (/ (- t_1 b) (+ a a)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = sqrt(((-4.0 * a) * c));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_1 + b));
} else {
tmp_2 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
t_1 = sqrt((((-4.0d0) * a) * c))
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= 2.5d-55) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (t_1 + b))
else
tmp_2 = (t_1 - b) / (a + a)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = Math.sqrt(((-4.0 * a) * c));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_1 + b));
} else {
tmp_2 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp t_1 = math.sqrt(((-4.0 * a) * c)) tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= 2.5e-55: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (t_1 + b)) else: tmp_2 = (t_1 - b) / (a + a) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp t_1 = sqrt(Float64(Float64(-4.0 * a) * c)) tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= 2.5e-55) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(t_1 + b))); else tmp_2 = Float64(Float64(t_1 - b) / Float64(a + a)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; t_1 = sqrt(((-4.0 * a) * c)); tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= 2.5e-55) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (t_1 + b)); else tmp_3 = (t_1 - b) / (a + a); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[(N[(-4 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, 1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296], If[GreaterEqual[b, 0], N[(c * N[(-2 / N[(t$95$1 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
t_1 := \sqrt{\left(-4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{1725436586697641}{6901746346790563787434755862277025452451108972170386555162524223799296}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{t\_1 + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a + a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 2.5000000000000001e-55 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 2.5000000000000001e-55Initial program 72.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6457.0%
Applied rewrites57.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6441.0%
Applied rewrites41.0%
Applied rewrites41.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b)))))
(t_1 (sqrt (fabs (* (* -4 a) c)))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296)
(if (>= b 0)
(/ (* 2 c) (- (- b) t_1))
(/ (+ (- b) t_1) (* 2 a)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = sqrt(fabs(((-4.0 * a) * c)));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_1);
} else {
tmp_2 = (-b + t_1) / (2.0 * a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
t_1 = sqrt(abs((((-4.0d0) * a) * c)))
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= 2.5d-55) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - t_1)
else
tmp_2 = (-b + t_1) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = Math.sqrt(Math.abs(((-4.0 * a) * c)));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_1);
} else {
tmp_2 = (-b + t_1) / (2.0 * a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp t_1 = math.sqrt(math.fabs(((-4.0 * a) * c))) tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= 2.5e-55: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - t_1) else: tmp_2 = (-b + t_1) / (2.0 * a) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp t_1 = sqrt(abs(Float64(Float64(-4.0 * a) * c))) tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= 2.5e-55) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_2 = Float64(Float64(Float64(-b) + t_1) / Float64(2.0 * a)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; t_1 = sqrt(abs(((-4.0 * a) * c))); tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= 2.5e-55) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - t_1); else tmp_3 = (-b + t_1) / (2.0 * a); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[Abs[N[(N[(-4 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, 1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296], If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$1), $MachinePrecision] / N[(2 * a), $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
t_1 := \sqrt{\left|\left(-4 \cdot a\right) \cdot c\right|}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{1725436586697641}{6901746346790563787434755862277025452451108972170386555162524223799296}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_1}{2 \cdot a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 2.5000000000000001e-55 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 2.5000000000000001e-55Initial program 72.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6457.0%
Applied rewrites57.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6441.0%
Applied rewrites41.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6445.8%
Applied rewrites45.8%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6450.7%
Applied rewrites50.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b)))))
(t_1 (sqrt (* (* -4 a) c))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296)
(if (>= b 0) (* c (/ -2 (+ t_1 b))) (* (/ 1/2 a) (- t_1 b)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = sqrt(((-4.0 * a) * c));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_1 + b));
} else {
tmp_2 = (0.5 / a) * (t_1 - b);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
t_1 = sqrt((((-4.0d0) * a) * c))
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= 2.5d-55) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (t_1 + b))
else
tmp_2 = (0.5d0 / a) * (t_1 - b)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double t_1 = Math.sqrt(((-4.0 * a) * c));
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.5e-55) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_1 + b));
} else {
tmp_2 = (0.5 / a) * (t_1 - b);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp t_1 = math.sqrt(((-4.0 * a) * c)) tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= 2.5e-55: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (t_1 + b)) else: tmp_2 = (0.5 / a) * (t_1 - b) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp t_1 = sqrt(Float64(Float64(-4.0 * a) * c)) tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= 2.5e-55) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(t_1 + b))); else tmp_2 = Float64(Float64(0.5 / a) * Float64(t_1 - b)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; t_1 = sqrt(((-4.0 * a) * c)); tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= 2.5e-55) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (t_1 + b)); else tmp_3 = (0.5 / a) * (t_1 - b); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, Block[{t$95$1 = N[Sqrt[N[(N[(-4 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, 1725436586697641/6901746346790563787434755862277025452451108972170386555162524223799296], If[GreaterEqual[b, 0], N[(c * N[(-2 / N[(t$95$1 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1/2 / a), $MachinePrecision] * N[(t$95$1 - b), $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
t_1 := \sqrt{\left(-4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{1725436586697641}{6901746346790563787434755862277025452451108972170386555162524223799296}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{t\_1 + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{2}}{a} \cdot \left(t\_1 - b\right)\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 2.5000000000000001e-55 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 2.5000000000000001e-55Initial program 72.6%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6457.0%
Applied rewrites57.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6441.0%
Applied rewrites41.0%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6441.0%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
sub-flip-reverseN/A
lower--.f6441.0%
Applied rewrites41.0%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
frac-2negN/A
lower-/.f64N/A
metadata-evalN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
Applied rewrites41.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ 1 (* -1 (/ a b))))
(t_1 (if (>= b 0) (/ (* 2 c) (* -2 b)) t_0)))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_1
(if (<=
b
-20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
4106071118205837/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232)
(if (>= b 0) (* -2 (/ c (sqrt (- (* 4 (* a c)))))) t_0)
t_1)))))double code(double a, double b, double c) {
double t_0 = 1.0 / (-1.0 * (a / b));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_1;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 * (c / sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = t_0;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = 1.0d0 / ((-1.0d0) * (a / b))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = t_0
end if
t_1 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_1
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 3.4d-155) then
if (b >= 0.0d0) then
tmp_3 = (-2.0d0) * (c / sqrt(-(4.0d0 * (a * c))))
else
tmp_3 = t_0
end if
tmp_1 = tmp_3
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = 1.0 / (-1.0 * (a / b));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_1;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 * (c / Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = t_0;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = 1.0 / (-1.0 * (a / b)) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = t_0 t_1 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_1 elif b <= -4e-310: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 3.4e-155: tmp_3 = 0 if b >= 0.0: tmp_3 = -2.0 * (c / math.sqrt(-(4.0 * (a * c)))) else: tmp_3 = t_0 tmp_1 = tmp_3 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(1.0 / Float64(-1.0 * Float64(a / b))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = t_0; end t_1 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_1; elseif (b <= -4e-310) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 3.4e-155) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-2.0 * Float64(c / sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_3 = t_0; end tmp_1 = tmp_3; else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = 1.0 / (-1.0 * (a / b)); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = t_0; end t_1 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_1; elseif (b <= -4e-310) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 3.4e-155) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -2.0 * (c / sqrt(-(4.0 * (a * c)))); else tmp_4 = t_0; end tmp_2 = tmp_4; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], t$95$0]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$1, If[LessEqual[b, -20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4106071118205837/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232], If[GreaterEqual[b, 0], N[(-2 * N[(c / N[Sqrt[(-N[(4 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], t$95$1]]]]]
\begin{array}{l}
t_0 := \frac{1}{-1 \cdot \frac{a}{b}}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq \frac{-20240225330731}{50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{4106071118205837}{120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{\sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -5.6000000000000005e-78 or 3.4e-155 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < -3.9999999999999878e-310Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if -3.9999999999999878e-310 < b < 3.4e-155Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6447.3%
Applied rewrites47.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
-20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
4106071118205837/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232)
(if (>= b 0)
(* -2 (/ c (sqrt (- (* 4 (* a c))))))
(* -1/2 (sqrt (* -4 (/ c a)))))
t_0)))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 * (c / sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = -0.5 * sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 3.4d-155) then
if (b >= 0.0d0) then
tmp_3 = (-2.0d0) * (c / sqrt(-(4.0d0 * (a * c))))
else
tmp_3 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 * (c / Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= -4e-310: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 3.4e-155: tmp_3 = 0 if b >= 0.0: tmp_3 = -2.0 * (c / math.sqrt(-(4.0 * (a * c)))) else: tmp_3 = -0.5 * math.sqrt((-4.0 * (c / a))) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= -4e-310) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 3.4e-155) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-2.0 * Float64(c / sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_3 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= -4e-310) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 3.4e-155) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -2.0 * (c / sqrt(-(4.0 * (a * c)))); else tmp_4 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, -20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 4106071118205837/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232], If[GreaterEqual[b, 0], N[(-2 * N[(c / N[Sqrt[(-N[(4 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{-20240225330731}{50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{4106071118205837}{120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-2 \cdot \frac{c}{\sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 3.4e-155 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < -3.9999999999999878e-310Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if -3.9999999999999878e-310 < b < 3.4e-155Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around 0
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6421.7%
Applied rewrites21.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
-1877755279706495/49414612623855131433714684257548170666395666446323759364477870612165610246092613987295015552108672972457782681717971658054152523775828485563235693344906862773807964911271084317496803647971976645810490155877135026504396358257981615873560389562783094809768080203212590222737650052546509407272052614415528872877858335227904)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
2287806213626217/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568)
(if (>= 0 0)
(/ 2 (sqrt (* -4 (/ a c))))
(* -1/2 (sqrt (* -4 (/ c a)))))
t_0)))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -3.8e-305) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.85e-158) {
double tmp_3;
if (0.0 >= 0.0) {
tmp_3 = 2.0 / sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= (-3.8d-305)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 1.85d-158) then
if (0.0d0 >= 0.0d0) then
tmp_3 = 2.0d0 / sqrt(((-4.0d0) * (a / c)))
else
tmp_3 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -3.8e-305) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.85e-158) {
double tmp_3;
if (0.0 >= 0.0) {
tmp_3 = 2.0 / Math.sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= -3.8e-305: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 1.85e-158: tmp_3 = 0 if 0.0 >= 0.0: tmp_3 = 2.0 / math.sqrt((-4.0 * (a / c))) else: tmp_3 = -0.5 * math.sqrt((-4.0 * (c / a))) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= -3.8e-305) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 1.85e-158) tmp_3 = 0.0 if (0.0 >= 0.0) tmp_3 = Float64(2.0 / sqrt(Float64(-4.0 * Float64(a / c)))); else tmp_3 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= -3.8e-305) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 1.85e-158) tmp_4 = 0.0; if (0.0 >= 0.0) tmp_4 = 2.0 / sqrt((-4.0 * (a / c))); else tmp_4 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, -1877755279706495/49414612623855131433714684257548170666395666446323759364477870612165610246092613987295015552108672972457782681717971658054152523775828485563235693344906862773807964911271084317496803647971976645810490155877135026504396358257981615873560389562783094809768080203212590222737650052546509407272052614415528872877858335227904], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2287806213626217/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568], If[GreaterEqual[0, 0], N[(2 / N[Sqrt[N[(-4 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{-1877755279706495}{49414612623855131433714684257548170666395666446323759364477870612165610246092613987295015552108672972457782681717971658054152523775828485563235693344906862773807964911271084317496803647971976645810490155877135026504396358257981615873560389562783094809768080203212590222737650052546509407272052614415528872877858335227904}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{2287806213626217}{123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;0 \geq 0:\\
\;\;\;\;\frac{2}{\sqrt{-4 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 1.85e-158 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < -3.8e-305Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if -3.8e-305 < b < 1.85e-158Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.4%
Applied rewrites16.4%
Taylor expanded in undef-var around zero
Applied rewrites16.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
-20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
2287806213626217/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568)
(if (>= b 0)
(/ 2 (sqrt (* -4 (/ a c))))
(* -1/2 (sqrt (* -4 (/ c a)))))
t_0)))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.85e-158) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= (-4d-310)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 1.85d-158) then
if (b >= 0.0d0) then
tmp_3 = 2.0d0 / sqrt(((-4.0d0) * (a / c)))
else
tmp_3 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= -4e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.85e-158) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / Math.sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= -4e-310: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 1.85e-158: tmp_3 = 0 if b >= 0.0: tmp_3 = 2.0 / math.sqrt((-4.0 * (a / c))) else: tmp_3 = -0.5 * math.sqrt((-4.0 * (c / a))) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= -4e-310) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 1.85e-158) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(2.0 / sqrt(Float64(-4.0 * Float64(a / c)))); else tmp_3 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= -4e-310) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 1.85e-158) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = 2.0 / sqrt((-4.0 * (a / c))); else tmp_4 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, -20240225330731/50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2287806213626217/123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568], If[GreaterEqual[b, 0], N[(2 / N[Sqrt[N[(-4 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{-20240225330731}{50600563326827654588123836679729326762389162441035529589225339506857584891998836722990095925359281123796769466079202977847452184346448369216753349985184627480379356069141590341116726935523304085309941919618186267140501870856173174654525838912289889085202514128089692388083353653807625633046581877161501565826926935273373696}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{2287806213626217}{123665200736552267030251260509823595017565674550605919957031528046448612553265933585158200530621522494798835713008069669675682517153375604983773077550946583958303386074349568}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{\sqrt{-4 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 1.85e-158 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < -3.9999999999999878e-310Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if -3.9999999999999878e-310 < b < 1.85e-158Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.4%
Applied rewrites16.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ 1 (* -1 (/ a b))))
(t_1 (if (>= b 0) (/ (* 2 c) (* -2 b)) t_0)))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_1
(if (<=
b
5033540777614485/359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
2294569154291497/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232)
(if (>= b 0) (/ -2 (sqrt (* -4 (/ a c)))) t_0)
t_1)))))double code(double a, double b, double c) {
double t_0 = 1.0 / (-1.0 * (a / b));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_1;
} else if (b <= 1.4e-293) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 / sqrt((-4.0 * (a / c)));
} else {
tmp_3 = t_0;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = 1.0d0 / ((-1.0d0) * (a / b))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = t_0
end if
t_1 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_1
else if (b <= 1.4d-293) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 1.9d-155) then
if (b >= 0.0d0) then
tmp_3 = (-2.0d0) / sqrt(((-4.0d0) * (a / c)))
else
tmp_3 = t_0
end if
tmp_1 = tmp_3
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = 1.0 / (-1.0 * (a / b));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_1;
} else if (b <= 1.4e-293) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 / Math.sqrt((-4.0 * (a / c)));
} else {
tmp_3 = t_0;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = 1.0 / (-1.0 * (a / b)) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = t_0 t_1 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_1 elif b <= 1.4e-293: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 1.9e-155: tmp_3 = 0 if b >= 0.0: tmp_3 = -2.0 / math.sqrt((-4.0 * (a / c))) else: tmp_3 = t_0 tmp_1 = tmp_3 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(1.0 / Float64(-1.0 * Float64(a / b))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = t_0; end t_1 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_1; elseif (b <= 1.4e-293) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 1.9e-155) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-2.0 / sqrt(Float64(-4.0 * Float64(a / c)))); else tmp_3 = t_0; end tmp_1 = tmp_3; else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = 1.0 / (-1.0 * (a / b)); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = t_0; end t_1 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_1; elseif (b <= 1.4e-293) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 1.9e-155) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -2.0 / sqrt((-4.0 * (a / c))); else tmp_4 = t_0; end tmp_2 = tmp_4; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], t$95$0]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$1, If[LessEqual[b, 5033540777614485/359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2294569154291497/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232], If[GreaterEqual[b, 0], N[(-2 / N[Sqrt[N[(-4 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0], t$95$1]]]]]
\begin{array}{l}
t_0 := \frac{1}{-1 \cdot \frac{a}{b}}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq \frac{5033540777614485}{359538626972463181545861038157804946723595395788461314546860162315465351611001926265416954644815072042240227759742786715317579537628833244985694861278948248755535786849730970552604439202492188238906165904170011537676301364684925762947826221081654474326701021369172596479894491876959432609670712659248448274432}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{2294569154291497}{120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2}{\sqrt{-4 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -5.6000000000000005e-78 or 1.8999999999999999e-155 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 1.4000000000000001e-293Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if 1.4000000000000001e-293 < b < 1.8999999999999999e-155Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in c around inf
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6442.5%
Applied rewrites42.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
2223657568073481/6176826577981891429214335532193521333299458305790469920559733826520701280761576748411876944013584121557222835214746457256769065471978560695404461668113357846725995613908885539687100455996497080726311269484641878313049544782247701984195048695347886851221010025401573777842206256568313675909006576801941109109732291903488)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
(if (<=
b
2294569154291497/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232)
(if (>= b 0)
(/ -2 (sqrt (* -4 (/ a c))))
(* -1/2 (sqrt (* -4 (/ c a)))))
t_0)))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 3.6e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 / sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= 3.6d-304) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else if (b <= 1.9d-155) then
if (b >= 0.0d0) then
tmp_3 = (-2.0d0) / sqrt(((-4.0d0) * (a / c)))
else
tmp_3 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 3.6e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e-155) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -2.0 / Math.sqrt((-4.0 * (a / c)));
} else {
tmp_3 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= 3.6e-304: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 elif b <= 1.9e-155: tmp_3 = 0 if b >= 0.0: tmp_3 = -2.0 / math.sqrt((-4.0 * (a / c))) else: tmp_3 = -0.5 * math.sqrt((-4.0 * (c / a))) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= 3.6e-304) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; elseif (b <= 1.9e-155) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-2.0 / sqrt(Float64(-4.0 * Float64(a / c)))); else tmp_3 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= 3.6e-304) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; elseif (b <= 1.9e-155) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -2.0 / sqrt((-4.0 * (a / c))); else tmp_4 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, 2223657568073481/6176826577981891429214335532193521333299458305790469920559733826520701280761576748411876944013584121557222835214746457256769065471978560695404461668113357846725995613908885539687100455996497080726311269484641878313049544782247701984195048695347886851221010025401573777842206256568313675909006576801941109109732291903488], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2294569154291497/120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232], If[GreaterEqual[b, 0], N[(-2 / N[Sqrt[N[(-4 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{2223657568073481}{6176826577981891429214335532193521333299458305790469920559733826520701280761576748411876944013584121557222835214746457256769065471978560695404461668113357846725995613908885539687100455996497080726311269484641878313049544782247701984195048695347886851221010025401573777842206256568313675909006576801941109109732291903488}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq \frac{2294569154291497}{120766797594289323271729746591624604509341479053326093708038601607859973196548763266756055205685080561326988000984443036792658708157593364241965896045846273396780650463232}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2}{\sqrt{-4 \cdot \frac{a}{c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 1.8999999999999999e-155 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 3.6000000000000001e-304Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
if 3.6000000000000001e-304 < b < 1.8999999999999999e-155Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in c around inf
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6416.9%
Applied rewrites16.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512)
t_0
(if (<=
b
3862231344430757/1404447761611184302913519680303925573139044514798677009948672509044786529730476274474284979081308875165000889686495260606709295068862629863225370551870891596701311667381761603721111090634735110308227210563164107569048052205800491261514946176100212790338675864723330454999587858894372783631526221325189251072)
(if (>= b 0) (* -1 (/ b a)) (* 1/2 (/ (sqrt (* -4 (* a c))) a)))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.75e-291) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-5.6d-78)) then
tmp_1 = t_0
else if (b <= 2.75d-291) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = 0.5d0 * (sqrt(((-4.0d0) * (a * c))) / a)
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -5.6e-78) {
tmp_1 = t_0;
} else if (b <= 2.75e-291) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = 0.5 * (Math.sqrt((-4.0 * (a * c))) / a);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -5.6e-78: tmp_1 = t_0 elif b <= 2.75e-291: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = 0.5 * (math.sqrt((-4.0 * (a * c))) / a) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -5.6e-78) tmp_1 = t_0; elseif (b <= 2.75e-291) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(0.5 * Float64(sqrt(Float64(-4.0 * Float64(a * c))) / a)); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5.6e-78) tmp_2 = t_0; elseif (b <= 2.75e-291) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = 0.5 * (sqrt((-4.0 * (a * c))) / a); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5840589551346239/1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512], t$95$0, If[LessEqual[b, 3862231344430757/1404447761611184302913519680303925573139044514798677009948672509044786529730476274474284979081308875165000889686495260606709295068862629863225370551870891596701311667381761603721111090634735110308227210563164107569048052205800491261514946176100212790338675864723330454999587858894372783631526221325189251072], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(N[Sqrt[N[(-4 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], t$95$0]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-5840589551346239}{1042962419883256876169444192465601618458351817556959360325703910069443225478828393565899456512}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{3862231344430757}{1404447761611184302913519680303925573139044514798677009948672509044786529730476274474284979081308875165000889686495260606709295068862629863225370551870891596701311667381761603721111090634735110308227210563164107569048052205800491261514946176100212790338675864723330454999587858894372783631526221325189251072}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{-4 \cdot \left(a \cdot c\right)}}{a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -5.6000000000000005e-78 or 2.7500000000000001e-291 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -5.6000000000000005e-78 < b < 2.7500000000000001e-291Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f648.8%
Applied rewrites8.8%
Taylor expanded in a around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6414.2%
Applied rewrites14.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b))))))
(if (<=
b
-1684996666696915/421249166674228746791672110734681729275580381602196445017243910144)
t_0
(if (<=
b
-5993757216606705/49947976805055875702105555676690660891977570282639538413746511354005947821116249921924897649015871538557230897942505966327167610868612564900642816)
(if (>= b 0) (* -1 (/ b a)) (* -1/2 (sqrt (* -4 (/ c a)))))
t_0))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -4e-51) {
tmp_1 = t_0;
} else if (b <= -1.2e-130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = -0.5 * sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
t_0 = tmp
if (b <= (-4d-51)) then
tmp_1 = t_0
else if (b <= (-1.2d-130)) then
if (b >= 0.0d0) then
tmp_2 = (-1.0d0) * (b / a)
else
tmp_2 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
tmp_1 = tmp_2
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
double t_0 = tmp;
double tmp_1;
if (b <= -4e-51) {
tmp_1 = t_0;
} else if (b <= -1.2e-130) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -1.0 * (b / a);
} else {
tmp_2 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) t_0 = tmp tmp_1 = 0 if b <= -4e-51: tmp_1 = t_0 elif b <= -1.2e-130: tmp_2 = 0 if b >= 0.0: tmp_2 = -1.0 * (b / a) else: tmp_2 = -0.5 * math.sqrt((-4.0 * (c / a))) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end t_0 = tmp tmp_1 = 0.0 if (b <= -4e-51) tmp_1 = t_0; elseif (b <= -1.2e-130) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-1.0 * Float64(b / a)); else tmp_2 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end t_0 = tmp; tmp_2 = 0.0; if (b <= -4e-51) tmp_2 = t_0; elseif (b <= -1.2e-130) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -1.0 * (b / a); else tmp_3 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -1684996666696915/421249166674228746791672110734681729275580381602196445017243910144], t$95$0, If[LessEqual[b, -5993757216606705/49947976805055875702105555676690660891977570282639538413746511354005947821116249921924897649015871538557230897942505966327167610868612564900642816], If[GreaterEqual[b, 0], N[(-1 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], t$95$0]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{if}\;b \leq \frac{-1684996666696915}{421249166674228746791672110734681729275580381602196445017243910144}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq \frac{-5993757216606705}{49947976805055875702105555676690660891977570282639538413746511354005947821116249921924897649015871538557230897942505966327167610868612564900642816}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-1 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < -4e-51 or -1.2e-130 < b Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -4e-51 < b < -1.2e-130Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f649.3%
Applied rewrites9.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2 c) (* -2 b))))
(if (<=
b
-1684996666696915/421249166674228746791672110734681729275580381602196445017243910144)
(if (>= b 0) t_0 (/ 1 (* -1 (/ a b))))
(if (>= b 0) t_0 (* -1/2 (sqrt (* -4 (/ c a))))))))double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (-2.0 * b);
double tmp_1;
if (b <= -4e-51) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = 1.0 / (-1.0 * (a / b));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * sqrt((-4.0 * (c / a)));
}
return tmp_1;
}
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
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = (2.0d0 * c) / ((-2.0d0) * b)
if (b <= (-4d-51)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = 1.0d0 / ((-1.0d0) * (a / b))
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (-0.5d0) * sqrt(((-4.0d0) * (c / a)))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (-2.0 * b);
double tmp_1;
if (b <= -4e-51) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = 1.0 / (-1.0 * (a / b));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * Math.sqrt((-4.0 * (c / a)));
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (-2.0 * b) tmp_1 = 0 if b <= -4e-51: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = 1.0 / (-1.0 * (a / b)) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = -0.5 * math.sqrt((-4.0 * (c / a))) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(-2.0 * b)) tmp_1 = 0.0 if (b <= -4e-51) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(-0.5 * sqrt(Float64(-4.0 * Float64(c / a)))); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (2.0 * c) / (-2.0 * b); tmp_2 = 0.0; if (b <= -4e-51) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = 1.0 / (-1.0 * (a / b)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = -0.5 * sqrt((-4.0 * (c / a))); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1684996666696915/421249166674228746791672110734681729275580381602196445017243910144], If[GreaterEqual[b, 0], t$95$0, N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0], t$95$0, N[(-1/2 * N[Sqrt[N[(-4 * N[(c / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{if}\;b \leq \frac{-1684996666696915}{421249166674228746791672110734681729275580381602196445017243910144}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \sqrt{-4 \cdot \frac{c}{a}}\\
\end{array}
if b < -4e-51Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
if -4e-51 < b Initial program 72.6%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6444.7%
Applied rewrites44.7%
Taylor expanded in b around inf
lower-*.f6441.6%
Applied rewrites41.6%
(FPCore (a b c) :precision binary64 (if (>= b 0) (/ (* 2 c) (* -2 b)) (/ 1 (* -1 (/ a b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / 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 >= 0.0d0) then
tmp = (2.0d0 * c) / ((-2.0d0) * b)
else
tmp = 1.0d0 / ((-1.0d0) * (a / b))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-2.0 * b);
} else {
tmp = 1.0 / (-1.0 * (a / b));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-2.0 * b) else: tmp = 1.0 / (-1.0 * (a / b)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); else tmp = Float64(1.0 / Float64(-1.0 * Float64(a / b))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-2.0 * b); else tmp = 1.0 / (-1.0 * (a / b)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0], N[(N[(2 * c), $MachinePrecision] / N[(-2 * b), $MachinePrecision]), $MachinePrecision], N[(1 / N[(-1 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 \cdot \frac{a}{b}}\\
\end{array}
Initial program 72.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6472.6%
lift-*.f64N/A
count-2-revN/A
lower-+.f6472.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-neg.f64N/A
remove-double-neg72.6%
Applied rewrites72.6%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6470.3%
Applied rewrites70.3%
Taylor expanded in b around inf
lower-*.f6467.2%
Applied rewrites67.2%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))