
(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}
Sampling outcomes in binary64 precision:
Herbie found 19 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)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (+ C A) (hypot (- A C) B_m)))
(t_1 (fma (* -4.0 A) C (* B_m B_m)))
(t_2 (* (* 2.0 F) t_1))
(t_3 (- t_1))
(t_4 (- (sqrt 2.0)))
(t_5 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_6
(/
(sqrt
(*
(* 2.0 (* t_5 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_5))))
(if (<= t_6 (- INFINITY))
(* (sqrt (* F (/ t_0 (fma (* C A) -4.0 (* B_m B_m))))) t_4)
(if (<= t_6 -1e-203)
(/ (sqrt (* t_0 t_2)) t_3)
(if (<= t_6 INFINITY)
(/ (sqrt (* (+ (- A (* 0.5 (/ (* B_m B_m) C))) A) t_2)) t_3)
(* (sqrt (/ (- F) B_m)) t_4))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = (C + A) - hypot((A - C), B_m);
double t_1 = fma((-4.0 * A), C, (B_m * B_m));
double t_2 = (2.0 * F) * t_1;
double t_3 = -t_1;
double t_4 = -sqrt(2.0);
double t_5 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_6 = sqrt(((2.0 * (t_5 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_5;
double tmp;
if (t_6 <= -((double) INFINITY)) {
tmp = sqrt((F * (t_0 / fma((C * A), -4.0, (B_m * B_m))))) * t_4;
} else if (t_6 <= -1e-203) {
tmp = sqrt((t_0 * t_2)) / t_3;
} else if (t_6 <= ((double) INFINITY)) {
tmp = sqrt((((A - (0.5 * ((B_m * B_m) / C))) + A) * t_2)) / t_3;
} else {
tmp = sqrt((-F / B_m)) * t_4;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(Float64(C + A) - hypot(Float64(A - C), B_m)) t_1 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) t_2 = Float64(Float64(2.0 * F) * t_1) t_3 = Float64(-t_1) t_4 = Float64(-sqrt(2.0)) t_5 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_6 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_5 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_5)) tmp = 0.0 if (t_6 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(t_0 / fma(Float64(C * A), -4.0, Float64(B_m * B_m))))) * t_4); elseif (t_6 <= -1e-203) tmp = Float64(sqrt(Float64(t_0 * t_2)) / t_3); elseif (t_6 <= Inf) tmp = Float64(sqrt(Float64(Float64(Float64(A - Float64(0.5 * Float64(Float64(B_m * B_m) / C))) + A) * t_2)) / t_3); else tmp = Float64(sqrt(Float64(Float64(-F) / B_m)) * t_4); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = (-t$95$1)}, Block[{t$95$4 = (-N[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$5 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$5 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$5)), $MachinePrecision]}, If[LessEqual[t$95$6, (-Infinity)], N[(N[Sqrt[N[(F * N[(t$95$0 / N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$4), $MachinePrecision], If[LessEqual[t$95$6, -1e-203], N[(N[Sqrt[N[(t$95$0 * t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], If[LessEqual[t$95$6, Infinity], N[(N[Sqrt[N[(N[(N[(A - N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + A), $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$3), $MachinePrecision], N[(N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision] * t$95$4), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)\\
t_1 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
t_2 := \left(2 \cdot F\right) \cdot t\_1\\
t_3 := -t\_1\\
t_4 := -\sqrt{2}\\
t_5 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_6 := \frac{\sqrt{\left(2 \cdot \left(t\_5 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_5}\\
\mathbf{if}\;t\_6 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{t\_0}{\mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)}} \cdot t\_4\\
\mathbf{elif}\;t\_6 \leq -1 \cdot 10^{-203}:\\
\;\;\;\;\frac{\sqrt{t\_0 \cdot t\_2}}{t\_3}\\
\mathbf{elif}\;t\_6 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right) + A\right) \cdot t\_2}}{t\_3}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-F}{B\_m}} \cdot t\_4\\
\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 3.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites63.9%
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))) < -1e-203Initial program 98.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites98.5%
if -1e-203 < (/.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 10.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites25.1%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6428.2
Applied rewrites28.2%
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 0.0%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites0.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.2
Applied rewrites3.2%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites4.4%
Taylor expanded in B around inf
Applied rewrites18.3%
Final simplification43.8%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m)))
(t_1 (* (* 2.0 F) t_0))
(t_2 (- t_0))
(t_3 (- (sqrt 2.0)))
(t_4 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_5
(/
(sqrt
(*
(* 2.0 (* t_4 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
(- t_4))))
(if (<= t_5 (- INFINITY))
(*
(sqrt
(*
F
(/ (- (+ C A) (hypot (- A C) B_m)) (fma (* C A) -4.0 (* B_m B_m)))))
t_3)
(if (<= t_5 -1e-203)
(/ (sqrt (* (- (+ C A) (hypot A B_m)) t_1)) t_2)
(if (<= t_5 INFINITY)
(/ (sqrt (* (+ (- A (* 0.5 (/ (* B_m B_m) C))) A) t_1)) t_2)
(* (sqrt (/ (- F) B_m)) t_3))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double t_1 = (2.0 * F) * t_0;
double t_2 = -t_0;
double t_3 = -sqrt(2.0);
double t_4 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_5 = sqrt(((2.0 * (t_4 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / -t_4;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = sqrt((F * (((C + A) - hypot((A - C), B_m)) / fma((C * A), -4.0, (B_m * B_m))))) * t_3;
} else if (t_5 <= -1e-203) {
tmp = sqrt((((C + A) - hypot(A, B_m)) * t_1)) / t_2;
} else if (t_5 <= ((double) INFINITY)) {
tmp = sqrt((((A - (0.5 * ((B_m * B_m) / C))) + A) * t_1)) / t_2;
} else {
tmp = sqrt((-F / B_m)) * t_3;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) t_1 = Float64(Float64(2.0 * F) * t_0) t_2 = Float64(-t_0) t_3 = Float64(-sqrt(2.0)) t_4 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_5 = Float64(sqrt(Float64(Float64(2.0 * Float64(t_4 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / Float64(-t_4)) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(C + A) - hypot(Float64(A - C), B_m)) / fma(Float64(C * A), -4.0, Float64(B_m * B_m))))) * t_3); elseif (t_5 <= -1e-203) tmp = Float64(sqrt(Float64(Float64(Float64(C + A) - hypot(A, B_m)) * t_1)) / t_2); elseif (t_5 <= Inf) tmp = Float64(sqrt(Float64(Float64(Float64(A - Float64(0.5 * Float64(Float64(B_m * B_m) / C))) + A) * t_1)) / t_2); else tmp = Float64(sqrt(Float64(Float64(-F) / B_m)) * t_3); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = (-t$95$0)}, Block[{t$95$3 = (-N[Sqrt[2.0], $MachinePrecision])}, Block[{t$95$4 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[N[(N[(2.0 * N[(t$95$4 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$4)), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(N[Sqrt[N[(F * N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$5, -1e-203], N[(N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$5, Infinity], N[(N[Sqrt[N[(N[(N[(A - N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + A), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], N[(N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision] * t$95$3), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
t_1 := \left(2 \cdot F\right) \cdot t\_0\\
t_2 := -t\_0\\
t_3 := -\sqrt{2}\\
t_4 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_5 := \frac{\sqrt{\left(2 \cdot \left(t\_4 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{-t\_4}\\
\mathbf{if}\;t\_5 \leq -\infty:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)}{\mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)}} \cdot t\_3\\
\mathbf{elif}\;t\_5 \leq -1 \cdot 10^{-203}:\\
\;\;\;\;\frac{\sqrt{\left(\left(C + A\right) - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot t\_1}}{t\_2}\\
\mathbf{elif}\;t\_5 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right) + A\right) \cdot t\_1}}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-F}{B\_m}} \cdot t\_3\\
\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 3.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites63.9%
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))) < -1e-203Initial program 98.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites98.5%
Taylor expanded in C around 0
unpow2N/A
unpow2N/A
lower-hypot.f6478.8
Applied rewrites78.8%
if -1e-203 < (/.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 10.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites25.1%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6428.2
Applied rewrites28.2%
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 0.0%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites0.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.2
Applied rewrites3.2%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites4.4%
Taylor expanded in B around inf
Applied rewrites18.3%
Final simplification40.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m))) (t_1 (- (sqrt 2.0))))
(if (<= B_m 2.25e-29)
(/
(sqrt (* (+ (- A (* 0.5 (/ (* B_m B_m) C))) A) (* (* 2.0 F) t_0)))
(- t_0))
(if (<= B_m 5e+148)
(*
(sqrt
(*
F
(/ (- (+ C A) (hypot (- A C) B_m)) (fma (* C A) -4.0 (* B_m B_m)))))
t_1)
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) t_1)))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double t_1 = -sqrt(2.0);
double tmp;
if (B_m <= 2.25e-29) {
tmp = sqrt((((A - (0.5 * ((B_m * B_m) / C))) + A) * ((2.0 * F) * t_0))) / -t_0;
} else if (B_m <= 5e+148) {
tmp = sqrt((F * (((C + A) - hypot((A - C), B_m)) / fma((C * A), -4.0, (B_m * B_m))))) * t_1;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * t_1;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) t_1 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 2.25e-29) tmp = Float64(sqrt(Float64(Float64(Float64(A - Float64(0.5 * Float64(Float64(B_m * B_m) / C))) + A) * Float64(Float64(2.0 * F) * t_0))) / Float64(-t_0)); elseif (B_m <= 5e+148) tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(C + A) - hypot(Float64(A - C), B_m)) / fma(Float64(C * A), -4.0, Float64(B_m * B_m))))) * t_1); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * t_1); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 2.25e-29], N[(N[Sqrt[N[(N[(N[(A - N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[B$95$m, 5e+148], N[(N[Sqrt[N[(F * N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[(C * A), $MachinePrecision] * -4.0 + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
t_1 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 2.25 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right) + A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{elif}\;B\_m \leq 5 \cdot 10^{+148}:\\
\;\;\;\;\sqrt{F \cdot \frac{\left(C + A\right) - \mathsf{hypot}\left(A - C, B\_m\right)}{\mathsf{fma}\left(C \cdot A, -4, B\_m \cdot B\_m\right)}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot t\_1\\
\end{array}
\end{array}
if B < 2.2499999999999999e-29Initial program 20.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites28.3%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6414.2
Applied rewrites14.2%
if 2.2499999999999999e-29 < B < 5.00000000000000024e148Initial program 38.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites57.3%
if 5.00000000000000024e148 < B Initial program 3.3%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites3.3%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f642.8
Applied rewrites2.8%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites7.5%
Taylor expanded in B around inf
Applied rewrites59.5%
Final simplification26.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.5e-29)
(/
(sqrt (* (+ (- A (* 0.5 (/ (* B_m B_m) C))) A) (* (* 2.0 F) t_0)))
(- t_0))
(if (<= B_m 2.6e+187)
(/ (sqrt (* (* (- A (hypot A B_m)) F) 2.0)) (- B_m))
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) (- (sqrt 2.0)))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double tmp;
if (B_m <= 3.5e-29) {
tmp = sqrt((((A - (0.5 * ((B_m * B_m) / C))) + A) * ((2.0 * F) * t_0))) / -t_0;
} else if (B_m <= 2.6e+187) {
tmp = sqrt((((A - hypot(A, B_m)) * F) * 2.0)) / -B_m;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * -sqrt(2.0);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 3.5e-29) tmp = Float64(sqrt(Float64(Float64(Float64(A - Float64(0.5 * Float64(Float64(B_m * B_m) / C))) + A) * Float64(Float64(2.0 * F) * t_0))) / Float64(-t_0)); elseif (B_m <= 2.6e+187) tmp = Float64(sqrt(Float64(Float64(Float64(A - hypot(A, B_m)) * F) * 2.0)) / Float64(-B_m)); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * Float64(-sqrt(2.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 3.5e-29], N[(N[Sqrt[N[(N[(N[(A - N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+187], N[(N[Sqrt[N[(N[(N[(A - N[Sqrt[A ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 3.5 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right) + A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+187}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - \mathsf{hypot}\left(A, B\_m\right)\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if B < 3.4999999999999997e-29Initial program 20.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites28.3%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6414.2
Applied rewrites14.2%
if 3.4999999999999997e-29 < B < 2.5999999999999999e187Initial program 32.6%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6440.1
Applied rewrites40.1%
Applied rewrites40.3%
if 2.5999999999999999e187 < B Initial program 0.0%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites0.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f642.9
Applied rewrites2.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites4.7%
Taylor expanded in B around inf
Applied rewrites62.8%
Final simplification23.4%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 2.6e+18)
(/
(sqrt (* (+ (- A (* 0.5 (/ (* B_m B_m) C))) A) (* (* 2.0 F) t_0)))
(- t_0))
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) (- (sqrt 2.0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double tmp;
if (B_m <= 2.6e+18) {
tmp = sqrt((((A - (0.5 * ((B_m * B_m) / C))) + A) * ((2.0 * F) * t_0))) / -t_0;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * -sqrt(2.0);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(Float64(Float64(A - Float64(0.5 * Float64(Float64(B_m * B_m) / C))) + A) * Float64(Float64(2.0 * F) * t_0))) / Float64(-t_0)); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * Float64(-sqrt(2.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(N[(N[(A - N[(0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - 0.5 \cdot \frac{B\_m \cdot B\_m}{C}\right) + A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if B < 2.6e18Initial program 22.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites29.8%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-neg.f6414.3
Applied rewrites14.3%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.7%
Final simplification22.6%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.2e+18)
(/ (sqrt (* (+ A A) (* (* 2.0 F) t_0))) (- t_0))
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) (- (sqrt 2.0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = fma((-4.0 * A), C, (B_m * B_m));
double tmp;
if (B_m <= 3.2e+18) {
tmp = sqrt(((A + A) * ((2.0 * F) * t_0))) / -t_0;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * -sqrt(2.0);
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = fma(Float64(-4.0 * A), C, Float64(B_m * B_m)) tmp = 0.0 if (B_m <= 3.2e+18) tmp = Float64(sqrt(Float64(Float64(A + A) * Float64(Float64(2.0 * F) * t_0))) / Float64(-t_0)); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * Float64(-sqrt(2.0))); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 3.2e+18], N[(N[Sqrt[N[(N[(A + A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-t$95$0)), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)\\
\mathbf{if}\;B\_m \leq 3.2 \cdot 10^{+18}:\\
\;\;\;\;\frac{\sqrt{\left(A + A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{-t\_0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\end{array}
\end{array}
if B < 3.2e18Initial program 22.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites29.8%
Taylor expanded in C around inf
mul-1-negN/A
lower--.f64N/A
lower-neg.f6415.1
Applied rewrites15.1%
if 3.2e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.7%
Final simplification23.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 1.2e-127)
(/
(sqrt (* (* -16.0 (* A A)) (* C F)))
(- (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.4e-90)
(/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) t_0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 1.2e-127) {
tmp = sqrt(((-16.0 * (A * A)) * (C * F))) / -fma((-4.0 * A), C, (B_m * B_m));
} else if (B_m <= 3.4e-90) {
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
} else if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * t_0;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 1.2e-127) tmp = Float64(sqrt(Float64(Float64(-16.0 * Float64(A * A)) * Float64(C * F))) / Float64(-fma(Float64(-4.0 * A), C, Float64(B_m * B_m)))); elseif (B_m <= 3.4e-90) tmp = Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)); elseif (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * t_0); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 1.2e-127], N[(N[Sqrt[N[(N[(-16.0 * N[(A * A), $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 3.4e-90], N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 1.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot \left(A \cdot A\right)\right) \cdot \left(C \cdot F\right)}}{-\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)}\\
\mathbf{elif}\;B\_m \leq 3.4 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 1.19999999999999991e-127Initial program 18.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites27.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.4
Applied rewrites13.4%
Taylor expanded in A around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f649.7
Applied rewrites9.7%
if 1.19999999999999991e-127 < B < 3.39999999999999994e-90Initial program 60.3%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6462.0
Applied rewrites62.0%
Applied rewrites62.6%
Taylor expanded in A around 0
Applied rewrites61.9%
if 3.39999999999999994e-90 < B < 2.6e18Initial program 37.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites41.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f649.6
Applied rewrites9.6%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites37.4%
Taylor expanded in A around -inf
Applied rewrites9.4%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.7%
Final simplification20.1%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 1.2e-127)
(/
(sqrt (* (* -16.0 (* A A)) (* C F)))
(- (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.4e-90)
(/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (/ (fma F (/ (+ C A) B_m) (- F)) B_m)) t_0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 1.2e-127) {
tmp = sqrt(((-16.0 * (A * A)) * (C * F))) / -fma((-4.0 * A), C, (B_m * B_m));
} else if (B_m <= 3.4e-90) {
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
} else if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((fma(F, ((C + A) / B_m), -F) / B_m)) * t_0;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 1.2e-127) tmp = Float64(sqrt(Float64(Float64(-16.0 * Float64(A * A)) * Float64(C * F))) / Float64(-fma(Float64(-4.0 * A), C, Float64(B_m * B_m)))); elseif (B_m <= 3.4e-90) tmp = Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)); elseif (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(fma(F, Float64(Float64(C + A) / B_m), Float64(-F)) / B_m)) * t_0); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 1.2e-127], N[(N[Sqrt[N[(N[(-16.0 * N[(A * A), $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 3.4e-90], N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(N[(F * N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] + (-F)), $MachinePrecision] / B$95$m), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 1.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot \left(A \cdot A\right)\right) \cdot \left(C \cdot F\right)}}{-\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)}\\
\mathbf{elif}\;B\_m \leq 3.4 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(F, \frac{C + A}{B\_m}, -F\right)}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 1.19999999999999991e-127Initial program 18.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites27.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.4
Applied rewrites13.4%
Taylor expanded in A around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f649.7
Applied rewrites9.7%
if 1.19999999999999991e-127 < B < 3.39999999999999994e-90Initial program 60.3%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6462.0
Applied rewrites62.0%
Applied rewrites62.6%
Taylor expanded in A around 0
Applied rewrites61.9%
if 3.39999999999999994e-90 < B < 2.6e18Initial program 37.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites41.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f649.6
Applied rewrites9.6%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites37.4%
Taylor expanded in A around -inf
Applied rewrites9.4%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.0%
Final simplification19.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 1.15e-26)
(/
(sqrt (* (* -8.0 A) (* (* C F) (+ A A))))
(- (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (* F (/ (- (/ (+ C A) B_m) 1.0) B_m))) t_0)))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 1.15e-26) {
tmp = sqrt(((-8.0 * A) * ((C * F) * (A + A)))) / -fma((-4.0 * A), C, (B_m * B_m));
} else if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((F * ((((C + A) / B_m) - 1.0) / B_m))) * t_0;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 1.15e-26) tmp = Float64(sqrt(Float64(Float64(-8.0 * A) * Float64(Float64(C * F) * Float64(A + A)))) / Float64(-fma(Float64(-4.0 * A), C, Float64(B_m * B_m)))); elseif (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(Float64(Float64(Float64(C + A) / B_m) - 1.0) / B_m))) * t_0); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 1.15e-26], N[(N[Sqrt[N[(N[(-8.0 * A), $MachinePrecision] * N[(N[(C * F), $MachinePrecision] * N[(A + A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(N[(N[(N[(C + A), $MachinePrecision] / B$95$m), $MachinePrecision] - 1.0), $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 1.15 \cdot 10^{-26}:\\
\;\;\;\;\frac{\sqrt{\left(-8 \cdot A\right) \cdot \left(\left(C \cdot F\right) \cdot \left(A + A\right)\right)}}{-\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{\frac{C + A}{B\_m} - 1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 1.15000000000000004e-26Initial program 20.6%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites28.7%
Taylor expanded in C around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6411.2
Applied rewrites11.2%
if 1.15000000000000004e-26 < B < 2.6e18Initial program 43.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites44.3%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f641.8
Applied rewrites1.8%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites44.6%
Taylor expanded in A around -inf
Applied rewrites9.5%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.7%
Final simplification20.2%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 1.2e-127)
(/
(sqrt (* (* -16.0 (* A A)) (* C F)))
(- (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.4e-90)
(/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (* F (/ -1.0 B_m))) t_0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 1.2e-127) {
tmp = sqrt(((-16.0 * (A * A)) * (C * F))) / -fma((-4.0 * A), C, (B_m * B_m));
} else if (B_m <= 3.4e-90) {
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
} else if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 1.2e-127) tmp = Float64(sqrt(Float64(Float64(-16.0 * Float64(A * A)) * Float64(C * F))) / Float64(-fma(Float64(-4.0 * A), C, Float64(B_m * B_m)))); elseif (B_m <= 3.4e-90) tmp = Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)); elseif (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(-1.0 / B_m))) * t_0); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 1.2e-127], N[(N[Sqrt[N[(N[(-16.0 * N[(A * A), $MachinePrecision]), $MachinePrecision] * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 3.4e-90], N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 1.2 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{\left(-16 \cdot \left(A \cdot A\right)\right) \cdot \left(C \cdot F\right)}}{-\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)}\\
\mathbf{elif}\;B\_m \leq 3.4 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 1.19999999999999991e-127Initial program 18.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites27.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.4
Applied rewrites13.4%
Taylor expanded in A around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f649.7
Applied rewrites9.7%
if 1.19999999999999991e-127 < B < 3.39999999999999994e-90Initial program 60.3%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6462.0
Applied rewrites62.0%
Applied rewrites62.6%
Taylor expanded in A around 0
Applied rewrites61.9%
if 3.39999999999999994e-90 < B < 2.6e18Initial program 37.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites41.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f649.6
Applied rewrites9.6%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites37.4%
Taylor expanded in A around -inf
Applied rewrites9.4%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.3%
Final simplification20.0%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 2.5e-125)
(/
(sqrt (* -16.0 (* (* (* A A) C) F)))
(- (fma (* -4.0 A) C (* B_m B_m))))
(if (<= B_m 3.4e-90)
(/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (* F (/ -1.0 B_m))) t_0))))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 2.5e-125) {
tmp = sqrt((-16.0 * (((A * A) * C) * F))) / -fma((-4.0 * A), C, (B_m * B_m));
} else if (B_m <= 3.4e-90) {
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
} else if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 2.5e-125) tmp = Float64(sqrt(Float64(-16.0 * Float64(Float64(Float64(A * A) * C) * F))) / Float64(-fma(Float64(-4.0 * A), C, Float64(B_m * B_m)))); elseif (B_m <= 3.4e-90) tmp = Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)); elseif (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(-1.0 / B_m))) * t_0); end return tmp end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 2.5e-125], N[(N[Sqrt[N[(-16.0 * N[(N[(N[(A * A), $MachinePrecision] * C), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision])), $MachinePrecision], If[LessEqual[B$95$m, 3.4e-90], N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision], If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 2.5 \cdot 10^{-125}:\\
\;\;\;\;\frac{\sqrt{-16 \cdot \left(\left(\left(A \cdot A\right) \cdot C\right) \cdot F\right)}}{-\mathsf{fma}\left(-4 \cdot A, C, B\_m \cdot B\_m\right)}\\
\mathbf{elif}\;B\_m \leq 3.4 \cdot 10^{-90}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\mathbf{elif}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 2.49999999999999983e-125Initial program 18.5%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites27.0%
Taylor expanded in A around -inf
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f648.1
Applied rewrites8.1%
if 2.49999999999999983e-125 < B < 3.39999999999999994e-90Initial program 60.3%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6462.0
Applied rewrites62.0%
Applied rewrites62.6%
Taylor expanded in A around 0
Applied rewrites61.9%
if 3.39999999999999994e-90 < B < 2.6e18Initial program 37.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites41.0%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f649.6
Applied rewrites9.6%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites37.4%
Taylor expanded in A around -inf
Applied rewrites9.4%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.3%
Final simplification18.9%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 2.6e+18)
(* (sqrt (* F (/ -0.5 C))) t_0)
(* (sqrt (* F (/ -1.0 B_m))) t_0))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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) :: t_0
real(8) :: tmp
t_0 = -sqrt(2.0d0)
if (b_m <= 2.6d+18) then
tmp = sqrt((f * ((-0.5d0) / c))) * t_0
else
tmp = sqrt((f * ((-1.0d0) / b_m))) * t_0
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = -Math.sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = Math.sqrt((F * (-0.5 / C))) * t_0;
} else {
tmp = Math.sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = -math.sqrt(2.0) tmp = 0 if B_m <= 2.6e+18: tmp = math.sqrt((F * (-0.5 / C))) * t_0 else: tmp = math.sqrt((F * (-1.0 / B_m))) * t_0 return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(F * Float64(-0.5 / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(-1.0 / B_m))) * t_0); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = -sqrt(2.0);
tmp = 0.0;
if (B_m <= 2.6e+18)
tmp = sqrt((F * (-0.5 / C))) * t_0;
else
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(F * N[(-0.5 / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{F \cdot \frac{-0.5}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 2.6e18Initial program 22.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites29.8%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.1
Applied rewrites13.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites28.2%
Taylor expanded in A around -inf
Applied rewrites7.8%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.3%
Final simplification17.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 2.6e+18)
(* (sqrt (* -0.5 (/ F C))) t_0)
(* (sqrt (* F (/ -1.0 B_m))) t_0))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = sqrt((-0.5 * (F / C))) * t_0;
} else {
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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) :: t_0
real(8) :: tmp
t_0 = -sqrt(2.0d0)
if (b_m <= 2.6d+18) then
tmp = sqrt(((-0.5d0) * (f / c))) * t_0
else
tmp = sqrt((f * ((-1.0d0) / b_m))) * t_0
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = -Math.sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = Math.sqrt((-0.5 * (F / C))) * t_0;
} else {
tmp = Math.sqrt((F * (-1.0 / B_m))) * t_0;
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = -math.sqrt(2.0) tmp = 0 if B_m <= 2.6e+18: tmp = math.sqrt((-0.5 * (F / C))) * t_0 else: tmp = math.sqrt((F * (-1.0 / B_m))) * t_0 return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / C))) * t_0); else tmp = Float64(sqrt(Float64(F * Float64(-1.0 / B_m))) * t_0); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = -sqrt(2.0);
tmp = 0.0;
if (B_m <= 2.6e+18)
tmp = sqrt((-0.5 * (F / C))) * t_0;
else
tmp = sqrt((F * (-1.0 / B_m))) * t_0;
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(-0.5 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[(F * N[(-1.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{F \cdot \frac{-1}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 2.6e18Initial program 22.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites29.8%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.1
Applied rewrites13.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites28.2%
Taylor expanded in A around -inf
Applied rewrites7.8%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.3%
Final simplification17.5%
B_m = (fabs.f64 B)
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B_m C F)
:precision binary64
(let* ((t_0 (- (sqrt 2.0))))
(if (<= B_m 2.6e+18)
(* (sqrt (* -0.5 (/ F C))) t_0)
(* (sqrt (/ (- F) B_m)) t_0))))B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double t_0 = -sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = sqrt((-0.5 * (F / C))) * t_0;
} else {
tmp = sqrt((-F / B_m)) * t_0;
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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) :: t_0
real(8) :: tmp
t_0 = -sqrt(2.0d0)
if (b_m <= 2.6d+18) then
tmp = sqrt(((-0.5d0) * (f / c))) * t_0
else
tmp = sqrt((-f / b_m)) * t_0
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double t_0 = -Math.sqrt(2.0);
double tmp;
if (B_m <= 2.6e+18) {
tmp = Math.sqrt((-0.5 * (F / C))) * t_0;
} else {
tmp = Math.sqrt((-F / B_m)) * t_0;
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): t_0 = -math.sqrt(2.0) tmp = 0 if B_m <= 2.6e+18: tmp = math.sqrt((-0.5 * (F / C))) * t_0 else: tmp = math.sqrt((-F / B_m)) * t_0 return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) t_0 = Float64(-sqrt(2.0)) tmp = 0.0 if (B_m <= 2.6e+18) tmp = Float64(sqrt(Float64(-0.5 * Float64(F / C))) * t_0); else tmp = Float64(sqrt(Float64(Float64(-F) / B_m)) * t_0); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
t_0 = -sqrt(2.0);
tmp = 0.0;
if (B_m <= 2.6e+18)
tmp = sqrt((-0.5 * (F / C))) * t_0;
else
tmp = sqrt((-F / B_m)) * t_0;
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision]
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
code[A_, B$95$m_, C_, F_] := Block[{t$95$0 = (-N[Sqrt[2.0], $MachinePrecision])}, If[LessEqual[B$95$m, 2.6e+18], N[(N[Sqrt[N[(-0.5 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
t_0 := -\sqrt{2}\\
\mathbf{if}\;B\_m \leq 2.6 \cdot 10^{+18}:\\
\;\;\;\;\sqrt{-0.5 \cdot \frac{F}{C}} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-F}{B\_m}} \cdot t\_0\\
\end{array}
\end{array}
if B < 2.6e18Initial program 22.2%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites29.8%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f6413.1
Applied rewrites13.1%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites28.2%
Taylor expanded in A around -inf
Applied rewrites7.8%
if 2.6e18 < B Initial program 16.7%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites18.4%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f643.9
Applied rewrites3.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites32.6%
Taylor expanded in B around inf
Applied rewrites51.2%
Final simplification17.5%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= F -2e+45) (* (sqrt (/ (- F) B_m)) (- (sqrt 2.0))) (/ (sqrt (* (fma (- B_m) F (* A F)) 2.0)) (- B_m))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2e+45) {
tmp = sqrt((-F / B_m)) * -sqrt(2.0);
} else {
tmp = sqrt((fma(-B_m, F, (A * F)) * 2.0)) / -B_m;
}
return tmp;
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= -2e+45) tmp = Float64(sqrt(Float64(Float64(-F) / B_m)) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(Float64(fma(Float64(-B_m), F, Float64(A * F)) * 2.0)) / Float64(-B_m)); end return tmp end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -2e+45], N[(N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(N[((-B$95$m) * F + N[(A * F), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2 \cdot 10^{+45}:\\
\;\;\;\;\sqrt{\frac{-F}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-B\_m, F, A \cdot F\right) \cdot 2}}{-B\_m}\\
\end{array}
\end{array}
if F < -1.9999999999999999e45Initial program 22.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites22.1%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f648.9
Applied rewrites8.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites29.4%
Taylor expanded in B around inf
Applied rewrites19.0%
if -1.9999999999999999e45 < F Initial program 20.2%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6419.7
Applied rewrites19.7%
Applied rewrites19.8%
Taylor expanded in A around 0
Applied rewrites16.4%
Final simplification17.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (if (<= F -2e+45) (* (sqrt (/ (- F) B_m)) (- (sqrt 2.0))) (/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2e+45) {
tmp = sqrt((-F / B_m)) * -sqrt(2.0);
} else {
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
}
return tmp;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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 <= (-2d+45)) then
tmp = sqrt((-f / b_m)) * -sqrt(2.0d0)
else
tmp = sqrt((((a - b_m) * f) * 2.0d0)) / -b_m
end if
code = tmp
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
double tmp;
if (F <= -2e+45) {
tmp = Math.sqrt((-F / B_m)) * -Math.sqrt(2.0);
} else {
tmp = Math.sqrt((((A - B_m) * F) * 2.0)) / -B_m;
}
return tmp;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): tmp = 0 if F <= -2e+45: tmp = math.sqrt((-F / B_m)) * -math.sqrt(2.0) else: tmp = math.sqrt((((A - B_m) * F) * 2.0)) / -B_m return tmp
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) tmp = 0.0 if (F <= -2e+45) tmp = Float64(sqrt(Float64(Float64(-F) / B_m)) * Float64(-sqrt(2.0))); else tmp = Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)); end return tmp end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp_2 = code(A, B_m, C, F)
tmp = 0.0;
if (F <= -2e+45)
tmp = sqrt((-F / B_m)) * -sqrt(2.0);
else
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
end
tmp_2 = tmp;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := If[LessEqual[F, -2e+45], N[(N[Sqrt[N[((-F) / B$95$m), $MachinePrecision]], $MachinePrecision] * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;F \leq -2 \cdot 10^{+45}:\\
\;\;\;\;\sqrt{\frac{-F}{B\_m}} \cdot \left(-\sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}\\
\end{array}
\end{array}
if F < -1.9999999999999999e45Initial program 22.1%
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
Applied rewrites22.1%
Taylor expanded in A around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower--.f64N/A
lower-neg.f648.9
Applied rewrites8.9%
Taylor expanded in F around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites29.4%
Taylor expanded in B around inf
Applied rewrites19.0%
if -1.9999999999999999e45 < F Initial program 20.2%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6419.7
Applied rewrites19.7%
Applied rewrites19.8%
Taylor expanded in A around 0
Applied rewrites16.4%
Final simplification17.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (/ (sqrt (* (* (- A B_m) F) 2.0)) (- B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((((A - B_m) * F) * 2.0)) / -B_m;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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 = sqrt((((a - b_m) * f) * 2.0d0)) / -b_m
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((((A - B_m) * F) * 2.0)) / -B_m;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((((A - B_m) * F) * 2.0)) / -B_m
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(Float64(Float64(A - B_m) * F) * 2.0)) / Float64(-B_m)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((((A - B_m) * F) * 2.0)) / -B_m;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(N[(N[(A - B$95$m), $MachinePrecision] * F), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{\left(\left(A - B\_m\right) \cdot F\right) \cdot 2}}{-B\_m}
\end{array}
Initial program 21.0%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6415.8
Applied rewrites15.8%
Applied rewrites15.9%
Taylor expanded in A around 0
Applied rewrites12.7%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (/ (sqrt (* -2.0 (* B_m F))) (- B_m)))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((-2.0 * (B_m * F))) / -B_m;
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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 = sqrt(((-2.0d0) * (b_m * f))) / -b_m
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((-2.0 * (B_m * F))) / -B_m;
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((-2.0 * (B_m * F))) / -B_m
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(sqrt(Float64(-2.0 * Float64(B_m * F))) / Float64(-B_m)) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((-2.0 * (B_m * F))) / -B_m;
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[(N[Sqrt[N[(-2.0 * N[(B$95$m * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-B$95$m)), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{\sqrt{-2 \cdot \left(B\_m \cdot F\right)}}{-B\_m}
\end{array}
Initial program 21.0%
Taylor expanded in C around 0
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
unpow2N/A
lower-hypot.f64N/A
lower-/.f64N/A
lower-sqrt.f6415.8
Applied rewrites15.8%
Applied rewrites15.9%
Taylor expanded in A around 0
Applied rewrites13.4%
B_m = (fabs.f64 B) NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. (FPCore (A B_m C F) :precision binary64 (sqrt (* F (/ 2.0 B_m))))
B_m = fabs(B);
assert(A < B_m && B_m < C && C < F);
double code(double A, double B_m, double C, double F) {
return sqrt((F * (2.0 / B_m)));
}
B_m = private
NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function.
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 = sqrt((f * (2.0d0 / b_m)))
end function
B_m = Math.abs(B);
assert A < B_m && B_m < C && C < F;
public static double code(double A, double B_m, double C, double F) {
return Math.sqrt((F * (2.0 / B_m)));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return math.sqrt((F * (2.0 / B_m)))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return sqrt(Float64(F * Float64(2.0 / B_m))) end
B_m = abs(B);
A, B_m, C, F = num2cell(sort([A, B_m, C, F])){:}
function tmp = code(A, B_m, C, F)
tmp = sqrt((F * (2.0 / B_m)));
end
B_m = N[Abs[B], $MachinePrecision] NOTE: A, B_m, C, and F should be sorted in increasing order before calling this function. code[A_, B$95$m_, C_, F_] := N[Sqrt[N[(F * N[(2.0 / B$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\sqrt{F \cdot \frac{2}{B\_m}}
\end{array}
Initial program 21.0%
Taylor expanded in B around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f642.1
Applied rewrites2.1%
Taylor expanded in B around 0
Applied rewrites2.1%
Applied rewrites2.1%
Applied rewrites2.1%
herbie shell --seed 2025017
(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))))