
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (pow (- A C) 2.0))
(t_2 (- (pow B_m 2.0) t_0))
(t_3
(/
(-
(sqrt
(* (* 2.0 (* t_2 F)) (- (+ A C) (sqrt (+ t_1 (pow B_m 2.0)))))))
t_2))
(t_4 (- (* B_m B_m) t_0)))
(if (<= t_3 (- INFINITY))
(* -0.25 (/ (sqrt (* -16.0 (* A F))) A))
(if (<= t_3 -2e-204)
(/
(- (sqrt (* (* 2.0 (* t_4 F)) (- (+ A C) (sqrt (+ t_1 (* B_m B_m)))))))
t_4)
(if (<= t_3 INFINITY)
(* -0.25 (/ (sqrt (* -16.0 (* C F))) C))
(* -1.0 (/ (sqrt (* -2.0 (* B_m F))) B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = pow((A - C), 2.0);
double t_2 = pow(B_m, 2.0) - t_0;
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((t_1 + pow(B_m, 2.0)))))) / t_2;
double t_4 = (B_m * B_m) - t_0;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A);
} else if (t_3 <= -2e-204) {
tmp = -sqrt(((2.0 * (t_4 * F)) * ((A + C) - sqrt((t_1 + (B_m * B_m)))))) / t_4;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = Math.pow((A - C), 2.0);
double t_2 = Math.pow(B_m, 2.0) - t_0;
double t_3 = -Math.sqrt(((2.0 * (t_2 * F)) * ((A + C) - Math.sqrt((t_1 + Math.pow(B_m, 2.0)))))) / t_2;
double t_4 = (B_m * B_m) - t_0;
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = -0.25 * (Math.sqrt((-16.0 * (A * F))) / A);
} else if (t_3 <= -2e-204) {
tmp = -Math.sqrt(((2.0 * (t_4 * F)) * ((A + C) - Math.sqrt((t_1 + (B_m * B_m)))))) / t_4;
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = -0.25 * (Math.sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -1.0 * (Math.sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = (4.0 * A) * C t_1 = math.pow((A - C), 2.0) t_2 = math.pow(B_m, 2.0) - t_0 t_3 = -math.sqrt(((2.0 * (t_2 * F)) * ((A + C) - math.sqrt((t_1 + math.pow(B_m, 2.0)))))) / t_2 t_4 = (B_m * B_m) - t_0 tmp = 0 if t_3 <= -math.inf: tmp = -0.25 * (math.sqrt((-16.0 * (A * F))) / A) elif t_3 <= -2e-204: tmp = -math.sqrt(((2.0 * (t_4 * F)) * ((A + C) - math.sqrt((t_1 + (B_m * B_m)))))) / t_4 elif t_3 <= math.inf: tmp = -0.25 * (math.sqrt((-16.0 * (C * F))) / C) else: tmp = -1.0 * (math.sqrt((-2.0 * (B_m * F))) / B_m) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A - C) ^ 2.0 t_2 = Float64((B_m ^ 2.0) - t_0) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64(t_1 + (B_m ^ 2.0))))))) / t_2) t_4 = Float64(Float64(B_m * B_m) - t_0) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); elseif (t_3 <= -2e-204) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_4 * F)) * Float64(Float64(A + C) - sqrt(Float64(t_1 + Float64(B_m * B_m))))))) / t_4); elseif (t_3 <= Inf) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C)); else tmp = Float64(-1.0 * Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / B_m)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = (4.0 * A) * C; t_1 = (A - C) ^ 2.0; t_2 = (B_m ^ 2.0) - t_0; t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((t_1 + (B_m ^ 2.0)))))) / t_2; t_4 = (B_m * B_m) - t_0; tmp = 0.0; if (t_3 <= -Inf) tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A); elseif (t_3 <= -2e-204) tmp = -sqrt(((2.0 * (t_4 * F)) * ((A + C) - sqrt((t_1 + (B_m * B_m)))))) / t_4; elseif (t_3 <= Inf) tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C); else tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(t$95$1 + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(B$95$m * B$95$m), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -2e-204], N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$4 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(t$95$1 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$4), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := {\left(A - C\right)}^{2}\\
t_2 := {B\_m}^{2} - t\_0\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t\_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{t\_1 + {B\_m}^{2}}\right)}}{t\_2}\\
t_4 := B\_m \cdot B\_m - t\_0\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\mathbf{elif}\;t\_3 \leq -2 \cdot 10^{-204}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t\_4 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{t\_1 + B\_m \cdot B\_m}\right)}}{t\_4}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{B\_m}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 18.1%
Taylor expanded in C around -inf
Applied rewrites19.8%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -2e-204Initial program 18.1%
Applied rewrites18.1%
Applied rewrites18.1%
Applied rewrites18.1%
if -2e-204 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 18.1%
Taylor expanded in A around -inf
Applied rewrites18.7%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (* (* 4.0 A) C))
(t_1 (pow (- A C) 2.0))
(t_2 (- (pow B_m 2.0) t_0))
(t_3
(/
(-
(sqrt
(* (* 2.0 (* t_2 F)) (- (+ A C) (sqrt (+ t_1 (pow B_m 2.0)))))))
t_2))
(t_4 (- (* B_m B_m) t_0)))
(if (<= t_3 (- INFINITY))
(* -0.25 (/ (sqrt (* -16.0 (* A F))) A))
(if (<= t_3 -2e-204)
(/
(- (sqrt (* (* 2.0 (* t_4 F)) (- C (sqrt (+ t_1 (* B_m B_m)))))))
t_4)
(if (<= t_3 INFINITY)
(* -0.25 (/ (sqrt (* -16.0 (* C F))) C))
(* -1.0 (/ (sqrt (* -2.0 (* B_m F))) B_m)))))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = pow((A - C), 2.0);
double t_2 = pow(B_m, 2.0) - t_0;
double t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((t_1 + pow(B_m, 2.0)))))) / t_2;
double t_4 = (B_m * B_m) - t_0;
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A);
} else if (t_3 <= -2e-204) {
tmp = -sqrt(((2.0 * (t_4 * F)) * (C - sqrt((t_1 + (B_m * B_m)))))) / t_4;
} else if (t_3 <= ((double) INFINITY)) {
tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double t_0 = (4.0 * A) * C;
double t_1 = Math.pow((A - C), 2.0);
double t_2 = Math.pow(B_m, 2.0) - t_0;
double t_3 = -Math.sqrt(((2.0 * (t_2 * F)) * ((A + C) - Math.sqrt((t_1 + Math.pow(B_m, 2.0)))))) / t_2;
double t_4 = (B_m * B_m) - t_0;
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = -0.25 * (Math.sqrt((-16.0 * (A * F))) / A);
} else if (t_3 <= -2e-204) {
tmp = -Math.sqrt(((2.0 * (t_4 * F)) * (C - Math.sqrt((t_1 + (B_m * B_m)))))) / t_4;
} else if (t_3 <= Double.POSITIVE_INFINITY) {
tmp = -0.25 * (Math.sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -1.0 * (Math.sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): t_0 = (4.0 * A) * C t_1 = math.pow((A - C), 2.0) t_2 = math.pow(B_m, 2.0) - t_0 t_3 = -math.sqrt(((2.0 * (t_2 * F)) * ((A + C) - math.sqrt((t_1 + math.pow(B_m, 2.0)))))) / t_2 t_4 = (B_m * B_m) - t_0 tmp = 0 if t_3 <= -math.inf: tmp = -0.25 * (math.sqrt((-16.0 * (A * F))) / A) elif t_3 <= -2e-204: tmp = -math.sqrt(((2.0 * (t_4 * F)) * (C - math.sqrt((t_1 + (B_m * B_m)))))) / t_4 elif t_3 <= math.inf: tmp = -0.25 * (math.sqrt((-16.0 * (C * F))) / C) else: tmp = -1.0 * (math.sqrt((-2.0 * (B_m * F))) / B_m) return tmp
B_m = abs(B) function code(A, B_m, C, F) t_0 = Float64(Float64(4.0 * A) * C) t_1 = Float64(A - C) ^ 2.0 t_2 = Float64((B_m ^ 2.0) - t_0) t_3 = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_2 * F)) * Float64(Float64(A + C) - sqrt(Float64(t_1 + (B_m ^ 2.0))))))) / t_2) t_4 = Float64(Float64(B_m * B_m) - t_0) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); elseif (t_3 <= -2e-204) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_4 * F)) * Float64(C - sqrt(Float64(t_1 + Float64(B_m * B_m))))))) / t_4); elseif (t_3 <= Inf) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C)); else tmp = Float64(-1.0 * Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / B_m)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) t_0 = (4.0 * A) * C; t_1 = (A - C) ^ 2.0; t_2 = (B_m ^ 2.0) - t_0; t_3 = -sqrt(((2.0 * (t_2 * F)) * ((A + C) - sqrt((t_1 + (B_m ^ 2.0)))))) / t_2; t_4 = (B_m * B_m) - t_0; tmp = 0.0; if (t_3 <= -Inf) tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A); elseif (t_3 <= -2e-204) tmp = -sqrt(((2.0 * (t_4 * F)) * (C - sqrt((t_1 + (B_m * B_m)))))) / t_4; elseif (t_3 <= Inf) tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C); else tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision]
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$2 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(t$95$1 + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(B$95$m * B$95$m), $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, -2e-204], N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$4 * F), $MachinePrecision]), $MachinePrecision] * N[(C - N[Sqrt[N[(t$95$1 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$4), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
t_0 := \left(4 \cdot A\right) \cdot C\\
t_1 := {\left(A - C\right)}^{2}\\
t_2 := {B\_m}^{2} - t\_0\\
t_3 := \frac{-\sqrt{\left(2 \cdot \left(t\_2 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{t\_1 + {B\_m}^{2}}\right)}}{t\_2}\\
t_4 := B\_m \cdot B\_m - t\_0\\
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\mathbf{elif}\;t\_3 \leq -2 \cdot 10^{-204}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot \left(t\_4 \cdot F\right)\right) \cdot \left(C - \sqrt{t\_1 + B\_m \cdot B\_m}\right)}}{t\_4}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{B\_m}\\
\end{array}
\end{array}
if (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -inf.0Initial program 18.1%
Taylor expanded in C around -inf
Applied rewrites19.8%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -2e-204Initial program 18.1%
Applied rewrites18.1%
Applied rewrites18.1%
Applied rewrites18.1%
Taylor expanded in A around 0
Applied rewrites14.3%
if -2e-204 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < +inf.0Initial program 18.1%
Taylor expanded in A around -inf
Applied rewrites18.7%
if +inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (-.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= F -5e-65)
(* -1.0 (sqrt (* -2.0 (/ F B_m))))
(if (<= F -4e-309)
(* -1.0 (/ (sqrt (* -2.0 (* B_m F))) B_m))
(* -0.25 (/ (sqrt (* -16.0 (* C F))) C)))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * sqrt((-2.0 * (F / B_m)));
} else if (F <= -4e-309) {
tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m);
} else {
tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C);
}
return tmp;
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (f <= (-5d-65)) then
tmp = (-1.0d0) * sqrt(((-2.0d0) * (f / b_m)))
else if (f <= (-4d-309)) then
tmp = (-1.0d0) * (sqrt(((-2.0d0) * (b_m * f))) / b_m)
else
tmp = (-0.25d0) * (sqrt(((-16.0d0) * (c * f))) / c)
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * Math.sqrt((-2.0 * (F / B_m)));
} else if (F <= -4e-309) {
tmp = -1.0 * (Math.sqrt((-2.0 * (B_m * F))) / B_m);
} else {
tmp = -0.25 * (Math.sqrt((-16.0 * (C * F))) / C);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if F <= -5e-65: tmp = -1.0 * math.sqrt((-2.0 * (F / B_m))) elif F <= -4e-309: tmp = -1.0 * (math.sqrt((-2.0 * (B_m * F))) / B_m) else: tmp = -0.25 * (math.sqrt((-16.0 * (C * F))) / C) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= -5e-65) tmp = Float64(-1.0 * sqrt(Float64(-2.0 * Float64(F / B_m)))); elseif (F <= -4e-309) tmp = Float64(-1.0 * Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / B_m)); else tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (F <= -5e-65) tmp = -1.0 * sqrt((-2.0 * (F / B_m))); elseif (F <= -4e-309) tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m); else tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -5e-65], N[(-1.0 * N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -4e-309], N[(-1.0 * N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-65}:\\
\;\;\;\;-1 \cdot \sqrt{-2 \cdot \frac{F}{B\_m}}\\
\mathbf{elif}\;F \leq -4 \cdot 10^{-309}:\\
\;\;\;\;-1 \cdot \frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{B\_m}\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
\end{array}
\end{array}
if F < -4.99999999999999983e-65Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
if -4.99999999999999983e-65 < F < -3.9999999999999977e-309Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
if -3.9999999999999977e-309 < F Initial program 18.1%
Taylor expanded in A around -inf
Applied rewrites18.7%
B_m = (fabs.f64 B)
(FPCore (A B_m C F)
:precision binary64
(if (<= F -5e-65)
(* -1.0 (sqrt (* -2.0 (/ F B_m))))
(if (<= F -5e-311)
(* -1.0 (/ (sqrt (* -2.0 (* B_m F))) B_m))
(* -0.25 (/ (sqrt (* -16.0 (* A F))) A)))))B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * sqrt((-2.0 * (F / B_m)));
} else if (F <= -5e-311) {
tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m);
} else {
tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A);
}
return tmp;
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (f <= (-5d-65)) then
tmp = (-1.0d0) * sqrt(((-2.0d0) * (f / b_m)))
else if (f <= (-5d-311)) then
tmp = (-1.0d0) * (sqrt(((-2.0d0) * (b_m * f))) / b_m)
else
tmp = (-0.25d0) * (sqrt(((-16.0d0) * (a * f))) / a)
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * Math.sqrt((-2.0 * (F / B_m)));
} else if (F <= -5e-311) {
tmp = -1.0 * (Math.sqrt((-2.0 * (B_m * F))) / B_m);
} else {
tmp = -0.25 * (Math.sqrt((-16.0 * (A * F))) / A);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if F <= -5e-65: tmp = -1.0 * math.sqrt((-2.0 * (F / B_m))) elif F <= -5e-311: tmp = -1.0 * (math.sqrt((-2.0 * (B_m * F))) / B_m) else: tmp = -0.25 * (math.sqrt((-16.0 * (A * F))) / A) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= -5e-65) tmp = Float64(-1.0 * sqrt(Float64(-2.0 * Float64(F / B_m)))); elseif (F <= -5e-311) tmp = Float64(-1.0 * Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / B_m)); else tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (F <= -5e-65) tmp = -1.0 * sqrt((-2.0 * (F / B_m))); elseif (F <= -5e-311) tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m); else tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -5e-65], N[(-1.0 * N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, -5e-311], N[(-1.0 * N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-65}:\\
\;\;\;\;-1 \cdot \sqrt{-2 \cdot \frac{F}{B\_m}}\\
\mathbf{elif}\;F \leq -5 \cdot 10^{-311}:\\
\;\;\;\;-1 \cdot \frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{B\_m}\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\end{array}
\end{array}
if F < -4.99999999999999983e-65Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
if -4.99999999999999983e-65 < F < -5.00000000000023e-311Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
if -5.00000000000023e-311 < F Initial program 18.1%
Taylor expanded in C around -inf
Applied rewrites19.8%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (if (<= F -5e-65) (* -1.0 (sqrt (* -2.0 (/ F B_m)))) (* -1.0 (/ (sqrt (* -2.0 (* B_m F))) B_m))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * sqrt((-2.0 * (F / B_m)));
} else {
tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: tmp
if (f <= (-5d-65)) then
tmp = (-1.0d0) * sqrt(((-2.0d0) * (f / b_m)))
else
tmp = (-1.0d0) * (sqrt(((-2.0d0) * (b_m * f))) / b_m)
end if
code = tmp
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -5e-65) {
tmp = -1.0 * Math.sqrt((-2.0 * (F / B_m)));
} else {
tmp = -1.0 * (Math.sqrt((-2.0 * (B_m * F))) / B_m);
}
return tmp;
}
B_m = math.fabs(B) def code(A, B_m, C, F): tmp = 0 if F <= -5e-65: tmp = -1.0 * math.sqrt((-2.0 * (F / B_m))) else: tmp = -1.0 * (math.sqrt((-2.0 * (B_m * F))) / B_m) return tmp
B_m = abs(B) function code(A, B_m, C, F) tmp = 0.0 if (F <= -5e-65) tmp = Float64(-1.0 * sqrt(Float64(-2.0 * Float64(F / B_m)))); else tmp = Float64(-1.0 * Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / B_m)); end return tmp end
B_m = abs(B); function tmp_2 = code(A, B_m, C, F) tmp = 0.0; if (F <= -5e-65) tmp = -1.0 * sqrt((-2.0 * (F / B_m))); else tmp = -1.0 * (sqrt((-2.0 * (B_m * F))) / B_m); end tmp_2 = tmp; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -5e-65], N[(-1.0 * N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
\begin{array}{l}
\mathbf{if}\;F \leq -5 \cdot 10^{-65}:\\
\;\;\;\;-1 \cdot \sqrt{-2 \cdot \frac{F}{B\_m}}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{B\_m}\\
\end{array}
\end{array}
if F < -4.99999999999999983e-65Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
if -4.99999999999999983e-65 < F Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (* -1.0 (sqrt (* -2.0 (/ F B_m)))))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return -1.0 * sqrt((-2.0 * (F / B_m)));
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-1.0d0) * sqrt(((-2.0d0) * (f / b_m)))
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return -1.0 * Math.sqrt((-2.0 * (F / B_m)));
}
B_m = math.fabs(B) def code(A, B_m, C, F): return -1.0 * math.sqrt((-2.0 * (F / B_m)))
B_m = abs(B) function code(A, B_m, C, F) return Float64(-1.0 * sqrt(Float64(-2.0 * Float64(F / B_m)))) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = -1.0 * sqrt((-2.0 * (F / B_m))); end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(-1.0 * N[Sqrt[N[(-2.0 * N[(F / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
-1 \cdot \sqrt{-2 \cdot \frac{F}{B\_m}}
\end{array}
Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 (* -1.0 (* (sqrt (* F -2.0)) 2.0)))
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return -1.0 * (sqrt((F * -2.0)) * 2.0);
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = (-1.0d0) * (sqrt((f * (-2.0d0))) * 2.0d0)
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return -1.0 * (Math.sqrt((F * -2.0)) * 2.0);
}
B_m = math.fabs(B) def code(A, B_m, C, F): return -1.0 * (math.sqrt((F * -2.0)) * 2.0)
B_m = abs(B) function code(A, B_m, C, F) return Float64(-1.0 * Float64(sqrt(Float64(F * -2.0)) * 2.0)) end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = -1.0 * (sqrt((F * -2.0)) * 2.0); end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := N[(-1.0 * N[(N[Sqrt[N[(F * -2.0), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
-1 \cdot \left(\sqrt{F \cdot -2} \cdot 2\right)
\end{array}
Initial program 18.1%
Taylor expanded in B around inf
Applied rewrites26.6%
Taylor expanded in B around 0
Applied rewrites26.3%
Applied rewrites5.3%
B_m = (fabs.f64 B) (FPCore (A B_m C F) :precision binary64 -1.0)
B_m = fabs(B);
double code(double A, double B_m, double C, double F) {
return -1.0;
}
B_m = private
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_m, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b_m
real(8), intent (in) :: c
real(8), intent (in) :: f
code = -1.0d0
end function
B_m = Math.abs(B);
public static double code(double A, double B_m, double C, double F) {
return -1.0;
}
B_m = math.fabs(B) def code(A, B_m, C, F): return -1.0
B_m = abs(B) function code(A, B_m, C, F) return -1.0 end
B_m = abs(B); function tmp = code(A, B_m, C, F) tmp = -1.0; end
B_m = N[Abs[B], $MachinePrecision] code[A_, B$95$m_, C_, F_] := -1.0
\begin{array}{l}
B_m = \left|B\right|
\\
-1
\end{array}
Initial program 18.1%
Taylor expanded in B around -inf
Applied rewrites0.8%
Applied rewrites5.3%
herbie shell --seed 2025159
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))