
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))))
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0)))
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
return -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c, f)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: f
real(8) :: t_0
t_0 = (b ** 2.0d0) - ((4.0d0 * a) * c)
code = -sqrt(((2.0d0 * (t_0 * f)) * ((a + c) - sqrt((((a - c) ** 2.0d0) + (b ** 2.0d0)))))) / t_0
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.pow(B, 2.0) - ((4.0 * A) * C);
return -Math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - Math.sqrt((Math.pow((A - C), 2.0) + Math.pow(B, 2.0)))))) / t_0;
}
def code(A, B, C, F): t_0 = math.pow(B, 2.0) - ((4.0 * A) * C) return -math.sqrt(((2.0 * (t_0 * F)) * ((A + C) - math.sqrt((math.pow((A - C), 2.0) + math.pow(B, 2.0)))))) / t_0
function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) return Float64(Float64(-sqrt(Float64(Float64(2.0 * Float64(t_0 * F)) * Float64(Float64(A + C) - sqrt(Float64((Float64(A - C) ^ 2.0) + (B ^ 2.0))))))) / t_0) end
function tmp = code(A, B, C, F) t_0 = (B ^ 2.0) - ((4.0 * A) * C); tmp = -sqrt(((2.0 * (t_0 * F)) * ((A + C) - sqrt((((A - C) ^ 2.0) + (B ^ 2.0)))))) / t_0; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, N[((-N[Sqrt[N[(N[(2.0 * N[(t$95$0 * F), $MachinePrecision]), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(A - C), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[B, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
\frac{-\sqrt{\left(2 \cdot \left(t\_0 \cdot F\right)\right) \cdot \left(\left(A + C\right) - \sqrt{{\left(A - C\right)}^{2} + {B}^{2}}\right)}}{t\_0}
\end{array}
\end{array}
Herbie found 13 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}
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))) (t_1 (fma -4.0 (* C A) (* B B))))
(if (<= C -1.32e-47)
(/
(-
(*
(sqrt (fma (* 4.0 A) C (* B B)))
(sqrt (* (* (- (- (hypot B (- C A)) C) A) 2.0) F))))
t_0)
(if (<= C 4.6e-17)
(/
(-
(*
(sqrt (* (- (+ A C) (hypot (- A C) B)) (* F 2.0)))
(sqrt (fma (* A C) -4.0 (* B B)))))
t_0)
(/
(-
(sqrt
(* (- A (fma -1.0 A (* 0.5 (/ (pow B 2.0) C)))) (* (* 2.0 F) t_1))))
t_1)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
double t_1 = fma(-4.0, (C * A), (B * B));
double tmp;
if (C <= -1.32e-47) {
tmp = -(sqrt(fma((4.0 * A), C, (B * B))) * sqrt(((((hypot(B, (C - A)) - C) - A) * 2.0) * F))) / t_0;
} else if (C <= 4.6e-17) {
tmp = -(sqrt((((A + C) - hypot((A - C), B)) * (F * 2.0))) * sqrt(fma((A * C), -4.0, (B * B)))) / t_0;
} else {
tmp = -sqrt(((A - fma(-1.0, A, (0.5 * (pow(B, 2.0) / C)))) * ((2.0 * F) * t_1))) / t_1;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = fma(-4.0, Float64(C * A), Float64(B * B)) tmp = 0.0 if (C <= -1.32e-47) tmp = Float64(Float64(-Float64(sqrt(fma(Float64(4.0 * A), C, Float64(B * B))) * sqrt(Float64(Float64(Float64(Float64(hypot(B, Float64(C - A)) - C) - A) * 2.0) * F)))) / t_0); elseif (C <= 4.6e-17) tmp = Float64(Float64(-Float64(sqrt(Float64(Float64(Float64(A + C) - hypot(Float64(A - C), B)) * Float64(F * 2.0))) * sqrt(fma(Float64(A * C), -4.0, Float64(B * B))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(A - fma(-1.0, A, Float64(0.5 * Float64((B ^ 2.0) / C)))) * Float64(Float64(2.0 * F) * t_1)))) / t_1); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
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]}, Block[{t$95$1 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -1.32e-47], N[((-N[(N[Sqrt[N[(N[(4.0 * A), $MachinePrecision] * C + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(N[(N[(N[Sqrt[B ^ 2 + N[(C - A), $MachinePrecision] ^ 2], $MachinePrecision] - C), $MachinePrecision] - A), $MachinePrecision] * 2.0), $MachinePrecision] * F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[C, 4.6e-17], N[((-N[(N[Sqrt[N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(A - N[(-1.0 * A + N[(0.5 * N[(N[Power[B, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
\mathbf{if}\;C \leq -1.32 \cdot 10^{-47}:\\
\;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(4 \cdot A, C, B \cdot B\right)} \cdot \sqrt{\left(\left(\left(\mathsf{hypot}\left(B, C - A\right) - C\right) - A\right) \cdot 2\right) \cdot F}}{t\_0}\\
\mathbf{elif}\;C \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(A + C\right) - \mathsf{hypot}\left(A - C, B\right)\right) \cdot \left(F \cdot 2\right)} \cdot \sqrt{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \mathsf{fma}\left(-1, A, 0.5 \cdot \frac{{B}^{2}}{C}\right)\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{t\_1}\\
\end{array}
\end{array}
if C < -1.32e-47Initial program 14.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negate2N/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites21.8%
Applied rewrites30.3%
if -1.32e-47 < C < 4.60000000000000018e-17Initial program 31.6%
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
distribute-lft-inN/A
lower-fma.f64N/A
Applied rewrites40.1%
Applied rewrites42.3%
if 4.60000000000000018e-17 < C Initial program 6.0%
Applied rewrites7.5%
Applied rewrites1.3%
Applied rewrites11.3%
Taylor expanded in C around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6433.3
Applied rewrites33.3%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (pow B 2.0) (* (* 4.0 A) C))) (t_1 (fma -4.0 (* C A) (* B B))))
(if (<= C -1.32e-47)
(/
(-
(*
(sqrt (* (fma (* 4.0 A) C (* B B)) 2.0))
(sqrt (* F (- (- (hypot B (- C A)) C) A)))))
t_0)
(if (<= C 4.6e-17)
(/
(-
(*
(sqrt (* (- (+ A C) (hypot (- A C) B)) (* F 2.0)))
(sqrt (fma (* A C) -4.0 (* B B)))))
t_0)
(/
(-
(sqrt
(* (- A (fma -1.0 A (* 0.5 (/ (pow B 2.0) C)))) (* (* 2.0 F) t_1))))
t_1)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = pow(B, 2.0) - ((4.0 * A) * C);
double t_1 = fma(-4.0, (C * A), (B * B));
double tmp;
if (C <= -1.32e-47) {
tmp = -(sqrt((fma((4.0 * A), C, (B * B)) * 2.0)) * sqrt((F * ((hypot(B, (C - A)) - C) - A)))) / t_0;
} else if (C <= 4.6e-17) {
tmp = -(sqrt((((A + C) - hypot((A - C), B)) * (F * 2.0))) * sqrt(fma((A * C), -4.0, (B * B)))) / t_0;
} else {
tmp = -sqrt(((A - fma(-1.0, A, (0.5 * (pow(B, 2.0) / C)))) * ((2.0 * F) * t_1))) / t_1;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C)) t_1 = fma(-4.0, Float64(C * A), Float64(B * B)) tmp = 0.0 if (C <= -1.32e-47) tmp = Float64(Float64(-Float64(sqrt(Float64(fma(Float64(4.0 * A), C, Float64(B * B)) * 2.0)) * sqrt(Float64(F * Float64(Float64(hypot(B, Float64(C - A)) - C) - A))))) / t_0); elseif (C <= 4.6e-17) tmp = Float64(Float64(-Float64(sqrt(Float64(Float64(Float64(A + C) - hypot(Float64(A - C), B)) * Float64(F * 2.0))) * sqrt(fma(Float64(A * C), -4.0, Float64(B * B))))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(A - fma(-1.0, A, Float64(0.5 * Float64((B ^ 2.0) / C)))) * Float64(Float64(2.0 * F) * t_1)))) / t_1); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
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]}, Block[{t$95$1 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, -1.32e-47], N[((-N[(N[Sqrt[N[(N[(N[(4.0 * A), $MachinePrecision] * C + N[(B * B), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(F * N[(N[(N[Sqrt[B ^ 2 + N[(C - A), $MachinePrecision] ^ 2], $MachinePrecision] - C), $MachinePrecision] - A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[C, 4.6e-17], N[((-N[(N[Sqrt[N[(N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(A - N[(-1.0 * A + N[(0.5 * N[(N[Power[B, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := {B}^{2} - \left(4 \cdot A\right) \cdot C\\
t_1 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
\mathbf{if}\;C \leq -1.32 \cdot 10^{-47}:\\
\;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(4 \cdot A, C, B \cdot B\right) \cdot 2} \cdot \sqrt{F \cdot \left(\left(\mathsf{hypot}\left(B, C - A\right) - C\right) - A\right)}}{t\_0}\\
\mathbf{elif}\;C \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(A + C\right) - \mathsf{hypot}\left(A - C, B\right)\right) \cdot \left(F \cdot 2\right)} \cdot \sqrt{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \mathsf{fma}\left(-1, A, 0.5 \cdot \frac{{B}^{2}}{C}\right)\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_1\right)}}{t\_1}\\
\end{array}
\end{array}
if C < -1.32e-47Initial program 14.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negate2N/A
distribute-lft-neg-outN/A
lower-neg.f64N/A
lower-*.f64N/A
Applied rewrites21.8%
Applied rewrites30.3%
if -1.32e-47 < C < 4.60000000000000018e-17Initial program 31.6%
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
distribute-lft-inN/A
lower-fma.f64N/A
Applied rewrites40.1%
Applied rewrites42.3%
if 4.60000000000000018e-17 < C Initial program 6.0%
Applied rewrites7.5%
Applied rewrites1.3%
Applied rewrites11.3%
Taylor expanded in C around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6433.3
Applied rewrites33.3%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B))) (t_1 (hypot (- A C) B)))
(if (<= C -5.2e-263)
(/ (- (sqrt (* (- (+ C A) t_1) (* (+ F F) t_0)))) t_0)
(if (<= C 4.6e-17)
(/
(-
(*
(sqrt (* (- (+ A C) t_1) (* F 2.0)))
(sqrt (fma (* A C) -4.0 (* B B)))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(/
(-
(sqrt
(* (- A (fma -1.0 A (* 0.5 (/ (pow B 2.0) C)))) (* (* 2.0 F) t_0))))
t_0)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double t_1 = hypot((A - C), B);
double tmp;
if (C <= -5.2e-263) {
tmp = -sqrt((((C + A) - t_1) * ((F + F) * t_0))) / t_0;
} else if (C <= 4.6e-17) {
tmp = -(sqrt((((A + C) - t_1) * (F * 2.0))) * sqrt(fma((A * C), -4.0, (B * B)))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = -sqrt(((A - fma(-1.0, A, (0.5 * (pow(B, 2.0) / C)))) * ((2.0 * F) * t_0))) / t_0;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) t_1 = hypot(Float64(A - C), B) tmp = 0.0 if (C <= -5.2e-263) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(C + A) - t_1) * Float64(Float64(F + F) * t_0)))) / t_0); elseif (C <= 4.6e-17) tmp = Float64(Float64(-Float64(sqrt(Float64(Float64(Float64(A + C) - t_1) * Float64(F * 2.0))) * sqrt(fma(Float64(A * C), -4.0, Float64(B * B))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(Float64(-sqrt(Float64(Float64(A - fma(-1.0, A, Float64(0.5 * Float64((B ^ 2.0) / C)))) * Float64(Float64(2.0 * F) * t_0)))) / t_0); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]}, If[LessEqual[C, -5.2e-263], N[((-N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - t$95$1), $MachinePrecision] * N[(N[(F + F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], If[LessEqual[C, 4.6e-17], N[((-N[(N[Sqrt[N[(N[(N[(A + C), $MachinePrecision] - t$95$1), $MachinePrecision] * N[(F * 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(A * C), $MachinePrecision] * -4.0 + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Sqrt[N[(N[(A - N[(-1.0 * A + N[(0.5 * N[(N[Power[B, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
t_1 := \mathsf{hypot}\left(A - C, B\right)\\
\mathbf{if}\;C \leq -5.2 \cdot 10^{-263}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(C + A\right) - t\_1\right) \cdot \left(\left(F + F\right) \cdot t\_0\right)}}{t\_0}\\
\mathbf{elif}\;C \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(A + C\right) - t\_1\right) \cdot \left(F \cdot 2\right)} \cdot \sqrt{\mathsf{fma}\left(A \cdot C, -4, B \cdot B\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \mathsf{fma}\left(-1, A, 0.5 \cdot \frac{{B}^{2}}{C}\right)\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{t\_0}\\
\end{array}
\end{array}
if C < -5.2000000000000001e-263Initial program 25.7%
Applied rewrites35.0%
lift-*.f64N/A
count-2-revN/A
lower-+.f6435.0
Applied rewrites35.0%
if -5.2000000000000001e-263 < C < 4.60000000000000018e-17Initial program 31.2%
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
distribute-lft-inN/A
lower-fma.f64N/A
Applied rewrites38.8%
Applied rewrites48.7%
if 4.60000000000000018e-17 < C Initial program 6.0%
Applied rewrites7.5%
Applied rewrites1.3%
Applied rewrites11.3%
Taylor expanded in C around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6433.3
Applied rewrites33.3%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B))) (t_1 (* (* 2.0 F) t_0)))
(if (<= C 2.7e-61)
(/ (- (sqrt (* (- A (- (hypot (- A C) B) C)) t_1))) t_0)
(/ (- (sqrt (* (- A (fma -1.0 A (* 0.5 (/ (pow B 2.0) C)))) t_1))) t_0))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double t_1 = (2.0 * F) * t_0;
double tmp;
if (C <= 2.7e-61) {
tmp = -sqrt(((A - (hypot((A - C), B) - C)) * t_1)) / t_0;
} else {
tmp = -sqrt(((A - fma(-1.0, A, (0.5 * (pow(B, 2.0) / C)))) * t_1)) / t_0;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) t_1 = Float64(Float64(2.0 * F) * t_0) tmp = 0.0 if (C <= 2.7e-61) tmp = Float64(Float64(-sqrt(Float64(Float64(A - Float64(hypot(Float64(A - C), B) - C)) * t_1))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(A - fma(-1.0, A, Float64(0.5 * Float64((B ^ 2.0) / C)))) * t_1))) / t_0); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[C, 2.7e-61], N[((-N[Sqrt[N[(N[(A - N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision] - C), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(A - N[(-1.0 * A + N[(0.5 * N[(N[Power[B, 2.0], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
t_1 := \left(2 \cdot F\right) \cdot t\_0\\
\mathbf{if}\;C \leq 2.7 \cdot 10^{-61}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \left(\mathsf{hypot}\left(A - C, B\right) - C\right)\right) \cdot t\_1}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \mathsf{fma}\left(-1, A, 0.5 \cdot \frac{{B}^{2}}{C}\right)\right) \cdot t\_1}}{t\_0}\\
\end{array}
\end{array}
if C < 2.69999999999999993e-61Initial program 29.4%
Applied rewrites37.8%
Applied rewrites6.6%
Applied rewrites37.9%
if 2.69999999999999993e-61 < C Initial program 8.0%
Applied rewrites9.8%
Applied rewrites2.0%
Applied rewrites13.4%
Taylor expanded in C around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6432.8
Applied rewrites32.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B))) (t_1 (* (* 2.0 F) t_0)))
(if (<= C 1.75e-64)
(/ (- (sqrt (* (- A (- (hypot (- A C) B) C)) t_1))) t_0)
(/ (- (sqrt (* (* 2.0 A) t_1))) t_0))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double t_1 = (2.0 * F) * t_0;
double tmp;
if (C <= 1.75e-64) {
tmp = -sqrt(((A - (hypot((A - C), B) - C)) * t_1)) / t_0;
} else {
tmp = -sqrt(((2.0 * A) * t_1)) / t_0;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) t_1 = Float64(Float64(2.0 * F) * t_0) tmp = 0.0 if (C <= 1.75e-64) tmp = Float64(Float64(-sqrt(Float64(Float64(A - Float64(hypot(Float64(A - C), B) - C)) * t_1))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * A) * t_1))) / t_0); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[C, 1.75e-64], N[((-N[Sqrt[N[(N[(A - N[(N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision] - C), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(2.0 * A), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
t_1 := \left(2 \cdot F\right) \cdot t\_0\\
\mathbf{if}\;C \leq 1.75 \cdot 10^{-64}:\\
\;\;\;\;\frac{-\sqrt{\left(A - \left(\mathsf{hypot}\left(A - C, B\right) - C\right)\right) \cdot t\_1}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot A\right) \cdot t\_1}}{t\_0}\\
\end{array}
\end{array}
if C < 1.7500000000000002e-64Initial program 29.4%
Applied rewrites37.8%
Applied rewrites6.7%
Applied rewrites37.9%
if 1.7500000000000002e-64 < C Initial program 8.2%
Applied rewrites10.1%
Applied rewrites4.6%
Taylor expanded in A around -inf
lower-*.f6426.0
Applied rewrites26.0%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B))))
(if (<= C 2.2e-99)
(/ (- (sqrt (* (- (+ C A) (hypot (- A C) B)) (* (+ F F) t_0)))) t_0)
(/ (- (sqrt (* (* 2.0 A) (* (* 2.0 F) t_0)))) t_0))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double tmp;
if (C <= 2.2e-99) {
tmp = -sqrt((((C + A) - hypot((A - C), B)) * ((F + F) * t_0))) / t_0;
} else {
tmp = -sqrt(((2.0 * A) * ((2.0 * F) * t_0))) / t_0;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) tmp = 0.0 if (C <= 2.2e-99) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(C + A) - hypot(Float64(A - C), B)) * Float64(Float64(F + F) * t_0)))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * A) * Float64(Float64(2.0 * F) * t_0)))) / t_0); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[C, 2.2e-99], N[((-N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] - N[Sqrt[N[(A - C), $MachinePrecision] ^ 2 + B ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(F + F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(2.0 * A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
\mathbf{if}\;C \leq 2.2 \cdot 10^{-99}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(C + A\right) - \mathsf{hypot}\left(A - C, B\right)\right) \cdot \left(\left(F + F\right) \cdot t\_0\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{t\_0}\\
\end{array}
\end{array}
if C < 2.20000000000000004e-99Initial program 28.7%
Applied rewrites37.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f6437.5
Applied rewrites37.5%
if 2.20000000000000004e-99 < C Initial program 10.3%
Applied rewrites12.4%
Applied rewrites5.4%
Taylor expanded in A around -inf
lower-*.f6426.2
Applied rewrites26.2%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B)))
(t_1 (* (* 2.0 F) t_0))
(t_2 (sqrt (- B (- A C)))))
(if (<= C 2.9e-66)
(/ (- (sqrt (* (fma t_2 (- t_2) (+ A C)) t_1))) t_0)
(/ (- (sqrt (* (* 2.0 A) t_1))) t_0))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double t_1 = (2.0 * F) * t_0;
double t_2 = sqrt((B - (A - C)));
double tmp;
if (C <= 2.9e-66) {
tmp = -sqrt((fma(t_2, -t_2, (A + C)) * t_1)) / t_0;
} else {
tmp = -sqrt(((2.0 * A) * t_1)) / t_0;
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) t_1 = Float64(Float64(2.0 * F) * t_0) t_2 = sqrt(Float64(B - Float64(A - C))) tmp = 0.0 if (C <= 2.9e-66) tmp = Float64(Float64(-sqrt(Float64(fma(t_2, Float64(-t_2), Float64(A + C)) * t_1))) / t_0); else tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * A) * t_1))) / t_0); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(B - N[(A - C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[C, 2.9e-66], N[((-N[Sqrt[N[(N[(t$95$2 * (-t$95$2) + N[(A + C), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[((-N[Sqrt[N[(N[(2.0 * A), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
t_1 := \left(2 \cdot F\right) \cdot t\_0\\
t_2 := \sqrt{B - \left(A - C\right)}\\
\mathbf{if}\;C \leq 2.9 \cdot 10^{-66}:\\
\;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(t\_2, -t\_2, A + C\right) \cdot t\_1}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot A\right) \cdot t\_1}}{t\_0}\\
\end{array}
\end{array}
if C < 2.90000000000000011e-66Initial program 29.4%
Applied rewrites37.8%
Applied rewrites6.6%
Applied rewrites30.6%
if 2.90000000000000011e-66 < C Initial program 8.3%
Applied rewrites10.2%
Applied rewrites4.7%
Taylor expanded in A around -inf
lower-*.f6426.1
Applied rewrites26.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (fma -4.0 (* C A) (* B B))))
(if (<= B 9e+87)
(/ (- (sqrt (* (* 2.0 A) (* (* 2.0 F) t_0)))) t_0)
(*
-1.0
(* (/ (sqrt 2.0) B) (sqrt (* F (- C (sqrt (* (+ B C) (- B C)))))))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = fma(-4.0, (C * A), (B * B));
double tmp;
if (B <= 9e+87) {
tmp = -sqrt(((2.0 * A) * ((2.0 * F) * t_0))) / t_0;
} else {
tmp = -1.0 * ((sqrt(2.0) / B) * sqrt((F * (C - sqrt(((B + C) * (B - C)))))));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = fma(-4.0, Float64(C * A), Float64(B * B)) tmp = 0.0 if (B <= 9e+87) tmp = Float64(Float64(-sqrt(Float64(Float64(2.0 * A) * Float64(Float64(2.0 * F) * t_0)))) / t_0); else tmp = Float64(-1.0 * Float64(Float64(sqrt(2.0) / B) * sqrt(Float64(F * Float64(C - sqrt(Float64(Float64(B + C) * Float64(B - C)))))))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[B, 9e+87], N[((-N[Sqrt[N[(N[(2.0 * A), $MachinePrecision] * N[(N[(2.0 * F), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-1.0 * N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[Sqrt[N[(F * N[(C - N[Sqrt[N[(N[(B + C), $MachinePrecision] * N[(B - C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)\\
\mathbf{if}\;B \leq 9 \cdot 10^{+87}:\\
\;\;\;\;\frac{-\sqrt{\left(2 \cdot A\right) \cdot \left(\left(2 \cdot F\right) \cdot t\_0\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(C - \sqrt{\left(B + C\right) \cdot \left(B - C\right)}\right)}\right)\\
\end{array}
\end{array}
if B < 9.0000000000000005e87Initial program 21.1%
Applied rewrites27.0%
Applied rewrites5.3%
Taylor expanded in A around -inf
lower-*.f6431.1
Applied rewrites31.1%
if 9.0000000000000005e87 < B Initial program 7.6%
Applied rewrites9.1%
Applied rewrites6.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f646.4
Applied rewrites6.4%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6413.6
Applied rewrites13.6%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 2.3e+79)
(/
(- (sqrt (* -8.0 (* A (* C (* F (- A (* -1.0 A))))))))
(fma -4.0 (* C A) (* B B)))
(*
-1.0
(* (/ (sqrt 2.0) B) (sqrt (* F (- C (sqrt (* (+ B C) (- B C))))))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.3e+79) {
tmp = -sqrt((-8.0 * (A * (C * (F * (A - (-1.0 * A))))))) / fma(-4.0, (C * A), (B * B));
} else {
tmp = -1.0 * ((sqrt(2.0) / B) * sqrt((F * (C - sqrt(((B + C) * (B - C)))))));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 2.3e+79) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A - Float64(-1.0 * A)))))))) / fma(-4.0, Float64(C * A), Float64(B * B))); else tmp = Float64(-1.0 * Float64(Float64(sqrt(2.0) / B) * sqrt(Float64(F * Float64(C - sqrt(Float64(Float64(B + C) * Float64(B - C)))))))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 2.3e+79], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A - N[(-1.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[Sqrt[N[(F * N[(C - N[Sqrt[N[(N[(B + C), $MachinePrecision] * N[(B - C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.3 \cdot 10^{+79}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(C - \sqrt{\left(B + C\right) \cdot \left(B - C\right)}\right)}\right)\\
\end{array}
\end{array}
if B < 2.3e79Initial program 21.0%
Applied rewrites27.0%
Applied rewrites5.2%
Taylor expanded in C around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6427.9
Applied rewrites27.9%
if 2.3e79 < B Initial program 8.5%
Applied rewrites9.9%
Applied rewrites7.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f647.3
Applied rewrites7.3%
Taylor expanded in A around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6414.8
Applied rewrites14.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= B 2.3e+79)
(/
(- (sqrt (* -8.0 (* A (* C (* F (- A (* -1.0 A))))))))
(fma -4.0 (* C A) (* B B)))
(*
-1.0
(* (/ (sqrt 2.0) B) (sqrt (* F (- A (sqrt (* (+ A B) (- B A))))))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.3e+79) {
tmp = -sqrt((-8.0 * (A * (C * (F * (A - (-1.0 * A))))))) / fma(-4.0, (C * A), (B * B));
} else {
tmp = -1.0 * ((sqrt(2.0) / B) * sqrt((F * (A - sqrt(((A + B) * (B - A)))))));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 2.3e+79) tmp = Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A - Float64(-1.0 * A)))))))) / fma(-4.0, Float64(C * A), Float64(B * B))); else tmp = Float64(-1.0 * Float64(Float64(sqrt(2.0) / B) * sqrt(Float64(F * Float64(A - sqrt(Float64(Float64(A + B) * Float64(B - A)))))))); end return tmp end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := If[LessEqual[B, 2.3e+79], N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A - N[(-1.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(N[Sqrt[2.0], $MachinePrecision] / B), $MachinePrecision] * N[Sqrt[N[(F * N[(A - N[Sqrt[N[(N[(A + B), $MachinePrecision] * N[(B - A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;B \leq 2.3 \cdot 10^{+79}:\\
\;\;\;\;\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\frac{\sqrt{2}}{B} \cdot \sqrt{F \cdot \left(A - \sqrt{\left(A + B\right) \cdot \left(B - A\right)}\right)}\right)\\
\end{array}
\end{array}
if B < 2.3e79Initial program 21.0%
Applied rewrites27.0%
Applied rewrites5.2%
Taylor expanded in C around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6427.9
Applied rewrites27.9%
if 2.3e79 < B Initial program 8.5%
Applied rewrites9.9%
Applied rewrites7.3%
lift-*.f64N/A
count-2-revN/A
lower-+.f647.3
Applied rewrites7.3%
Taylor expanded in C around 0
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower--.f6414.7
Applied rewrites14.7%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (/ (- (sqrt (* -8.0 (* A (* C (* F (- A (* -1.0 A)))))))) (fma -4.0 (* C A) (* B B))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt((-8.0 * (A * (C * (F * (A - (-1.0 * A))))))) / fma(-4.0, (C * A), (B * B));
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(Float64(-sqrt(Float64(-8.0 * Float64(A * Float64(C * Float64(F * Float64(A - Float64(-1.0 * A)))))))) / fma(-4.0, Float64(C * A), Float64(B * B))) end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[((-N[Sqrt[N[(-8.0 * N[(A * N[(C * N[(F * N[(A - N[(-1.0 * A), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / N[(-4.0 * N[(C * A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\frac{-\sqrt{-8 \cdot \left(A \cdot \left(C \cdot \left(F \cdot \left(A - -1 \cdot A\right)\right)\right)\right)}}{\mathsf{fma}\left(-4, C \cdot A, B \cdot B\right)}
\end{array}
Initial program 18.6%
Applied rewrites23.7%
Applied rewrites4.9%
Taylor expanded in C around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6423.2
Applied rewrites23.2%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* 0.25 (* (/ (sqrt 2.0) C) (sqrt (* F (fma -4.0 C (* 4.0 C)))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return 0.25 * ((sqrt(2.0) / C) * sqrt((F * fma(-4.0, C, (4.0 * C)))));
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(0.25 * Float64(Float64(sqrt(2.0) / C) * sqrt(Float64(F * fma(-4.0, C, Float64(4.0 * C)))))) end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(0.25 * N[(N[(N[Sqrt[2.0], $MachinePrecision] / C), $MachinePrecision] * N[Sqrt[N[(F * N[(-4.0 * C + N[(4.0 * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
0.25 \cdot \left(\frac{\sqrt{2}}{C} \cdot \sqrt{F \cdot \mathsf{fma}\left(-4, C, 4 \cdot C\right)}\right)
\end{array}
Initial program 18.6%
lift-*.f64N/A
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
distribute-lft-inN/A
lower-fma.f64N/A
Applied rewrites25.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-outN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites21.0%
Taylor expanded in A around inf
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f643.8
Applied rewrites3.8%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (* -1.0 (* (sqrt (/ F B)) (sqrt 2.0))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -1.0 * (sqrt((F / B)) * sqrt(2.0));
}
NOTE: A, B, 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, 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
code = (-1.0d0) * (sqrt((f / b)) * sqrt(2.0d0))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -1.0 * (Math.sqrt((F / B)) * Math.sqrt(2.0));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -1.0 * (math.sqrt((F / B)) * math.sqrt(2.0))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-1.0 * Float64(sqrt(Float64(F / B)) * sqrt(2.0))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -1.0 * (sqrt((F / B)) * sqrt(2.0));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := N[(-1.0 * N[(N[Sqrt[N[(F / B), $MachinePrecision]], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-1 \cdot \left(\sqrt{\frac{F}{B}} \cdot \sqrt{2}\right)
\end{array}
Initial program 18.6%
lift--.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate--l+N/A
lower-+.f64N/A
lower--.f6418.6
lift-sqrt.f64N/A
lift-+.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-pow.f64N/A
unpow2N/A
lower-hypot.f6423.7
Applied rewrites23.7%
Applied rewrites12.1%
Applied rewrites8.3%
Taylor expanded in B around inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f6413.7
Applied rewrites13.7%
herbie shell --seed 2025107
(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))))