
(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 11 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
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0))
(t_2 (* 0.25 (/ (* (sqrt (* -16.0 A)) (sqrt F)) A))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -5e-171)
(/
1.0
(/
(- (* C (* A 4.0)) (* B B))
(sqrt
(*
(+ (+ C A) (sqrt (fma (- C A) (- C A) (* B B))))
(* (+ F F) (fma (* -4.0 A) C (* B B)))))))
(if (<= t_1 0.0)
t_2
(if (<= t_1 INFINITY)
(* (* (/ (sqrt (* -16.0 F)) A) 0.25) (sqrt A))
(- (sqrt (fabs (* -2.0 (/ F B)))))))))))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 = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
double t_2 = 0.25 * ((sqrt((-16.0 * A)) * sqrt(F)) / A);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -5e-171) {
tmp = 1.0 / (((C * (A * 4.0)) - (B * B)) / sqrt((((C + A) + sqrt(fma((C - A), (C - A), (B * B)))) * ((F + F) * fma((-4.0 * A), C, (B * B))))));
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((sqrt((-16.0 * F)) / A) * 0.25) * sqrt(A);
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
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 = 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) t_2 = Float64(0.25 * Float64(Float64(sqrt(Float64(-16.0 * A)) * sqrt(F)) / A)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -5e-171) tmp = Float64(1.0 / Float64(Float64(Float64(C * Float64(A * 4.0)) - Float64(B * B)) / sqrt(Float64(Float64(Float64(C + A) + sqrt(fma(Float64(C - A), Float64(C - A), Float64(B * B)))) * Float64(Float64(F + F) * fma(Float64(-4.0 * A), C, Float64(B * B))))))); elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(-16.0 * F)) / A) * 0.25) * sqrt(A)); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); 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[((-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]}, Block[{t$95$2 = N[(0.25 * N[(N[(N[Sqrt[N[(-16.0 * A), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -5e-171], N[(1.0 / N[(N[(N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(N[(C - A), $MachinePrecision] * N[(C - A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(F + F), $MachinePrecision] * N[(N[(-4.0 * A), $MachinePrecision] * C + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[Sqrt[N[(-16.0 * F), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision] * 0.25), $MachinePrecision] * N[Sqrt[A], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $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 := \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}\\
t_2 := 0.25 \cdot \frac{\sqrt{-16 \cdot A} \cdot \sqrt{F}}{A}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-171}:\\
\;\;\;\;\frac{1}{\frac{C \cdot \left(A \cdot 4\right) - B \cdot B}{\sqrt{\left(\left(C + A\right) + \sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)}\right) \cdot \left(\left(F + F\right) \cdot \mathsf{fma}\left(-4 \cdot A, C, B \cdot B\right)\right)}}}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{-16 \cdot F}}{A} \cdot 0.25\right) \cdot \sqrt{A}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\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.99999999999999992e-171 < (/.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))) < -0.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-special-*.f64N/A
lower-special-sqrt.f64N/A
lower-*.f64N/A
lower-special-sqrt.f6434.9
Applied rewrites34.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))) < -4.99999999999999992e-171Initial program 19.7%
Applied rewrites19.8%
Applied rewrites19.7%
if -0.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))) < +inf.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
mult-flipN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6436.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
sqrt-unprodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6411.6
Applied rewrites11.6%
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 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.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 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_1
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0))
(t_2 (* 0.25 (/ (* (sqrt (* -16.0 A)) (sqrt F)) A))))
(if (<= t_1 -2e+204)
t_2
(if (<= t_1 -5e-171)
(/
(sqrt
(*
(* (+ (sqrt (fma (- C A) (- C A) (* B B))) (+ C A)) (+ F F))
(fma (* C -4.0) A (* B B))))
(- (* C (* A 4.0)) (* B B)))
(if (<= t_1 0.0)
t_2
(if (<= t_1 INFINITY)
(* (* (/ (sqrt (* -16.0 F)) A) 0.25) (sqrt A))
(- (sqrt (fabs (* -2.0 (/ F B)))))))))))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 = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
double t_2 = 0.25 * ((sqrt((-16.0 * A)) * sqrt(F)) / A);
double tmp;
if (t_1 <= -2e+204) {
tmp = t_2;
} else if (t_1 <= -5e-171) {
tmp = sqrt((((sqrt(fma((C - A), (C - A), (B * B))) + (C + A)) * (F + F)) * fma((C * -4.0), A, (B * B)))) / ((C * (A * 4.0)) - (B * B));
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((sqrt((-16.0 * F)) / A) * 0.25) * sqrt(A);
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
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 = 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) t_2 = Float64(0.25 * Float64(Float64(sqrt(Float64(-16.0 * A)) * sqrt(F)) / A)) tmp = 0.0 if (t_1 <= -2e+204) tmp = t_2; elseif (t_1 <= -5e-171) tmp = Float64(sqrt(Float64(Float64(Float64(sqrt(fma(Float64(C - A), Float64(C - A), Float64(B * B))) + Float64(C + A)) * Float64(F + F)) * fma(Float64(C * -4.0), A, Float64(B * B)))) / Float64(Float64(C * Float64(A * 4.0)) - Float64(B * B))); elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(-16.0 * F)) / A) * 0.25) * sqrt(A)); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); 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[((-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]}, Block[{t$95$2 = N[(0.25 * N[(N[(N[Sqrt[N[(-16.0 * A), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+204], t$95$2, If[LessEqual[t$95$1, -5e-171], N[(N[Sqrt[N[(N[(N[(N[Sqrt[N[(N[(C - A), $MachinePrecision] * N[(C - A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(C + A), $MachinePrecision]), $MachinePrecision] * N[(F + F), $MachinePrecision]), $MachinePrecision] * N[(N[(C * -4.0), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[Sqrt[N[(-16.0 * F), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision] * 0.25), $MachinePrecision] * N[Sqrt[A], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $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 := \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}\\
t_2 := 0.25 \cdot \frac{\sqrt{-16 \cdot A} \cdot \sqrt{F}}{A}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+204}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-171}:\\
\;\;\;\;\frac{\sqrt{\left(\left(\sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)} + \left(C + A\right)\right) \cdot \left(F + F\right)\right) \cdot \mathsf{fma}\left(C \cdot -4, A, B \cdot B\right)}}{C \cdot \left(A \cdot 4\right) - B \cdot B}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{-16 \cdot F}}{A} \cdot 0.25\right) \cdot \sqrt{A}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\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))) < -1.99999999999999998e204 or -4.99999999999999992e-171 < (/.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))) < -0.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-special-*.f64N/A
lower-special-sqrt.f64N/A
lower-*.f64N/A
lower-special-sqrt.f6434.9
Applied rewrites34.9%
if -1.99999999999999998e204 < (/.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.99999999999999992e-171Initial program 19.7%
Applied rewrites19.8%
if -0.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))) < +inf.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
mult-flipN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6436.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
sqrt-unprodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6411.6
Applied rewrites11.6%
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 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.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 (- (pow B 2.0) (* (* 4.0 A) C)))
(t_1
(/
(-
(sqrt
(*
(* 2.0 (* t_0 F))
(+ (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0)))))))
t_0))
(t_2 (* 0.25 (/ (* (sqrt (* -16.0 A)) (sqrt F)) A))))
(if (<= t_1 -2e+204)
t_2
(if (<= t_1 -5e-171)
(/
1.0
(/
(- (* C (* A 4.0)) (* B B))
(sqrt
(*
(* (+ (sqrt (fma C C (* B B))) (+ C A)) (+ F F))
(fma (* C -4.0) A (* B B))))))
(if (<= t_1 0.0)
t_2
(if (<= t_1 INFINITY)
(* (* (/ (sqrt (* -16.0 F)) A) 0.25) (sqrt A))
(- (sqrt (fabs (* -2.0 (/ F B)))))))))))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 = -sqrt(((2.0 * (t_0 * F)) * ((A + C) + sqrt((pow((A - C), 2.0) + pow(B, 2.0)))))) / t_0;
double t_2 = 0.25 * ((sqrt((-16.0 * A)) * sqrt(F)) / A);
double tmp;
if (t_1 <= -2e+204) {
tmp = t_2;
} else if (t_1 <= -5e-171) {
tmp = 1.0 / (((C * (A * 4.0)) - (B * B)) / sqrt((((sqrt(fma(C, C, (B * B))) + (C + A)) * (F + F)) * fma((C * -4.0), A, (B * B)))));
} else if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((sqrt((-16.0 * F)) / A) * 0.25) * sqrt(A);
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
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 = 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) t_2 = Float64(0.25 * Float64(Float64(sqrt(Float64(-16.0 * A)) * sqrt(F)) / A)) tmp = 0.0 if (t_1 <= -2e+204) tmp = t_2; elseif (t_1 <= -5e-171) tmp = Float64(1.0 / Float64(Float64(Float64(C * Float64(A * 4.0)) - Float64(B * B)) / sqrt(Float64(Float64(Float64(sqrt(fma(C, C, Float64(B * B))) + Float64(C + A)) * Float64(F + F)) * fma(Float64(C * -4.0), A, Float64(B * B)))))); elseif (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(sqrt(Float64(-16.0 * F)) / A) * 0.25) * sqrt(A)); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); 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[((-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]}, Block[{t$95$2 = N[(0.25 * N[(N[(N[Sqrt[N[(-16.0 * A), $MachinePrecision]], $MachinePrecision] * N[Sqrt[F], $MachinePrecision]), $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+204], t$95$2, If[LessEqual[t$95$1, -5e-171], N[(1.0 / N[(N[(N[(C * N[(A * 4.0), $MachinePrecision]), $MachinePrecision] - N[(B * B), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Sqrt[N[(C * C + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(C + A), $MachinePrecision]), $MachinePrecision] * N[(F + F), $MachinePrecision]), $MachinePrecision] * N[(N[(C * -4.0), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[Sqrt[N[(-16.0 * F), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision] * 0.25), $MachinePrecision] * N[Sqrt[A], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $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 := \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}\\
t_2 := 0.25 \cdot \frac{\sqrt{-16 \cdot A} \cdot \sqrt{F}}{A}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+204}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-171}:\\
\;\;\;\;\frac{1}{\frac{C \cdot \left(A \cdot 4\right) - B \cdot B}{\sqrt{\left(\left(\sqrt{\mathsf{fma}\left(C, C, B \cdot B\right)} + \left(C + A\right)\right) \cdot \left(F + F\right)\right) \cdot \mathsf{fma}\left(C \cdot -4, A, B \cdot B\right)}}}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left(\frac{\sqrt{-16 \cdot F}}{A} \cdot 0.25\right) \cdot \sqrt{A}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\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))) < -1.99999999999999998e204 or -4.99999999999999992e-171 < (/.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))) < -0.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-special-*.f64N/A
lower-special-sqrt.f64N/A
lower-*.f64N/A
lower-special-sqrt.f6434.9
Applied rewrites34.9%
if -1.99999999999999998e204 < (/.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.99999999999999992e-171Initial program 19.7%
Applied rewrites19.8%
Taylor expanded in A around 0
Applied rewrites18.6%
Taylor expanded in A around 0
Applied rewrites19.1%
if -0.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))) < +inf.0Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
mult-flipN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6436.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.9
Applied rewrites36.9%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
sqrt-unprodN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6411.6
Applied rewrites11.6%
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 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 1e-114)
(* 0.25 (/ (sqrt (* -16.0 (* A F))) A))
(if (<= (pow B 2.0) 2e+281)
(/
(-
(*
(sqrt (fma (* C -4.0) A (* B B)))
(*
(sqrt (+ (+ C A) (sqrt (fma (- C A) (- C A) (* B B)))))
(sqrt (+ F F)))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(- (sqrt (fabs (* -2.0 (/ F B))))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 1e-114) {
tmp = 0.25 * (sqrt((-16.0 * (A * F))) / A);
} else if (pow(B, 2.0) <= 2e+281) {
tmp = -(sqrt(fma((C * -4.0), A, (B * B))) * (sqrt(((C + A) + sqrt(fma((C - A), (C - A), (B * B))))) * sqrt((F + F)))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 1e-114) tmp = Float64(0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); elseif ((B ^ 2.0) <= 2e+281) tmp = Float64(Float64(-Float64(sqrt(fma(Float64(C * -4.0), A, Float64(B * B))) * Float64(sqrt(Float64(Float64(C + A) + sqrt(fma(Float64(C - A), Float64(C - A), Float64(B * B))))) * sqrt(Float64(F + F))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); 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[N[Power[B, 2.0], $MachinePrecision], 1e-114], N[(0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 2e+281], N[((-N[(N[Sqrt[N[(N[(C * -4.0), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(N[(C + A), $MachinePrecision] + N[Sqrt[N[(N[(C - A), $MachinePrecision] * N[(C - A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(F + F), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 10^{-114}:\\
\;\;\;\;0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\mathbf{elif}\;{B}^{2} \leq 2 \cdot 10^{+281}:\\
\;\;\;\;\frac{-\sqrt{\mathsf{fma}\left(C \cdot -4, A, B \cdot B\right)} \cdot \left(\sqrt{\left(C + A\right) + \sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)}} \cdot \sqrt{F + F}\right)}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.0000000000000001e-114Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
if 1.0000000000000001e-114 < (pow.f64 B #s(literal 2 binary64)) < 2.0000000000000001e281Initial program 19.7%
Applied rewrites19.8%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-special-*.f64N/A
lower-special-sqrt.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-special-sqrt.f6421.4
Applied rewrites21.4%
if 2.0000000000000001e281 < (pow.f64 B #s(literal 2 binary64)) Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function.
(FPCore (A B C F)
:precision binary64
(if (<= (pow B 2.0) 1e-114)
(* 0.25 (/ (sqrt (* -16.0 (* A F))) A))
(if (<= (pow B 2.0) 5e+165)
(/
(-
(*
(sqrt (+ F F))
(sqrt
(*
(+ (sqrt (fma (- C A) (- C A) (* B B))) (+ C A))
(fma (* C -4.0) A (* B B))))))
(- (pow B 2.0) (* (* 4.0 A) C)))
(- (sqrt (fabs (* -2.0 (/ F B))))))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 1e-114) {
tmp = 0.25 * (sqrt((-16.0 * (A * F))) / A);
} else if (pow(B, 2.0) <= 5e+165) {
tmp = -(sqrt((F + F)) * sqrt(((sqrt(fma((C - A), (C - A), (B * B))) + (C + A)) * fma((C * -4.0), A, (B * B))))) / (pow(B, 2.0) - ((4.0 * A) * C));
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
return tmp;
}
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 1e-114) tmp = Float64(0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); elseif ((B ^ 2.0) <= 5e+165) tmp = Float64(Float64(-Float64(sqrt(Float64(F + F)) * sqrt(Float64(Float64(sqrt(fma(Float64(C - A), Float64(C - A), Float64(B * B))) + Float64(C + A)) * fma(Float64(C * -4.0), A, Float64(B * B)))))) / Float64((B ^ 2.0) - Float64(Float64(4.0 * A) * C))); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); 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[N[Power[B, 2.0], $MachinePrecision], 1e-114], N[(0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[B, 2.0], $MachinePrecision], 5e+165], N[((-N[(N[Sqrt[N[(F + F), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[(N[Sqrt[N[(N[(C - A), $MachinePrecision] * N[(C - A), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(C + A), $MachinePrecision]), $MachinePrecision] * N[(N[(C * -4.0), $MachinePrecision] * A + N[(B * B), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) / N[(N[Power[B, 2.0], $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 10^{-114}:\\
\;\;\;\;0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\mathbf{elif}\;{B}^{2} \leq 5 \cdot 10^{+165}:\\
\;\;\;\;\frac{-\sqrt{F + F} \cdot \sqrt{\left(\sqrt{\mathsf{fma}\left(C - A, C - A, B \cdot B\right)} + \left(C + A\right)\right) \cdot \mathsf{fma}\left(C \cdot -4, A, B \cdot B\right)}}{{B}^{2} - \left(4 \cdot A\right) \cdot C}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 1.0000000000000001e-114Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
if 1.0000000000000001e-114 < (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999997e165Initial program 19.7%
Applied rewrites17.0%
if 4.9999999999999997e165 < (pow.f64 B #s(literal 2 binary64)) Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (if (<= (pow B 2.0) 5e-49) (* 0.25 (/ (sqrt (* -16.0 (* A F))) A)) (- (sqrt (fabs (* -2.0 (/ F B)))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (pow(B, 2.0) <= 5e-49) {
tmp = 0.25 * (sqrt((-16.0 * (A * F))) / A);
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
return tmp;
}
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
real(8) :: tmp
if ((b ** 2.0d0) <= 5d-49) then
tmp = 0.25d0 * (sqrt(((-16.0d0) * (a * f))) / a)
else
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.pow(B, 2.0) <= 5e-49) {
tmp = 0.25 * (Math.sqrt((-16.0 * (A * F))) / A);
} else {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if math.pow(B, 2.0) <= 5e-49: tmp = 0.25 * (math.sqrt((-16.0 * (A * F))) / A) else: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if ((B ^ 2.0) <= 5e-49) tmp = Float64(0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if ((B ^ 2.0) <= 5e-49)
tmp = 0.25 * (sqrt((-16.0 * (A * F))) / A);
else
tmp = -sqrt(abs((-2.0 * (F / B))));
end
tmp_2 = 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[N[Power[B, 2.0], $MachinePrecision], 5e-49], N[(0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
\mathbf{if}\;{B}^{2} \leq 5 \cdot 10^{-49}:\\
\;\;\;\;0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\end{array}
\end{array}
if (pow.f64 B #s(literal 2 binary64)) < 4.9999999999999999e-49Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
if 4.9999999999999999e-49 < (pow.f64 B #s(literal 2 binary64)) Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.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 (sqrt (* -16.0 (/ F A)))))
(if (<= A -2e-61)
(* -0.25 t_0)
(if (<= A 5e-195) (- (sqrt (fabs (* -2.0 (/ F B))))) (* 0.25 t_0)))))assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double t_0 = sqrt((-16.0 * (F / A)));
double tmp;
if (A <= -2e-61) {
tmp = -0.25 * t_0;
} else if (A <= 5e-195) {
tmp = -sqrt(fabs((-2.0 * (F / B))));
} else {
tmp = 0.25 * t_0;
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((-16.0d0) * (f / a)))
if (a <= (-2d-61)) then
tmp = (-0.25d0) * t_0
else if (a <= 5d-195) then
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
else
tmp = 0.25d0 * t_0
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((-16.0 * (F / A)));
double tmp;
if (A <= -2e-61) {
tmp = -0.25 * t_0;
} else if (A <= 5e-195) {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
} else {
tmp = 0.25 * t_0;
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): t_0 = math.sqrt((-16.0 * (F / A))) tmp = 0 if A <= -2e-61: tmp = -0.25 * t_0 elif A <= 5e-195: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) else: tmp = 0.25 * t_0 return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) t_0 = sqrt(Float64(-16.0 * Float64(F / A))) tmp = 0.0 if (A <= -2e-61) tmp = Float64(-0.25 * t_0); elseif (A <= 5e-195) tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); else tmp = Float64(0.25 * t_0); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
t_0 = sqrt((-16.0 * (F / A)));
tmp = 0.0;
if (A <= -2e-61)
tmp = -0.25 * t_0;
elseif (A <= 5e-195)
tmp = -sqrt(abs((-2.0 * (F / B))));
else
tmp = 0.25 * t_0;
end
tmp_2 = 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[Sqrt[N[(-16.0 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[A, -2e-61], N[(-0.25 * t$95$0), $MachinePrecision], If[LessEqual[A, 5e-195], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), N[(0.25 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
\begin{array}{l}
t_0 := \sqrt{-16 \cdot \frac{F}{A}}\\
\mathbf{if}\;A \leq -2 \cdot 10^{-61}:\\
\;\;\;\;-0.25 \cdot t\_0\\
\mathbf{elif}\;A \leq 5 \cdot 10^{-195}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot t\_0\\
\end{array}
\end{array}
if A < -2.0000000000000001e-61Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6427.5
Applied rewrites27.5%
if -2.0000000000000001e-61 < A < 5.00000000000000009e-195Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
if 5.00000000000000009e-195 < A Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
Taylor expanded in A around inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6421.4
Applied rewrites21.4%
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.25e-23) (* -0.25 (sqrt (* -16.0 (/ F A)))) (- (sqrt (fabs (* -2.0 (/ F B)))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.25e-23) {
tmp = -0.25 * sqrt((-16.0 * (F / A)));
} else {
tmp = -sqrt(fabs((-2.0 * (F / B))));
}
return tmp;
}
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
real(8) :: tmp
if (b <= 2.25d-23) then
tmp = (-0.25d0) * sqrt(((-16.0d0) * (f / a)))
else
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
end if
code = tmp
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 2.25e-23) {
tmp = -0.25 * Math.sqrt((-16.0 * (F / A)));
} else {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
}
return tmp;
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): tmp = 0 if B <= 2.25e-23: tmp = -0.25 * math.sqrt((-16.0 * (F / A))) else: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) return tmp
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) tmp = 0.0 if (B <= 2.25e-23) tmp = Float64(-0.25 * sqrt(Float64(-16.0 * Float64(F / A)))); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); end return tmp end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp_2 = code(A, B, C, F)
tmp = 0.0;
if (B <= 2.25e-23)
tmp = -0.25 * sqrt((-16.0 * (F / A)));
else
tmp = -sqrt(abs((-2.0 * (F / B))));
end
tmp_2 = 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.25e-23], N[(-0.25 * N[Sqrt[N[(-16.0 * N[(F / A), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $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.25 \cdot 10^{-23}:\\
\;\;\;\;-0.25 \cdot \sqrt{-16 \cdot \frac{F}{A}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\end{array}
\end{array}
if B < 2.24999999999999987e-23Initial program 19.7%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6436.9
Applied rewrites36.9%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6427.5
Applied rewrites27.5%
if 2.24999999999999987e-23 < B Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (sqrt (fabs (* -2.0 (/ F B))))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt(fabs((-2.0 * (F / B))));
}
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 = -sqrt(abs(((-2.0d0) * (f / b))))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt(Math.abs((-2.0 * (F / B))));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt(math.fabs((-2.0 * (F / B))))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt(abs((-2.0 * (F / B))));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}
\end{array}
Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6427.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.1
Applied rewrites27.1%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (sqrt (* (/ F B) -2.0))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt(((F / B) * -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 = -sqrt(((f / b) * (-2.0d0)))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt(((F / B) * -2.0));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt(((F / B) * -2.0))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-sqrt(Float64(Float64(F / B) * -2.0))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt(((F / B) * -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[Sqrt[N[(N[(F / B), $MachinePrecision] * -2.0), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-\sqrt{\frac{F}{B} \cdot -2}
\end{array}
Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. (FPCore (A B C F) :precision binary64 (- (sqrt (* F (/ -2.0 B)))))
assert(A < B && B < C && C < F);
double code(double A, double B, double C, double F) {
return -sqrt((F * (-2.0 / B)));
}
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 = -sqrt((f * ((-2.0d0) / b)))
end function
assert A < B && B < C && C < F;
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((F * (-2.0 / B)));
}
[A, B, C, F] = sort([A, B, C, F]) def code(A, B, C, F): return -math.sqrt((F * (-2.0 / B)))
A, B, C, F = sort([A, B, C, F]) function code(A, B, C, F) return Float64(-sqrt(Float64(F * Float64(-2.0 / B)))) end
A, B, C, F = num2cell(sort([A, B, C, F])){:}
function tmp = code(A, B, C, F)
tmp = -sqrt((F * (-2.0 / B)));
end
NOTE: A, B, C, and F should be sorted in increasing order before calling this function. code[A_, B_, C_, F_] := (-N[Sqrt[N[(F * N[(-2.0 / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
[A, B, C, F] = \mathsf{sort}([A, B, C, F])\\
\\
-\sqrt{F \cdot \frac{-2}{B}}
\end{array}
Initial program 19.7%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.0
Applied rewrites14.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6414.0
Applied rewrites14.0%
herbie shell --seed 2025150
(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))))