
(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}
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}
Herbie found 7 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}
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}
(FPCore (A B C F)
:precision binary64
(if (<= (fmax A C) -6.2e-268)
(* 0.25 (* (sqrt F) (sqrt (/ -16.0 (fmin A C)))))
(if (<= (fmax A C) 1.5e+51)
(- (sqrt (fabs (* -2.0 (/ F B)))))
(* 0.25 (/ (sqrt (* (* -16.0 F) (fmin A C))) (fmin A C))))))double code(double A, double B, double C, double F) {
double tmp;
if (fmax(A, C) <= -6.2e-268) {
tmp = 0.25 * (sqrt(F) * sqrt((-16.0 / fmin(A, C))));
} else if (fmax(A, C) <= 1.5e+51) {
tmp = -sqrt(fabs((-2.0 * (F / B))));
} else {
tmp = 0.25 * (sqrt(((-16.0 * F) * fmin(A, C))) / fmin(A, C));
}
return tmp;
}
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 (fmax(a, c) <= (-6.2d-268)) then
tmp = 0.25d0 * (sqrt(f) * sqrt(((-16.0d0) / fmin(a, c))))
else if (fmax(a, c) <= 1.5d+51) then
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
else
tmp = 0.25d0 * (sqrt((((-16.0d0) * f) * fmin(a, c))) / fmin(a, c))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (fmax(A, C) <= -6.2e-268) {
tmp = 0.25 * (Math.sqrt(F) * Math.sqrt((-16.0 / fmin(A, C))));
} else if (fmax(A, C) <= 1.5e+51) {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
} else {
tmp = 0.25 * (Math.sqrt(((-16.0 * F) * fmin(A, C))) / fmin(A, C));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if fmax(A, C) <= -6.2e-268: tmp = 0.25 * (math.sqrt(F) * math.sqrt((-16.0 / fmin(A, C)))) elif fmax(A, C) <= 1.5e+51: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) else: tmp = 0.25 * (math.sqrt(((-16.0 * F) * fmin(A, C))) / fmin(A, C)) return tmp
function code(A, B, C, F) tmp = 0.0 if (fmax(A, C) <= -6.2e-268) tmp = Float64(0.25 * Float64(sqrt(F) * sqrt(Float64(-16.0 / fmin(A, C))))); elseif (fmax(A, C) <= 1.5e+51) tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); else tmp = Float64(0.25 * Float64(sqrt(Float64(Float64(-16.0 * F) * fmin(A, C))) / fmin(A, C))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (max(A, C) <= -6.2e-268) tmp = 0.25 * (sqrt(F) * sqrt((-16.0 / min(A, C)))); elseif (max(A, C) <= 1.5e+51) tmp = -sqrt(abs((-2.0 * (F / B)))); else tmp = 0.25 * (sqrt(((-16.0 * F) * min(A, C))) / min(A, C)); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[N[Max[A, C], $MachinePrecision], -6.2e-268], N[(0.25 * N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(-16.0 / N[Min[A, C], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Max[A, C], $MachinePrecision], 1.5e+51], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), N[(0.25 * N[(N[Sqrt[N[(N[(-16.0 * F), $MachinePrecision] * N[Min[A, C], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Min[A, C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(A, C\right) \leq -6.2 \cdot 10^{-268}:\\
\;\;\;\;0.25 \cdot \left(\sqrt{F} \cdot \sqrt{\frac{-16}{\mathsf{min}\left(A, C\right)}}\right)\\
\mathbf{elif}\;\mathsf{max}\left(A, C\right) \leq 1.5 \cdot 10^{+51}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\sqrt{\left(-16 \cdot F\right) \cdot \mathsf{min}\left(A, C\right)}}{\mathsf{min}\left(A, C\right)}\\
\end{array}
if C < -6.1999999999999996e-268Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f64N/A
lower-unsound-sqrt.f6417.8%
Applied rewrites17.8%
Taylor expanded in A around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f647.5%
Applied rewrites7.5%
if -6.1999999999999996e-268 < C < 1.5e51Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
if 1.5e51 < C Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
(FPCore (A B C F)
:precision binary64
(if (<= (fmax A C) -6.2e-268)
(* 0.25 (* (sqrt F) (sqrt (/ -16.0 (fmin A C)))))
(if (<= (fmax A C) 1.5e+51)
(- (sqrt (fabs (* -2.0 (/ F B)))))
(* 0.25 (/ (sqrt (* -16.0 (* (fmin A C) F))) (fmin A C))))))double code(double A, double B, double C, double F) {
double tmp;
if (fmax(A, C) <= -6.2e-268) {
tmp = 0.25 * (sqrt(F) * sqrt((-16.0 / fmin(A, C))));
} else if (fmax(A, C) <= 1.5e+51) {
tmp = -sqrt(fabs((-2.0 * (F / B))));
} else {
tmp = 0.25 * (sqrt((-16.0 * (fmin(A, C) * F))) / fmin(A, C));
}
return tmp;
}
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 (fmax(a, c) <= (-6.2d-268)) then
tmp = 0.25d0 * (sqrt(f) * sqrt(((-16.0d0) / fmin(a, c))))
else if (fmax(a, c) <= 1.5d+51) then
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
else
tmp = 0.25d0 * (sqrt(((-16.0d0) * (fmin(a, c) * f))) / fmin(a, c))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (fmax(A, C) <= -6.2e-268) {
tmp = 0.25 * (Math.sqrt(F) * Math.sqrt((-16.0 / fmin(A, C))));
} else if (fmax(A, C) <= 1.5e+51) {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
} else {
tmp = 0.25 * (Math.sqrt((-16.0 * (fmin(A, C) * F))) / fmin(A, C));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if fmax(A, C) <= -6.2e-268: tmp = 0.25 * (math.sqrt(F) * math.sqrt((-16.0 / fmin(A, C)))) elif fmax(A, C) <= 1.5e+51: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) else: tmp = 0.25 * (math.sqrt((-16.0 * (fmin(A, C) * F))) / fmin(A, C)) return tmp
function code(A, B, C, F) tmp = 0.0 if (fmax(A, C) <= -6.2e-268) tmp = Float64(0.25 * Float64(sqrt(F) * sqrt(Float64(-16.0 / fmin(A, C))))); elseif (fmax(A, C) <= 1.5e+51) tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); else tmp = Float64(0.25 * Float64(sqrt(Float64(-16.0 * Float64(fmin(A, C) * F))) / fmin(A, C))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (max(A, C) <= -6.2e-268) tmp = 0.25 * (sqrt(F) * sqrt((-16.0 / min(A, C)))); elseif (max(A, C) <= 1.5e+51) tmp = -sqrt(abs((-2.0 * (F / B)))); else tmp = 0.25 * (sqrt((-16.0 * (min(A, C) * F))) / min(A, C)); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[N[Max[A, C], $MachinePrecision], -6.2e-268], N[(0.25 * N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(-16.0 / N[Min[A, C], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Max[A, C], $MachinePrecision], 1.5e+51], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), N[(0.25 * N[(N[Sqrt[N[(-16.0 * N[(N[Min[A, C], $MachinePrecision] * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Min[A, C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(A, C\right) \leq -6.2 \cdot 10^{-268}:\\
\;\;\;\;0.25 \cdot \left(\sqrt{F} \cdot \sqrt{\frac{-16}{\mathsf{min}\left(A, C\right)}}\right)\\
\mathbf{elif}\;\mathsf{max}\left(A, C\right) \leq 1.5 \cdot 10^{+51}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\sqrt{-16 \cdot \left(\mathsf{min}\left(A, C\right) \cdot F\right)}}{\mathsf{min}\left(A, C\right)}\\
\end{array}
if C < -6.1999999999999996e-268Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f64N/A
lower-unsound-sqrt.f6417.8%
Applied rewrites17.8%
Taylor expanded in A around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f647.5%
Applied rewrites7.5%
if -6.1999999999999996e-268 < C < 1.5e51Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
if 1.5e51 < C Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
(FPCore (A B C F)
:precision binary64
(if (<= (fmin A C) -5.6e-218)
(* -0.25 (* (sqrt F) (sqrt (/ -16.0 (fmin A C)))))
(if (<= (fmin A C) 5.5e-86)
(- (sqrt (fabs (* -2.0 (/ F B)))))
(* 0.25 (sqrt (* -16.0 (/ F (fmin A C))))))))double code(double A, double B, double C, double F) {
double tmp;
if (fmin(A, C) <= -5.6e-218) {
tmp = -0.25 * (sqrt(F) * sqrt((-16.0 / fmin(A, C))));
} else if (fmin(A, C) <= 5.5e-86) {
tmp = -sqrt(fabs((-2.0 * (F / B))));
} else {
tmp = 0.25 * sqrt((-16.0 * (F / fmin(A, C))));
}
return tmp;
}
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 (fmin(a, c) <= (-5.6d-218)) then
tmp = (-0.25d0) * (sqrt(f) * sqrt(((-16.0d0) / fmin(a, c))))
else if (fmin(a, c) <= 5.5d-86) then
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
else
tmp = 0.25d0 * sqrt(((-16.0d0) * (f / fmin(a, c))))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (fmin(A, C) <= -5.6e-218) {
tmp = -0.25 * (Math.sqrt(F) * Math.sqrt((-16.0 / fmin(A, C))));
} else if (fmin(A, C) <= 5.5e-86) {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
} else {
tmp = 0.25 * Math.sqrt((-16.0 * (F / fmin(A, C))));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if fmin(A, C) <= -5.6e-218: tmp = -0.25 * (math.sqrt(F) * math.sqrt((-16.0 / fmin(A, C)))) elif fmin(A, C) <= 5.5e-86: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) else: tmp = 0.25 * math.sqrt((-16.0 * (F / fmin(A, C)))) return tmp
function code(A, B, C, F) tmp = 0.0 if (fmin(A, C) <= -5.6e-218) tmp = Float64(-0.25 * Float64(sqrt(F) * sqrt(Float64(-16.0 / fmin(A, C))))); elseif (fmin(A, C) <= 5.5e-86) tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); else tmp = Float64(0.25 * sqrt(Float64(-16.0 * Float64(F / fmin(A, C))))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (min(A, C) <= -5.6e-218) tmp = -0.25 * (sqrt(F) * sqrt((-16.0 / min(A, C)))); elseif (min(A, C) <= 5.5e-86) tmp = -sqrt(abs((-2.0 * (F / B)))); else tmp = 0.25 * sqrt((-16.0 * (F / min(A, C)))); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[N[Min[A, C], $MachinePrecision], -5.6e-218], N[(-0.25 * N[(N[Sqrt[F], $MachinePrecision] * N[Sqrt[N[(-16.0 / N[Min[A, C], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Min[A, C], $MachinePrecision], 5.5e-86], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), N[(0.25 * N[Sqrt[N[(-16.0 * N[(F / N[Min[A, C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\mathsf{min}\left(A, C\right) \leq -5.6 \cdot 10^{-218}:\\
\;\;\;\;-0.25 \cdot \left(\sqrt{F} \cdot \sqrt{\frac{-16}{\mathsf{min}\left(A, C\right)}}\right)\\
\mathbf{elif}\;\mathsf{min}\left(A, C\right) \leq 5.5 \cdot 10^{-86}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \sqrt{-16 \cdot \frac{F}{\mathsf{min}\left(A, C\right)}}\\
\end{array}
if A < -5.60000000000000018e-218Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
lift-sqrt.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-*.f64N/A
lower-unsound-sqrt.f6417.8%
Applied rewrites17.8%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f6417.8%
Applied rewrites17.8%
if -5.60000000000000018e-218 < A < 5.5e-86Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
if 5.5e-86 < A Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
Taylor expanded in A around inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6411.4%
Applied rewrites11.4%
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (sqrt (* -16.0 (/ F (fmin A C))))) (t_1 (* 0.25 t_0)))
(if (<= (fmax A C) -5.7e-268)
t_1
(if (<= (fmax A C) 1.25e+127)
(- (sqrt (fabs (* -2.0 (/ F B)))))
(if (<= (fmax A C) 1e+241) (* -0.25 t_0) t_1)))))double code(double A, double B, double C, double F) {
double t_0 = sqrt((-16.0 * (F / fmin(A, C))));
double t_1 = 0.25 * t_0;
double tmp;
if (fmax(A, C) <= -5.7e-268) {
tmp = t_1;
} else if (fmax(A, C) <= 1.25e+127) {
tmp = -sqrt(fabs((-2.0 * (F / B))));
} else if (fmax(A, C) <= 1e+241) {
tmp = -0.25 * t_0;
} else {
tmp = t_1;
}
return tmp;
}
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) :: t_1
real(8) :: tmp
t_0 = sqrt(((-16.0d0) * (f / fmin(a, c))))
t_1 = 0.25d0 * t_0
if (fmax(a, c) <= (-5.7d-268)) then
tmp = t_1
else if (fmax(a, c) <= 1.25d+127) then
tmp = -sqrt(abs(((-2.0d0) * (f / b))))
else if (fmax(a, c) <= 1d+241) then
tmp = (-0.25d0) * t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double t_0 = Math.sqrt((-16.0 * (F / fmin(A, C))));
double t_1 = 0.25 * t_0;
double tmp;
if (fmax(A, C) <= -5.7e-268) {
tmp = t_1;
} else if (fmax(A, C) <= 1.25e+127) {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / B))));
} else if (fmax(A, C) <= 1e+241) {
tmp = -0.25 * t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(A, B, C, F): t_0 = math.sqrt((-16.0 * (F / fmin(A, C)))) t_1 = 0.25 * t_0 tmp = 0 if fmax(A, C) <= -5.7e-268: tmp = t_1 elif fmax(A, C) <= 1.25e+127: tmp = -math.sqrt(math.fabs((-2.0 * (F / B)))) elif fmax(A, C) <= 1e+241: tmp = -0.25 * t_0 else: tmp = t_1 return tmp
function code(A, B, C, F) t_0 = sqrt(Float64(-16.0 * Float64(F / fmin(A, C)))) t_1 = Float64(0.25 * t_0) tmp = 0.0 if (fmax(A, C) <= -5.7e-268) tmp = t_1; elseif (fmax(A, C) <= 1.25e+127) tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))); elseif (fmax(A, C) <= 1e+241) tmp = Float64(-0.25 * t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(A, B, C, F) t_0 = sqrt((-16.0 * (F / min(A, C)))); t_1 = 0.25 * t_0; tmp = 0.0; if (max(A, C) <= -5.7e-268) tmp = t_1; elseif (max(A, C) <= 1.25e+127) tmp = -sqrt(abs((-2.0 * (F / B)))); elseif (max(A, C) <= 1e+241) tmp = -0.25 * t_0; else tmp = t_1; end tmp_2 = tmp; end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[Sqrt[N[(-16.0 * N[(F / N[Min[A, C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(0.25 * t$95$0), $MachinePrecision]}, If[LessEqual[N[Max[A, C], $MachinePrecision], -5.7e-268], t$95$1, If[LessEqual[N[Max[A, C], $MachinePrecision], 1.25e+127], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), If[LessEqual[N[Max[A, C], $MachinePrecision], 1e+241], N[(-0.25 * t$95$0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := \sqrt{-16 \cdot \frac{F}{\mathsf{min}\left(A, C\right)}}\\
t_1 := 0.25 \cdot t\_0\\
\mathbf{if}\;\mathsf{max}\left(A, C\right) \leq -5.7 \cdot 10^{-268}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\mathsf{max}\left(A, C\right) \leq 1.25 \cdot 10^{+127}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}\\
\mathbf{elif}\;\mathsf{max}\left(A, C\right) \leq 10^{+241}:\\
\;\;\;\;-0.25 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if C < -5.6999999999999998e-268 or 1.0000000000000001e241 < C Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
Taylor expanded in A around inf
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6411.4%
Applied rewrites11.4%
if -5.6999999999999998e-268 < C < 1.2500000000000001e127Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
if 1.2500000000000001e127 < C < 1.0000000000000001e241Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.5%
Applied rewrites14.5%
(FPCore (A B C F) :precision binary64 (if (<= (fabs B) 1.05e+39) (* -0.25 (sqrt (* -16.0 (/ F (fmin A C))))) (- (sqrt (fabs (* -2.0 (/ F (fabs B))))))))
double code(double A, double B, double C, double F) {
double tmp;
if (fabs(B) <= 1.05e+39) {
tmp = -0.25 * sqrt((-16.0 * (F / fmin(A, C))));
} else {
tmp = -sqrt(fabs((-2.0 * (F / fabs(B)))));
}
return tmp;
}
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 (abs(b) <= 1.05d+39) then
tmp = (-0.25d0) * sqrt(((-16.0d0) * (f / fmin(a, c))))
else
tmp = -sqrt(abs(((-2.0d0) * (f / abs(b)))))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (Math.abs(B) <= 1.05e+39) {
tmp = -0.25 * Math.sqrt((-16.0 * (F / fmin(A, C))));
} else {
tmp = -Math.sqrt(Math.abs((-2.0 * (F / Math.abs(B)))));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if math.fabs(B) <= 1.05e+39: tmp = -0.25 * math.sqrt((-16.0 * (F / fmin(A, C)))) else: tmp = -math.sqrt(math.fabs((-2.0 * (F / math.fabs(B))))) return tmp
function code(A, B, C, F) tmp = 0.0 if (abs(B) <= 1.05e+39) tmp = Float64(-0.25 * sqrt(Float64(-16.0 * Float64(F / fmin(A, C))))); else tmp = Float64(-sqrt(abs(Float64(-2.0 * Float64(F / abs(B)))))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (abs(B) <= 1.05e+39) tmp = -0.25 * sqrt((-16.0 * (F / min(A, C)))); else tmp = -sqrt(abs((-2.0 * (F / abs(B))))); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[N[Abs[B], $MachinePrecision], 1.05e+39], N[(-0.25 * N[Sqrt[N[(-16.0 * N[(F / N[Min[A, C], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / N[Abs[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
\mathbf{if}\;\left|B\right| \leq 1.05 \cdot 10^{+39}:\\
\;\;\;\;-0.25 \cdot \sqrt{-16 \cdot \frac{F}{\mathsf{min}\left(A, C\right)}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\left|-2 \cdot \frac{F}{\left|B\right|}\right|}\\
\end{array}
if B < 1.0499999999999999e39Initial program 18.6%
Taylor expanded in C around inf
lower-*.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6419.0%
Applied rewrites19.0%
Taylor expanded in A around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.5%
Applied rewrites14.5%
if 1.0499999999999999e39 < B Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
(FPCore (A B C F) :precision binary64 (- (sqrt (fabs (* -2.0 (/ F B))))))
double code(double A, double B, double C, double F) {
return -sqrt(fabs((-2.0 * (F / B))));
}
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
public static double code(double A, double B, double C, double F) {
return -Math.sqrt(Math.abs((-2.0 * (F / B))));
}
def code(A, B, C, F): return -math.sqrt(math.fabs((-2.0 * (F / B))))
function code(A, B, C, F) return Float64(-sqrt(abs(Float64(-2.0 * Float64(F / B))))) end
function tmp = code(A, B, C, F) tmp = -sqrt(abs((-2.0 * (F / B)))); end
code[A_, B_, C_, F_] := (-N[Sqrt[N[Abs[N[(-2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])
-\sqrt{\left|-2 \cdot \frac{F}{B}\right|}
Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
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.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6427.9%
Applied rewrites27.9%
(FPCore (A B C F) :precision binary64 (- (sqrt (* F (/ -2.0 B)))))
double code(double A, double B, double C, double F) {
return -sqrt((F * (-2.0 / B)));
}
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
public static double code(double A, double B, double C, double F) {
return -Math.sqrt((F * (-2.0 / B)));
}
def code(A, B, C, F): return -math.sqrt((F * (-2.0 / B)))
function code(A, B, C, F) return Float64(-sqrt(Float64(F * Float64(-2.0 / B)))) end
function tmp = code(A, B, C, F) tmp = -sqrt((F * (-2.0 / B))); end
code[A_, B_, C_, F_] := (-N[Sqrt[N[(F * N[(-2.0 / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])
-\sqrt{F \cdot \frac{-2}{B}}
Initial program 18.6%
Taylor expanded in B around -inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6414.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6414.2%
Applied rewrites14.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6414.2%
Applied rewrites14.2%
herbie shell --seed 2025189
(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))))