
(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 16 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 (- (* -1.0 (pow B_m 2.0)) (* (* -1.0 (* 4.0 A)) C)))
(t_1 (- (pow B_m 2.0) (* (* 4.0 A) C)))
(t_2 (* 2.0 (* t_1 F)))
(t_3
(/
(sqrt (* t_2 (+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B_m 2.0))))))
t_0)))
(if (<= t_3 -5e-165)
(/
(*
(* (* (pow F 0.5) (sqrt (- (* B_m B_m) (* 4.0 (* A C))))) (pow 2.0 0.5))
(* -1.0 (sqrt (+ (+ A C) (hypot (- A C) B_m)))))
t_1)
(if (<= t_3 1e+257)
(/ (sqrt (* t_2 (fma -0.5 (/ (* B_m B_m) A) (* 2.0 C)))) t_0)
(if (<= t_3 INFINITY)
(* (pow (* -0.5 (/ F A)) 0.5) (pow 2.0 0.5))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma
(pow B_m 0.5)
(pow F 0.5)
(* 0.5 (* (pow (/ F B_m) 0.5) C)))))))))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 = (-1.0 * pow(B_m, 2.0)) - ((-1.0 * (4.0 * A)) * C);
double t_1 = pow(B_m, 2.0) - ((4.0 * A) * C);
double t_2 = 2.0 * (t_1 * F);
double t_3 = sqrt((t_2 * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B_m, 2.0)))))) / t_0;
double tmp;
if (t_3 <= -5e-165) {
tmp = (((pow(F, 0.5) * sqrt(((B_m * B_m) - (4.0 * (A * C))))) * pow(2.0, 0.5)) * (-1.0 * sqrt(((A + C) + hypot((A - C), B_m))))) / t_1;
} else if (t_3 <= 1e+257) {
tmp = sqrt((t_2 * fma(-0.5, ((B_m * B_m) / A), (2.0 * C)))) / t_0;
} else if (t_3 <= ((double) INFINITY)) {
tmp = pow((-0.5 * (F / A)), 0.5) * pow(2.0, 0.5);
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(-1.0 * (B_m ^ 2.0)) - Float64(Float64(-1.0 * Float64(4.0 * A)) * C)) t_1 = Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_2 = Float64(2.0 * Float64(t_1 * F)) t_3 = Float64(sqrt(Float64(t_2 * Float64(Float64(A + C) + sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0)))))) / t_0) tmp = 0.0 if (t_3 <= -5e-165) tmp = Float64(Float64(Float64(Float64((F ^ 0.5) * sqrt(Float64(Float64(B_m * B_m) - Float64(4.0 * Float64(A * C))))) * (2.0 ^ 0.5)) * Float64(-1.0 * sqrt(Float64(Float64(A + C) + hypot(Float64(A - C), B_m))))) / t_1); elseif (t_3 <= 1e+257) tmp = Float64(sqrt(Float64(t_2 * fma(-0.5, Float64(Float64(B_m * B_m) / A), Float64(2.0 * C)))) / t_0); elseif (t_3 <= Inf) tmp = Float64((Float64(-0.5 * Float64(F / A)) ^ 0.5) * (2.0 ^ 0.5)); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[(-1.0 * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(4.0 * A), $MachinePrecision]), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 * N[(t$95$1 * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(t$95$2 * 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$0), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-165], N[(N[(N[(N[(N[Power[F, 0.5], $MachinePrecision] * N[Sqrt[N[(N[(B$95$m * B$95$m), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Sqrt[N[(N[(A + C), $MachinePrecision] + N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B$95$m ^ 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], If[LessEqual[t$95$3, 1e+257], N[(N[Sqrt[N[(t$95$2 * N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[Power[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := -1 \cdot {B\_m}^{2} - \left(-1 \cdot \left(4 \cdot A\right)\right) \cdot C\\
t_1 := {B\_m}^{2} - \left(4 \cdot A\right) \cdot C\\
t_2 := 2 \cdot \left(t\_1 \cdot F\right)\\
t_3 := \frac{\sqrt{t\_2 \cdot \left(\left(A + C\right) + \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\right)}}{t\_0}\\
\mathbf{if}\;t\_3 \leq -5 \cdot 10^{-165}:\\
\;\;\;\;\frac{\left(\left({F}^{0.5} \cdot \sqrt{B\_m \cdot B\_m - 4 \cdot \left(A \cdot C\right)}\right) \cdot {2}^{0.5}\right) \cdot \left(-1 \cdot \sqrt{\left(A + C\right) + \mathsf{hypot}\left(A - C, B\_m\right)}\right)}{t\_1}\\
\mathbf{elif}\;t\_3 \leq 10^{+257}:\\
\;\;\;\;\frac{\sqrt{t\_2 \cdot \mathsf{fma}\left(-0.5, \frac{B\_m \cdot B\_m}{A}, 2 \cdot C\right)}}{t\_0}\\
\mathbf{elif}\;t\_3 \leq \infty:\\
\;\;\;\;{\left(-0.5 \cdot \frac{F}{A}\right)}^{0.5} \cdot {2}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\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))) < -4.99999999999999981e-165Initial program 41.7%
Applied rewrites64.0%
Taylor expanded in F around 0
lower-*.f64N/A
sqrt-prodN/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f6472.5
Applied rewrites72.5%
if -4.99999999999999981e-165 < (/.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))) < 1.00000000000000003e257Initial program 24.5%
Taylor expanded in A around -inf
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6443.4
Applied rewrites43.4%
if 1.00000000000000003e257 < (/.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 4.1%
Taylor expanded in F around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites10.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-/.f6457.9
Applied rewrites57.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))) Initial program 0.0%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites2.0%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6418.1
Applied rewrites18.1%
Final simplification44.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 (+ (pow (- A C) 2.0) (pow B_m 2.0))))
(t_1 (* 2.0 (* (- (pow B_m 2.0) (* (* 4.0 A) C)) F)))
(t_2 (- (* -1.0 (pow B_m 2.0)) (* (* -1.0 (* 4.0 A)) C)))
(t_3 (/ (sqrt (* t_1 (fma -0.5 (/ (* B_m B_m) A) (* 2.0 C)))) t_2))
(t_4 (/ (sqrt (* t_1 (+ (+ A C) t_0))) t_2)))
(if (<= t_4 (- INFINITY))
t_3
(if (<= t_4 -5e-165)
(/ (sqrt (* t_1 (+ C t_0))) t_2)
(if (<= t_4 1e+257)
t_3
(if (<= t_4 INFINITY)
(* (pow (* -0.5 (/ F A)) 0.5) (pow 2.0 0.5))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma
(pow B_m 0.5)
(pow F 0.5)
(* 0.5 (* (pow (/ F B_m) 0.5) C))))))))))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((pow((A - C), 2.0) + pow(B_m, 2.0)));
double t_1 = 2.0 * ((pow(B_m, 2.0) - ((4.0 * A) * C)) * F);
double t_2 = (-1.0 * pow(B_m, 2.0)) - ((-1.0 * (4.0 * A)) * C);
double t_3 = sqrt((t_1 * fma(-0.5, ((B_m * B_m) / A), (2.0 * C)))) / t_2;
double t_4 = sqrt((t_1 * ((A + C) + t_0))) / t_2;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = t_3;
} else if (t_4 <= -5e-165) {
tmp = sqrt((t_1 * (C + t_0))) / t_2;
} else if (t_4 <= 1e+257) {
tmp = t_3;
} else if (t_4 <= ((double) INFINITY)) {
tmp = pow((-0.5 * (F / A)), 0.5) * pow(2.0, 0.5);
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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 = sqrt(Float64((Float64(A - C) ^ 2.0) + (B_m ^ 2.0))) t_1 = Float64(2.0 * Float64(Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) * F)) t_2 = Float64(Float64(-1.0 * (B_m ^ 2.0)) - Float64(Float64(-1.0 * Float64(4.0 * A)) * C)) t_3 = Float64(sqrt(Float64(t_1 * fma(-0.5, Float64(Float64(B_m * B_m) / A), Float64(2.0 * C)))) / t_2) t_4 = Float64(sqrt(Float64(t_1 * Float64(Float64(A + C) + t_0))) / t_2) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = t_3; elseif (t_4 <= -5e-165) tmp = Float64(sqrt(Float64(t_1 * Float64(C + t_0))) / t_2); elseif (t_4 <= 1e+257) tmp = t_3; elseif (t_4 <= Inf) tmp = Float64((Float64(-0.5 * Float64(F / A)) ^ 0.5) * (2.0 ^ 0.5)); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-1.0 * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(4.0 * A), $MachinePrecision]), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(t$95$1 * N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(t$95$1 * N[(N[(A + C), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], t$95$3, If[LessEqual[t$95$4, -5e-165], N[(N[Sqrt[N[(t$95$1 * N[(C + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[t$95$4, 1e+257], t$95$3, If[LessEqual[t$95$4, Infinity], N[(N[Power[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := \sqrt{{\left(A - C\right)}^{2} + {B\_m}^{2}}\\
t_1 := 2 \cdot \left(\left({B\_m}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\\
t_2 := -1 \cdot {B\_m}^{2} - \left(-1 \cdot \left(4 \cdot A\right)\right) \cdot C\\
t_3 := \frac{\sqrt{t\_1 \cdot \mathsf{fma}\left(-0.5, \frac{B\_m \cdot B\_m}{A}, 2 \cdot C\right)}}{t\_2}\\
t_4 := \frac{\sqrt{t\_1 \cdot \left(\left(A + C\right) + t\_0\right)}}{t\_2}\\
\mathbf{if}\;t\_4 \leq -\infty:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq -5 \cdot 10^{-165}:\\
\;\;\;\;\frac{\sqrt{t\_1 \cdot \left(C + t\_0\right)}}{t\_2}\\
\mathbf{elif}\;t\_4 \leq 10^{+257}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq \infty:\\
\;\;\;\;{\left(-0.5 \cdot \frac{F}{A}\right)}^{0.5} \cdot {2}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\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.0 or -4.99999999999999981e-165 < (/.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))) < 1.00000000000000003e257Initial program 13.2%
Taylor expanded in A around -inf
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6433.7
Applied rewrites33.7%
if -inf.0 < (/.f64 (neg.f64 (sqrt.f64 (*.f64 (*.f64 #s(literal 2 binary64) (*.f64 (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C)) F)) (+.f64 (+.f64 A C) (sqrt.f64 (+.f64 (pow.f64 (-.f64 A C) #s(literal 2 binary64)) (pow.f64 B #s(literal 2 binary64)))))))) (-.f64 (pow.f64 B #s(literal 2 binary64)) (*.f64 (*.f64 #s(literal 4 binary64) A) C))) < -4.99999999999999981e-165Initial program 98.3%
Taylor expanded in A around 0
Applied rewrites85.1%
if 1.00000000000000003e257 < (/.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 4.1%
Taylor expanded in F around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites10.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-/.f6457.9
Applied rewrites57.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))) Initial program 0.0%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites2.0%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6418.1
Applied rewrites18.1%
Final simplification36.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 (- (* -1.0 (pow B_m 2.0)) (* (* -1.0 (* 4.0 A)) C))))
(if (<= B_m 9.6e-35)
(/
(sqrt
(*
(* 2.0 (* (- (pow B_m 2.0) (* (* 4.0 A) C)) F))
(fma -0.5 (/ (* B_m B_m) A) (* 2.0 C))))
t_0)
(if (<= B_m 3.6e+51)
(/
(*
(*
(sqrt F)
(sqrt
(*
(+ A (+ C (pow (fma B_m B_m (pow (- A C) 2.0)) 0.5)))
(- (* B_m B_m) (* 4.0 (* A C))))))
(pow 2.0 0.5))
t_0)
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma (pow B_m 0.5) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C))))))))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 = (-1.0 * pow(B_m, 2.0)) - ((-1.0 * (4.0 * A)) * C);
double tmp;
if (B_m <= 9.6e-35) {
tmp = sqrt(((2.0 * ((pow(B_m, 2.0) - ((4.0 * A) * C)) * F)) * fma(-0.5, ((B_m * B_m) / A), (2.0 * C)))) / t_0;
} else if (B_m <= 3.6e+51) {
tmp = ((sqrt(F) * sqrt(((A + (C + pow(fma(B_m, B_m, pow((A - C), 2.0)), 0.5))) * ((B_m * B_m) - (4.0 * (A * C)))))) * pow(2.0, 0.5)) / t_0;
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(-1.0 * (B_m ^ 2.0)) - Float64(Float64(-1.0 * Float64(4.0 * A)) * C)) tmp = 0.0 if (B_m <= 9.6e-35) tmp = Float64(sqrt(Float64(Float64(2.0 * Float64(Float64((B_m ^ 2.0) - Float64(Float64(4.0 * A) * C)) * F)) * fma(-0.5, Float64(Float64(B_m * B_m) / A), Float64(2.0 * C)))) / t_0); elseif (B_m <= 3.6e+51) tmp = Float64(Float64(Float64(sqrt(F) * sqrt(Float64(Float64(A + Float64(C + (fma(B_m, B_m, (Float64(A - C) ^ 2.0)) ^ 0.5))) * Float64(Float64(B_m * B_m) - Float64(4.0 * Float64(A * C)))))) * (2.0 ^ 0.5)) / t_0); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[(-1.0 * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(4.0 * A), $MachinePrecision]), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B$95$m, 9.6e-35], N[(N[Sqrt[N[(N[(2.0 * N[(N[(N[Power[B$95$m, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision] * N[(-0.5 * N[(N[(B$95$m * B$95$m), $MachinePrecision] / A), $MachinePrecision] + N[(2.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[B$95$m, 3.6e+51], N[(N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(N[(A + N[(C + N[Power[N[(B$95$m * B$95$m + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(B$95$m * B$95$m), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := -1 \cdot {B\_m}^{2} - \left(-1 \cdot \left(4 \cdot A\right)\right) \cdot C\\
\mathbf{if}\;B\_m \leq 9.6 \cdot 10^{-35}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot \left(\left({B\_m}^{2} - \left(4 \cdot A\right) \cdot C\right) \cdot F\right)\right) \cdot \mathsf{fma}\left(-0.5, \frac{B\_m \cdot B\_m}{A}, 2 \cdot C\right)}}{t\_0}\\
\mathbf{elif}\;B\_m \leq 3.6 \cdot 10^{+51}:\\
\;\;\;\;\frac{\left(\sqrt{F} \cdot \sqrt{\left(A + \left(C + {\left(\mathsf{fma}\left(B\_m, B\_m, {\left(A - C\right)}^{2}\right)\right)}^{0.5}\right)\right) \cdot \left(B\_m \cdot B\_m - 4 \cdot \left(A \cdot C\right)\right)}\right) \cdot {2}^{0.5}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if B < 9.6000000000000005e-35Initial program 19.9%
Taylor expanded in A around -inf
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6419.4
Applied rewrites19.4%
if 9.6000000000000005e-35 < B < 3.60000000000000011e51Initial program 45.7%
Taylor expanded in F around 0
lower-*.f64N/A
Applied rewrites56.3%
if 3.60000000000000011e51 < B Initial program 5.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites13.7%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Final simplification29.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 (<= B_m 1.15e-29)
(/
(sqrt
(*
C
(fma
-16.0
(* A (* C F))
(* 2.0 (* F (fma -4.0 (* A (- A A)) (* 2.0 (* B_m B_m))))))))
(- (* -1.0 (pow B_m 2.0)) (* (* -1.0 (* 4.0 A)) C)))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma (pow B_m 0.5) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C))))))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 (B_m <= 1.15e-29) {
tmp = sqrt((C * fma(-16.0, (A * (C * F)), (2.0 * (F * fma(-4.0, (A * (A - A)), (2.0 * (B_m * B_m)))))))) / ((-1.0 * pow(B_m, 2.0)) - ((-1.0 * (4.0 * A)) * C));
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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 (B_m <= 1.15e-29) tmp = Float64(sqrt(Float64(C * fma(-16.0, Float64(A * Float64(C * F)), Float64(2.0 * Float64(F * fma(-4.0, Float64(A * Float64(A - A)), Float64(2.0 * Float64(B_m * B_m)))))))) / Float64(Float64(-1.0 * (B_m ^ 2.0)) - Float64(Float64(-1.0 * Float64(4.0 * A)) * C))); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[B$95$m, 1.15e-29], N[(N[Sqrt[N[(C * N[(-16.0 * N[(A * N[(C * F), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(F * N[(-4.0 * N[(A * N[(A - A), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(B$95$m * B$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(-1.0 * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(4.0 * A), $MachinePrecision]), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;B\_m \leq 1.15 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{C \cdot \mathsf{fma}\left(-16, A \cdot \left(C \cdot F\right), 2 \cdot \left(F \cdot \mathsf{fma}\left(-4, A \cdot \left(A - A\right), 2 \cdot \left(B\_m \cdot B\_m\right)\right)\right)\right)}}{-1 \cdot {B\_m}^{2} - \left(-1 \cdot \left(4 \cdot A\right)\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if B < 1.14999999999999996e-29Initial program 20.2%
Taylor expanded in C around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites11.6%
Taylor expanded in C around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow2N/A
lower-*.f64N/A
Applied rewrites18.4%
if 1.14999999999999996e-29 < B Initial program 15.9%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites21.9%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6457.7
Applied rewrites57.7%
Final simplification27.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
(if (<= (pow B_m 2.0) 1e-211)
(* (pow (* -0.5 (/ F A)) 0.5) (pow 2.0 0.5))
(if (<= (pow B_m 2.0) 5e+94)
(/
(*
(*
(sqrt F)
(sqrt
(*
(+ A (+ C (pow (fma B_m B_m (pow (- A C) 2.0)) 0.5)))
(- (* B_m B_m) (* 4.0 (* A C))))))
(pow 2.0 0.5))
(- (* -1.0 (pow B_m 2.0)) (* (* -1.0 (* 4.0 A)) C)))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma (pow B_m 0.5) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C)))))))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 (pow(B_m, 2.0) <= 1e-211) {
tmp = pow((-0.5 * (F / A)), 0.5) * pow(2.0, 0.5);
} else if (pow(B_m, 2.0) <= 5e+94) {
tmp = ((sqrt(F) * sqrt(((A + (C + pow(fma(B_m, B_m, pow((A - C), 2.0)), 0.5))) * ((B_m * B_m) - (4.0 * (A * C)))))) * pow(2.0, 0.5)) / ((-1.0 * pow(B_m, 2.0)) - ((-1.0 * (4.0 * A)) * C));
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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 ((B_m ^ 2.0) <= 1e-211) tmp = Float64((Float64(-0.5 * Float64(F / A)) ^ 0.5) * (2.0 ^ 0.5)); elseif ((B_m ^ 2.0) <= 5e+94) tmp = Float64(Float64(Float64(sqrt(F) * sqrt(Float64(Float64(A + Float64(C + (fma(B_m, B_m, (Float64(A - C) ^ 2.0)) ^ 0.5))) * Float64(Float64(B_m * B_m) - Float64(4.0 * Float64(A * C)))))) * (2.0 ^ 0.5)) / Float64(Float64(-1.0 * (B_m ^ 2.0)) - Float64(Float64(-1.0 * Float64(4.0 * A)) * C))); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[N[Power[B$95$m, 2.0], $MachinePrecision], 1e-211], N[(N[Power[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B$95$m, 2.0], $MachinePrecision], 5e+94], N[(N[(N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(N[(A + N[(C + N[Power[N[(B$95$m * B$95$m + N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(B$95$m * B$95$m), $MachinePrecision] - N[(4.0 * N[(A * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * N[Power[B$95$m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(4.0 * A), $MachinePrecision]), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;{B\_m}^{2} \leq 10^{-211}:\\
\;\;\;\;{\left(-0.5 \cdot \frac{F}{A}\right)}^{0.5} \cdot {2}^{0.5}\\
\mathbf{elif}\;{B\_m}^{2} \leq 5 \cdot 10^{+94}:\\
\;\;\;\;\frac{\left(\sqrt{F} \cdot \sqrt{\left(A + \left(C + {\left(\mathsf{fma}\left(B\_m, B\_m, {\left(A - C\right)}^{2}\right)\right)}^{0.5}\right)\right) \cdot \left(B\_m \cdot B\_m - 4 \cdot \left(A \cdot C\right)\right)}\right) \cdot {2}^{0.5}}{-1 \cdot {B\_m}^{2} - \left(-1 \cdot \left(4 \cdot A\right)\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.00000000000000009e-211Initial program 17.0%
Taylor expanded in F around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites11.1%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-/.f6418.7
Applied rewrites18.7%
if 1.00000000000000009e-211 < (pow.f64 B #s(literal 2 binary64)) < 5.0000000000000001e94Initial program 40.8%
Taylor expanded in F around 0
lower-*.f64N/A
Applied rewrites44.4%
if 5.0000000000000001e94 < (pow.f64 B #s(literal 2 binary64)) Initial program 6.7%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites6.8%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6427.5
Applied rewrites27.5%
Final simplification28.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
(if (<= F -5e-310)
(* (pow (* -0.5 (/ F A)) 0.5) (pow 2.0 0.5))
(if (<= F 4e+17)
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(pow (* F (+ C (hypot (* -1.0 B_m) (* -1.0 C)))) 0.5))
(* (* -1.0 (pow (/ F B_m) 0.5)) (pow 2.0 0.5)))))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 <= -5e-310) {
tmp = pow((-0.5 * (F / A)), 0.5) * pow(2.0, 0.5);
} else if (F <= 4e+17) {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * pow((F * (C + hypot((-1.0 * B_m), (-1.0 * C)))), 0.5);
} else {
tmp = (-1.0 * pow((F / B_m), 0.5)) * pow(2.0, 0.5);
}
return tmp;
}
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 <= -5e-310) {
tmp = Math.pow((-0.5 * (F / A)), 0.5) * Math.pow(2.0, 0.5);
} else if (F <= 4e+17) {
tmp = (-1.0 * (Math.pow(2.0, 0.5) / B_m)) * Math.pow((F * (C + Math.hypot((-1.0 * B_m), (-1.0 * C)))), 0.5);
} else {
tmp = (-1.0 * Math.pow((F / B_m), 0.5)) * Math.pow(2.0, 0.5);
}
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 <= -5e-310: tmp = math.pow((-0.5 * (F / A)), 0.5) * math.pow(2.0, 0.5) elif F <= 4e+17: tmp = (-1.0 * (math.pow(2.0, 0.5) / B_m)) * math.pow((F * (C + math.hypot((-1.0 * B_m), (-1.0 * C)))), 0.5) else: tmp = (-1.0 * math.pow((F / B_m), 0.5)) * math.pow(2.0, 0.5) 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 <= -5e-310) tmp = Float64((Float64(-0.5 * Float64(F / A)) ^ 0.5) * (2.0 ^ 0.5)); elseif (F <= 4e+17) tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * (Float64(F * Float64(C + hypot(Float64(-1.0 * B_m), Float64(-1.0 * C)))) ^ 0.5)); else tmp = Float64(Float64(-1.0 * (Float64(F / B_m) ^ 0.5)) * (2.0 ^ 0.5)); 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 <= -5e-310)
tmp = ((-0.5 * (F / A)) ^ 0.5) * (2.0 ^ 0.5);
elseif (F <= 4e+17)
tmp = (-1.0 * ((2.0 ^ 0.5) / B_m)) * ((F * (C + hypot((-1.0 * B_m), (-1.0 * C)))) ^ 0.5);
else
tmp = (-1.0 * ((F / B_m) ^ 0.5)) * (2.0 ^ 0.5);
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, -5e-310], N[(N[Power[N[(-0.5 * N[(F / A), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[F, 4e+17], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[Power[N[(F * N[(C + N[Sqrt[N[(-1.0 * B$95$m), $MachinePrecision] ^ 2 + N[(-1.0 * C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $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}
\mathbf{if}\;F \leq -5 \cdot 10^{-310}:\\
\;\;\;\;{\left(-0.5 \cdot \frac{F}{A}\right)}^{0.5} \cdot {2}^{0.5}\\
\mathbf{elif}\;F \leq 4 \cdot 10^{+17}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot {\left(F \cdot \left(C + \mathsf{hypot}\left(-1 \cdot B\_m, -1 \cdot C\right)\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot {\left(\frac{F}{B\_m}\right)}^{0.5}\right) \cdot {2}^{0.5}\\
\end{array}
\end{array}
if F < -4.999999999999985e-310Initial program 29.7%
Taylor expanded in F around -inf
sqrt-unprodN/A
metadata-evalN/A
lower-*.f64N/A
Applied rewrites24.8%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-/.f6438.8
Applied rewrites38.8%
if -4.999999999999985e-310 < F < 4e17Initial program 17.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites9.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
unpow1/2N/A
sqr-neg-revN/A
sqr-neg-revN/A
lower-hypot.f64N/A
lower-neg.f64N/A
lower-neg.f6422.3
Applied rewrites22.3%
if 4e17 < F Initial program 17.3%
Taylor expanded in B around inf
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f6417.0
Applied rewrites17.0%
Final simplification22.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 4e+17)
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(pow (* F (+ C (hypot (* -1.0 B_m) (* -1.0 C)))) 0.5))
(* (* -1.0 (pow (/ F B_m) 0.5)) (pow 2.0 0.5))))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 <= 4e+17) {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * pow((F * (C + hypot((-1.0 * B_m), (-1.0 * C)))), 0.5);
} else {
tmp = (-1.0 * pow((F / B_m), 0.5)) * pow(2.0, 0.5);
}
return tmp;
}
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 <= 4e+17) {
tmp = (-1.0 * (Math.pow(2.0, 0.5) / B_m)) * Math.pow((F * (C + Math.hypot((-1.0 * B_m), (-1.0 * C)))), 0.5);
} else {
tmp = (-1.0 * Math.pow((F / B_m), 0.5)) * Math.pow(2.0, 0.5);
}
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 <= 4e+17: tmp = (-1.0 * (math.pow(2.0, 0.5) / B_m)) * math.pow((F * (C + math.hypot((-1.0 * B_m), (-1.0 * C)))), 0.5) else: tmp = (-1.0 * math.pow((F / B_m), 0.5)) * math.pow(2.0, 0.5) 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 <= 4e+17) tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * (Float64(F * Float64(C + hypot(Float64(-1.0 * B_m), Float64(-1.0 * C)))) ^ 0.5)); else tmp = Float64(Float64(-1.0 * (Float64(F / B_m) ^ 0.5)) * (2.0 ^ 0.5)); 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 <= 4e+17)
tmp = (-1.0 * ((2.0 ^ 0.5) / B_m)) * ((F * (C + hypot((-1.0 * B_m), (-1.0 * C)))) ^ 0.5);
else
tmp = (-1.0 * ((F / B_m) ^ 0.5)) * (2.0 ^ 0.5);
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, 4e+17], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[Power[N[(F * N[(C + N[Sqrt[N[(-1.0 * B$95$m), $MachinePrecision] ^ 2 + N[(-1.0 * C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[Power[2.0, 0.5], $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}
\mathbf{if}\;F \leq 4 \cdot 10^{+17}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot {\left(F \cdot \left(C + \mathsf{hypot}\left(-1 \cdot B\_m, -1 \cdot C\right)\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot {\left(\frac{F}{B\_m}\right)}^{0.5}\right) \cdot {2}^{0.5}\\
\end{array}
\end{array}
if F < 4e17Initial program 20.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites7.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
unpow1/2N/A
sqr-neg-revN/A
sqr-neg-revN/A
lower-hypot.f64N/A
lower-neg.f64N/A
lower-neg.f6417.1
Applied rewrites17.1%
if 4e17 < F Initial program 17.3%
Taylor expanded in B around inf
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f6417.0
Applied rewrites17.0%
Final simplification17.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 (* -1.0 (/ (pow 2.0 0.5) B_m))))
(if (<= F 1.55e+30)
(* t_0 (pow (* F (+ C (hypot (* -1.0 B_m) (* -1.0 C)))) 0.5))
(*
t_0
(fma (pow B_m 0.5) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C)))))))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 = -1.0 * (pow(2.0, 0.5) / B_m);
double tmp;
if (F <= 1.55e+30) {
tmp = t_0 * pow((F * (C + hypot((-1.0 * B_m), (-1.0 * C)))), 0.5);
} else {
tmp = t_0 * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(-1.0 * Float64((2.0 ^ 0.5) / B_m)) tmp = 0.0 if (F <= 1.55e+30) tmp = Float64(t_0 * (Float64(F * Float64(C + hypot(Float64(-1.0 * B_m), Float64(-1.0 * C)))) ^ 0.5)); else tmp = Float64(t_0 * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, 1.55e+30], N[(t$95$0 * N[Power[N[(F * N[(C + N[Sqrt[N[(-1.0 * B$95$m), $MachinePrecision] ^ 2 + N[(-1.0 * C), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := -1 \cdot \frac{{2}^{0.5}}{B\_m}\\
\mathbf{if}\;F \leq 1.55 \cdot 10^{+30}:\\
\;\;\;\;t\_0 \cdot {\left(F \cdot \left(C + \mathsf{hypot}\left(-1 \cdot B\_m, -1 \cdot C\right)\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if F < 1.5499999999999999e30Initial program 20.4%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites7.2%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
unpow1/2N/A
sqr-neg-revN/A
sqr-neg-revN/A
lower-hypot.f64N/A
lower-neg.f64N/A
lower-neg.f6416.7
Applied rewrites16.7%
if 1.5499999999999999e30 < F Initial program 17.3%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites10.2%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6417.1
Applied rewrites17.1%
Final simplification16.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 (* (log 2.0) 0.5)))
(if (<= B_m 1.46e+51)
(*
(/ (+ (cosh t_0) (sinh t_0)) (* -1.0 B_m))
(pow (* F (+ C (exp (* (log (fma B_m B_m (* C C))) 0.5)))) 0.5))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma (pow B_m 0.5) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C)))))))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 = log(2.0) * 0.5;
double tmp;
if (B_m <= 1.46e+51) {
tmp = ((cosh(t_0) + sinh(t_0)) / (-1.0 * B_m)) * pow((F * (C + exp((log(fma(B_m, B_m, (C * C))) * 0.5)))), 0.5);
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(log(2.0) * 0.5) tmp = 0.0 if (B_m <= 1.46e+51) tmp = Float64(Float64(Float64(cosh(t_0) + sinh(t_0)) / Float64(-1.0 * B_m)) * (Float64(F * Float64(C + exp(Float64(log(fma(B_m, B_m, Float64(C * C))) * 0.5)))) ^ 0.5)); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[Log[2.0], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[B$95$m, 1.46e+51], N[(N[(N[(N[Cosh[t$95$0], $MachinePrecision] + N[Sinh[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * B$95$m), $MachinePrecision]), $MachinePrecision] * N[Power[N[(F * N[(C + N[Exp[N[(N[Log[N[(B$95$m * B$95$m + N[(C * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := \log 2 \cdot 0.5\\
\mathbf{if}\;B\_m \leq 1.46 \cdot 10^{+51}:\\
\;\;\;\;\frac{\cosh t\_0 + \sinh t\_0}{-1 \cdot B\_m} \cdot {\left(F \cdot \left(C + e^{\log \left(\mathsf{fma}\left(B\_m, B\_m, C \cdot C\right)\right) \cdot 0.5}\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if B < 1.4600000000000001e51Initial program 22.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites7.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow-to-expN/A
lower-exp.f64N/A
pow2N/A
pow2N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f646.8
Applied rewrites6.8%
lift-pow.f64N/A
pow-to-expN/A
lift-log.f64N/A
lift-*.f64N/A
sinh-+-cosh-revN/A
lower-+.f64N/A
lower-cosh.f64N/A
lower-sinh.f646.8
Applied rewrites6.8%
if 1.4600000000000001e51 < B Initial program 5.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites13.7%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
Final simplification16.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 (* (log 2.0) 0.5)))
(if (<= B_m 3.6e+56)
(*
(/ (+ (cosh t_0) (sinh t_0)) (* -1.0 B_m))
(pow (* F (+ C (exp (* (log (fma B_m B_m (* C C))) 0.5)))) 0.5))
(*
(* -1.0 (/ (pow 2.0 0.5) B_m))
(fma
(pow B_m 0.5)
(exp (* (log F) 0.5))
(* 0.5 (* (pow (/ F B_m) 0.5) C)))))))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 = log(2.0) * 0.5;
double tmp;
if (B_m <= 3.6e+56) {
tmp = ((cosh(t_0) + sinh(t_0)) / (-1.0 * B_m)) * pow((F * (C + exp((log(fma(B_m, B_m, (C * C))) * 0.5)))), 0.5);
} else {
tmp = (-1.0 * (pow(2.0, 0.5) / B_m)) * fma(pow(B_m, 0.5), exp((log(F) * 0.5)), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(log(2.0) * 0.5) tmp = 0.0 if (B_m <= 3.6e+56) tmp = Float64(Float64(Float64(cosh(t_0) + sinh(t_0)) / Float64(-1.0 * B_m)) * (Float64(F * Float64(C + exp(Float64(log(fma(B_m, B_m, Float64(C * C))) * 0.5)))) ^ 0.5)); else tmp = Float64(Float64(-1.0 * Float64((2.0 ^ 0.5) / B_m)) * fma((B_m ^ 0.5), exp(Float64(log(F) * 0.5)), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[Log[2.0], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[B$95$m, 3.6e+56], N[(N[(N[(N[Cosh[t$95$0], $MachinePrecision] + N[Sinh[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * B$95$m), $MachinePrecision]), $MachinePrecision] * N[Power[N[(F * N[(C + N[Exp[N[(N[Log[N[(B$95$m * B$95$m + N[(C * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * N[(N[Power[2.0, 0.5], $MachinePrecision] / B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Power[B$95$m, 0.5], $MachinePrecision] * N[Exp[N[(N[Log[F], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := \log 2 \cdot 0.5\\
\mathbf{if}\;B\_m \leq 3.6 \cdot 10^{+56}:\\
\;\;\;\;\frac{\cosh t\_0 + \sinh t\_0}{-1 \cdot B\_m} \cdot {\left(F \cdot \left(C + e^{\log \left(\mathsf{fma}\left(B\_m, B\_m, C \cdot C\right)\right) \cdot 0.5}\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot \frac{{2}^{0.5}}{B\_m}\right) \cdot \mathsf{fma}\left({B\_m}^{0.5}, e^{\log F \cdot 0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if B < 3.59999999999999998e56Initial program 22.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites7.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow-to-expN/A
lower-exp.f64N/A
pow2N/A
pow2N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f646.8
Applied rewrites6.8%
lift-pow.f64N/A
pow-to-expN/A
lift-log.f64N/A
lift-*.f64N/A
sinh-+-cosh-revN/A
lower-+.f64N/A
lower-cosh.f64N/A
lower-sinh.f646.8
Applied rewrites6.8%
if 3.59999999999999998e56 < B Initial program 5.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites13.7%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6457.8
Applied rewrites57.8%
Final simplification15.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
(let* ((t_0 (* (log 2.0) 0.5)))
(if (<= B_m 7.8e+51)
(*
(/ (+ (cosh t_0) (sinh t_0)) (* -1.0 B_m))
(pow (* F (+ C (exp (* (log (fma B_m B_m (* C C))) 0.5)))) 0.5))
(*
(/ (exp t_0) (* -1.0 B_m))
(fma
(exp (* (log B_m) 0.5))
(pow F 0.5)
(* 0.5 (* (pow (/ F B_m) 0.5) C)))))))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 = log(2.0) * 0.5;
double tmp;
if (B_m <= 7.8e+51) {
tmp = ((cosh(t_0) + sinh(t_0)) / (-1.0 * B_m)) * pow((F * (C + exp((log(fma(B_m, B_m, (C * C))) * 0.5)))), 0.5);
} else {
tmp = (exp(t_0) / (-1.0 * B_m)) * fma(exp((log(B_m) * 0.5)), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
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(log(2.0) * 0.5) tmp = 0.0 if (B_m <= 7.8e+51) tmp = Float64(Float64(Float64(cosh(t_0) + sinh(t_0)) / Float64(-1.0 * B_m)) * (Float64(F * Float64(C + exp(Float64(log(fma(B_m, B_m, Float64(C * C))) * 0.5)))) ^ 0.5)); else tmp = Float64(Float64(exp(t_0) / Float64(-1.0 * B_m)) * fma(exp(Float64(log(B_m) * 0.5)), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))); 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[Log[2.0], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[B$95$m, 7.8e+51], N[(N[(N[(N[Cosh[t$95$0], $MachinePrecision] + N[Sinh[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * B$95$m), $MachinePrecision]), $MachinePrecision] * N[Power[N[(F * N[(C + N[Exp[N[(N[Log[N[(B$95$m * B$95$m + N[(C * C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[t$95$0], $MachinePrecision] / N[(-1.0 * B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(N[Log[B$95$m], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $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 := \log 2 \cdot 0.5\\
\mathbf{if}\;B\_m \leq 7.8 \cdot 10^{+51}:\\
\;\;\;\;\frac{\cosh t\_0 + \sinh t\_0}{-1 \cdot B\_m} \cdot {\left(F \cdot \left(C + e^{\log \left(\mathsf{fma}\left(B\_m, B\_m, C \cdot C\right)\right) \cdot 0.5}\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{t\_0}}{-1 \cdot B\_m} \cdot \mathsf{fma}\left(e^{\log B\_m \cdot 0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)\\
\end{array}
\end{array}
if B < 7.79999999999999968e51Initial program 22.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites7.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
pow-to-expN/A
lower-exp.f64N/A
pow2N/A
pow2N/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
pow2N/A
lift-fma.f64N/A
lift-*.f646.8
Applied rewrites6.8%
lift-pow.f64N/A
pow-to-expN/A
lift-log.f64N/A
lift-*.f64N/A
sinh-+-cosh-revN/A
lower-+.f64N/A
lower-cosh.f64N/A
lower-sinh.f646.8
Applied rewrites6.8%
if 7.79999999999999968e51 < B Initial program 5.5%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites13.7%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6457.3
Applied rewrites57.3%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6457.3
Applied rewrites57.3%
Final simplification15.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 (* (/ (exp (* (log 2.0) 0.5)) (* -1.0 B_m)) (fma (exp (* (log B_m) 0.5)) (pow F 0.5) (* 0.5 (* (pow (/ F B_m) 0.5) C)))))
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 (exp((log(2.0) * 0.5)) / (-1.0 * B_m)) * fma(exp((log(B_m) * 0.5)), pow(F, 0.5), (0.5 * (pow((F / B_m), 0.5) * C)));
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(exp(Float64(log(2.0) * 0.5)) / Float64(-1.0 * B_m)) * fma(exp(Float64(log(B_m) * 0.5)), (F ^ 0.5), Float64(0.5 * Float64((Float64(F / B_m) ^ 0.5) * C)))) 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[(N[Exp[N[(N[Log[2.0], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[(-1.0 * B$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(N[Log[B$95$m], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Power[F, 0.5], $MachinePrecision] + N[(0.5 * N[(N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\frac{e^{\log 2 \cdot 0.5}}{-1 \cdot B\_m} \cdot \mathsf{fma}\left(e^{\log B\_m \cdot 0.5}, {F}^{0.5}, 0.5 \cdot \left({\left(\frac{F}{B\_m}\right)}^{0.5} \cdot C\right)\right)
\end{array}
Initial program 19.2%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites8.4%
Taylor expanded in C around 0
sqrt-prodN/A
lower-fma.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f6415.2
Applied rewrites15.2%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6414.3
Applied rewrites14.3%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6414.3
Applied rewrites14.3%
Final simplification14.3%
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 (<= C 9.2e+171)
(*
F
(fma
-1.0
(* (pow (pow (* B_m F) -1.0) 0.5) (pow 2.0 0.5))
(*
-0.5
(*
(pow (pow (* (* (* B_m B_m) B_m) F) -1.0) 0.5)
(* (pow 2.0 0.5) (+ A C))))))
(* -1.0 (* (/ 2.0 B_m) (pow (* C F) 0.5)))))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 (C <= 9.2e+171) {
tmp = F * fma(-1.0, (pow(pow((B_m * F), -1.0), 0.5) * pow(2.0, 0.5)), (-0.5 * (pow(pow((((B_m * B_m) * B_m) * F), -1.0), 0.5) * (pow(2.0, 0.5) * (A + C)))));
} else {
tmp = -1.0 * ((2.0 / B_m) * pow((C * F), 0.5));
}
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 (C <= 9.2e+171) tmp = Float64(F * fma(-1.0, Float64(((Float64(B_m * F) ^ -1.0) ^ 0.5) * (2.0 ^ 0.5)), Float64(-0.5 * Float64(((Float64(Float64(Float64(B_m * B_m) * B_m) * F) ^ -1.0) ^ 0.5) * Float64((2.0 ^ 0.5) * Float64(A + C)))))); else tmp = Float64(-1.0 * Float64(Float64(2.0 / B_m) * (Float64(C * F) ^ 0.5))); 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[C, 9.2e+171], N[(F * N[(-1.0 * N[(N[Power[N[Power[N[(B$95$m * F), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(N[Power[N[Power[N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] * B$95$m), $MachinePrecision] * F), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[(N[Power[2.0, 0.5], $MachinePrecision] * N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(2.0 / B$95$m), $MachinePrecision] * N[Power[N[(C * F), $MachinePrecision], 0.5], $MachinePrecision]), $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}
\mathbf{if}\;C \leq 9.2 \cdot 10^{+171}:\\
\;\;\;\;F \cdot \mathsf{fma}\left(-1, {\left({\left(B\_m \cdot F\right)}^{-1}\right)}^{0.5} \cdot {2}^{0.5}, -0.5 \cdot \left({\left({\left(\left(\left(B\_m \cdot B\_m\right) \cdot B\_m\right) \cdot F\right)}^{-1}\right)}^{0.5} \cdot \left({2}^{0.5} \cdot \left(A + C\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\frac{2}{B\_m} \cdot {\left(C \cdot F\right)}^{0.5}\right)\\
\end{array}
\end{array}
if C < 9.20000000000000069e171Initial program 21.7%
Taylor expanded in B around inf
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites12.8%
Taylor expanded in F around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lower-*.f64N/A
Applied rewrites12.8%
if 9.20000000000000069e171 < C Initial program 2.1%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
pow1/2N/A
lower-pow.f64N/A
Applied rewrites2.1%
Taylor expanded in B around 0
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f645.5
Applied rewrites5.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
(*
F
(fma
-1.0
(* (pow (pow (* B_m F) -1.0) 0.5) (pow 2.0 0.5))
(*
-0.5
(*
(pow (pow (* (* (* B_m B_m) B_m) F) -1.0) 0.5)
(* (pow 2.0 0.5) (+ A C)))))))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 F * fma(-1.0, (pow(pow((B_m * F), -1.0), 0.5) * pow(2.0, 0.5)), (-0.5 * (pow(pow((((B_m * B_m) * B_m) * F), -1.0), 0.5) * (pow(2.0, 0.5) * (A + C)))));
}
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(F * fma(-1.0, Float64(((Float64(B_m * F) ^ -1.0) ^ 0.5) * (2.0 ^ 0.5)), Float64(-0.5 * Float64(((Float64(Float64(Float64(B_m * B_m) * B_m) * F) ^ -1.0) ^ 0.5) * Float64((2.0 ^ 0.5) * Float64(A + C)))))) 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[(F * N[(-1.0 * N[(N[Power[N[Power[N[(B$95$m * F), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(N[Power[N[Power[N[(N[(N[(B$95$m * B$95$m), $MachinePrecision] * B$95$m), $MachinePrecision] * F), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * N[(N[Power[2.0, 0.5], $MachinePrecision] * N[(A + C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
F \cdot \mathsf{fma}\left(-1, {\left({\left(B\_m \cdot F\right)}^{-1}\right)}^{0.5} \cdot {2}^{0.5}, -0.5 \cdot \left({\left({\left(\left(\left(B\_m \cdot B\_m\right) \cdot B\_m\right) \cdot F\right)}^{-1}\right)}^{0.5} \cdot \left({2}^{0.5} \cdot \left(A + C\right)\right)\right)\right)
\end{array}
Initial program 19.2%
Taylor expanded in B around inf
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites11.4%
Taylor expanded in F around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lower-*.f64N/A
Applied rewrites11.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 (* (* -1.0 (pow (/ F B_m) 0.5)) (* -1.0 (pow 2.0 0.5))))
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 (-1.0 * pow((F / B_m), 0.5)) * (-1.0 * pow(2.0, 0.5));
}
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 = ((-1.0d0) * ((f / b_m) ** 0.5d0)) * ((-1.0d0) * (2.0d0 ** 0.5d0))
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 (-1.0 * Math.pow((F / B_m), 0.5)) * (-1.0 * Math.pow(2.0, 0.5));
}
B_m = math.fabs(B) [A, B_m, C, F] = sort([A, B_m, C, F]) def code(A, B_m, C, F): return (-1.0 * math.pow((F / B_m), 0.5)) * (-1.0 * math.pow(2.0, 0.5))
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(Float64(-1.0 * (Float64(F / B_m) ^ 0.5)) * Float64(-1.0 * (2.0 ^ 0.5))) 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 = (-1.0 * ((F / B_m) ^ 0.5)) * (-1.0 * (2.0 ^ 0.5));
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[(-1.0 * N[Power[N[(F / B$95$m), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
\left(-1 \cdot {\left(\frac{F}{B\_m}\right)}^{0.5}\right) \cdot \left(-1 \cdot {2}^{0.5}\right)
\end{array}
Initial program 19.2%
Taylor expanded in B around inf
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites11.4%
Taylor expanded in B around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f642.1
Applied rewrites2.1%
Final simplification2.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 (* (exp (* (log (/ F B_m)) 0.5)) (pow 2.0 0.5)))
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 exp((log((F / B_m)) * 0.5)) * pow(2.0, 0.5);
}
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 = exp((log((f / b_m)) * 0.5d0)) * (2.0d0 ** 0.5d0)
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.exp((Math.log((F / B_m)) * 0.5)) * Math.pow(2.0, 0.5);
}
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.exp((math.log((F / B_m)) * 0.5)) * math.pow(2.0, 0.5)
B_m = abs(B) A, B_m, C, F = sort([A, B_m, C, F]) function code(A, B_m, C, F) return Float64(exp(Float64(log(Float64(F / B_m)) * 0.5)) * (2.0 ^ 0.5)) 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 = exp((log((F / B_m)) * 0.5)) * (2.0 ^ 0.5);
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[Exp[N[(N[Log[N[(F / B$95$m), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Power[2.0, 0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
B_m = \left|B\right|
\\
[A, B_m, C, F] = \mathsf{sort}([A, B_m, C, F])\\
\\
e^{\log \left(\frac{F}{B\_m}\right) \cdot 0.5} \cdot {2}^{0.5}
\end{array}
Initial program 19.2%
Taylor expanded in B around inf
lower-fma.f64N/A
lower-*.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow1/2N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites11.4%
Taylor expanded in B around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f64N/A
lift-/.f64N/A
lower-*.f64N/A
pow1/2N/A
lift-pow.f642.1
Applied rewrites2.1%
lift-/.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lift-/.f642.0
Applied rewrites2.0%
Final simplification2.0%
herbie shell --seed 2025065
(FPCore (A B C F)
:name "ABCF->ab-angle a"
: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))))