
(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 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}
\\
\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}
(FPCore (A B C F)
:precision binary64
(let* ((t_0 (- (* B B) (* (* 4.0 A) C))))
(if (<= A -2.2e-87)
(* -0.25 (/ (sqrt (* -16.0 (* C F))) C))
(if (<= A 1.1e-272)
(/
(-
(sqrt
(*
(* (* t_0 F) 2.0)
(- (+ A C) (sqrt (fma (- A C) (- A C) (* B B)))))))
t_0)
(* -0.25 (/ (sqrt (* -16.0 (* A F))) A))))))
double code(double A, double B, double C, double F) {
double t_0 = (B * B) - ((4.0 * A) * C);
double tmp;
if (A <= -2.2e-87) {
tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C);
} else if (A <= 1.1e-272) {
tmp = -sqrt((((t_0 * F) * 2.0) * ((A + C) - sqrt(fma((A - C), (A - C), (B * B)))))) / t_0;
} else {
tmp = -0.25 * (sqrt((-16.0 * (A * F))) / A);
}
return tmp;
}
function code(A, B, C, F) t_0 = Float64(Float64(B * B) - Float64(Float64(4.0 * A) * C)) tmp = 0.0 if (A <= -2.2e-87) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C)); elseif (A <= 1.1e-272) tmp = Float64(Float64(-sqrt(Float64(Float64(Float64(t_0 * F) * 2.0) * Float64(Float64(A + C) - sqrt(fma(Float64(A - C), Float64(A - C), Float64(B * B))))))) / t_0); else tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(A * F))) / A)); end return tmp end
code[A_, B_, C_, F_] := Block[{t$95$0 = N[(N[(B * B), $MachinePrecision] - N[(N[(4.0 * A), $MachinePrecision] * C), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[A, -2.2e-87], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision], If[LessEqual[A, 1.1e-272], N[((-N[Sqrt[N[(N[(N[(t$95$0 * F), $MachinePrecision] * 2.0), $MachinePrecision] * N[(N[(A + C), $MachinePrecision] - N[Sqrt[N[(N[(A - C), $MachinePrecision] * N[(A - C), $MachinePrecision] + N[(B * B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t$95$0), $MachinePrecision], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(A * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / A), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := B \cdot B - \left(4 \cdot A\right) \cdot C\\
\mathbf{if}\;A \leq -2.2 \cdot 10^{-87}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
\mathbf{elif}\;A \leq 1.1 \cdot 10^{-272}:\\
\;\;\;\;\frac{-\sqrt{\left(\left(t\_0 \cdot F\right) \cdot 2\right) \cdot \left(\left(A + C\right) - \sqrt{\mathsf{fma}\left(A - C, A - C, B \cdot B\right)}\right)}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(A \cdot F\right)}}{A}\\
\end{array}
\end{array}
if A < -2.19999999999999988e-87Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
if -2.19999999999999988e-87 < A < 1.09999999999999994e-272Initial program 19.4%
Applied rewrites19.4%
if 1.09999999999999994e-272 < A Initial program 19.4%
Taylor expanded in C around -inf
Applied rewrites19.0%
(FPCore (A B C F)
:precision binary64
(if (<= B -2.35e+51)
(* -1.0 (sqrt (* 2.0 (/ F B))))
(if (<= B 6.2e-8)
(* -0.25 (/ (sqrt (* -16.0 (* C F))) C))
(- (/ (sqrt (* -2.0 (* B F))) B)))))
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -2.35e+51) {
tmp = -1.0 * sqrt((2.0 * (F / B)));
} else if (B <= 6.2e-8) {
tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -(sqrt((-2.0 * (B * F))) / 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 (b <= (-2.35d+51)) then
tmp = (-1.0d0) * sqrt((2.0d0 * (f / b)))
else if (b <= 6.2d-8) then
tmp = (-0.25d0) * (sqrt(((-16.0d0) * (c * f))) / c)
else
tmp = -(sqrt(((-2.0d0) * (b * f))) / b)
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -2.35e+51) {
tmp = -1.0 * Math.sqrt((2.0 * (F / B)));
} else if (B <= 6.2e-8) {
tmp = -0.25 * (Math.sqrt((-16.0 * (C * F))) / C);
} else {
tmp = -(Math.sqrt((-2.0 * (B * F))) / B);
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if B <= -2.35e+51: tmp = -1.0 * math.sqrt((2.0 * (F / B))) elif B <= 6.2e-8: tmp = -0.25 * (math.sqrt((-16.0 * (C * F))) / C) else: tmp = -(math.sqrt((-2.0 * (B * F))) / B) return tmp
function code(A, B, C, F) tmp = 0.0 if (B <= -2.35e+51) tmp = Float64(-1.0 * sqrt(Float64(2.0 * Float64(F / B)))); elseif (B <= 6.2e-8) tmp = Float64(-0.25 * Float64(sqrt(Float64(-16.0 * Float64(C * F))) / C)); else tmp = Float64(-Float64(sqrt(Float64(-2.0 * Float64(B * F))) / B)); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (B <= -2.35e+51) tmp = -1.0 * sqrt((2.0 * (F / B))); elseif (B <= 6.2e-8) tmp = -0.25 * (sqrt((-16.0 * (C * F))) / C); else tmp = -(sqrt((-2.0 * (B * F))) / B); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[B, -2.35e+51], N[(-1.0 * N[Sqrt[N[(2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 6.2e-8], N[(-0.25 * N[(N[Sqrt[N[(-16.0 * N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / C), $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(-2.0 * N[(B * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -2.35 \cdot 10^{+51}:\\
\;\;\;\;-1 \cdot \sqrt{2 \cdot \frac{F}{B}}\\
\mathbf{elif}\;B \leq 6.2 \cdot 10^{-8}:\\
\;\;\;\;-0.25 \cdot \frac{\sqrt{-16 \cdot \left(C \cdot F\right)}}{C}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{-2 \cdot \left(B \cdot F\right)}}{B}\\
\end{array}
\end{array}
if B < -2.3500000000000001e51Initial program 19.4%
Taylor expanded in B around -inf
Applied rewrites14.9%
if -2.3500000000000001e51 < B < 6.2e-8Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
if 6.2e-8 < B Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
Taylor expanded in B around 0
Applied rewrites14.1%
(FPCore (A B C F)
:precision binary64
(if (<= B -2.35e+51)
(* -1.0 (sqrt (* 2.0 (/ F B))))
(if (<= B 6.2e-8)
(* 0.25 (* F (sqrt (/ -16.0 (* C F)))))
(- (/ (sqrt (* -2.0 (* B F))) B)))))
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -2.35e+51) {
tmp = -1.0 * sqrt((2.0 * (F / B)));
} else if (B <= 6.2e-8) {
tmp = 0.25 * (F * sqrt((-16.0 / (C * F))));
} else {
tmp = -(sqrt((-2.0 * (B * F))) / 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 (b <= (-2.35d+51)) then
tmp = (-1.0d0) * sqrt((2.0d0 * (f / b)))
else if (b <= 6.2d-8) then
tmp = 0.25d0 * (f * sqrt(((-16.0d0) / (c * f))))
else
tmp = -(sqrt(((-2.0d0) * (b * f))) / b)
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -2.35e+51) {
tmp = -1.0 * Math.sqrt((2.0 * (F / B)));
} else if (B <= 6.2e-8) {
tmp = 0.25 * (F * Math.sqrt((-16.0 / (C * F))));
} else {
tmp = -(Math.sqrt((-2.0 * (B * F))) / B);
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if B <= -2.35e+51: tmp = -1.0 * math.sqrt((2.0 * (F / B))) elif B <= 6.2e-8: tmp = 0.25 * (F * math.sqrt((-16.0 / (C * F)))) else: tmp = -(math.sqrt((-2.0 * (B * F))) / B) return tmp
function code(A, B, C, F) tmp = 0.0 if (B <= -2.35e+51) tmp = Float64(-1.0 * sqrt(Float64(2.0 * Float64(F / B)))); elseif (B <= 6.2e-8) tmp = Float64(0.25 * Float64(F * sqrt(Float64(-16.0 / Float64(C * F))))); else tmp = Float64(-Float64(sqrt(Float64(-2.0 * Float64(B * F))) / B)); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (B <= -2.35e+51) tmp = -1.0 * sqrt((2.0 * (F / B))); elseif (B <= 6.2e-8) tmp = 0.25 * (F * sqrt((-16.0 / (C * F)))); else tmp = -(sqrt((-2.0 * (B * F))) / B); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[B, -2.35e+51], N[(-1.0 * N[Sqrt[N[(2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 6.2e-8], N[(0.25 * N[(F * N[Sqrt[N[(-16.0 / N[(C * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(-2.0 * N[(B * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -2.35 \cdot 10^{+51}:\\
\;\;\;\;-1 \cdot \sqrt{2 \cdot \frac{F}{B}}\\
\mathbf{elif}\;B \leq 6.2 \cdot 10^{-8}:\\
\;\;\;\;0.25 \cdot \left(F \cdot \sqrt{\frac{-16}{C \cdot F}}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{-2 \cdot \left(B \cdot F\right)}}{B}\\
\end{array}
\end{array}
if B < -2.3500000000000001e51Initial program 19.4%
Taylor expanded in B around -inf
Applied rewrites14.9%
if -2.3500000000000001e51 < B < 6.2e-8Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
Taylor expanded in C around -inf
Applied rewrites11.3%
Taylor expanded in F around inf
Applied rewrites19.1%
if 6.2e-8 < B Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
Taylor expanded in B around 0
Applied rewrites14.1%
(FPCore (A B C F)
:precision binary64
(if (<= B -6.5e-57)
(* -1.0 (sqrt (* 2.0 (/ F B))))
(if (<= B 8.5e-82)
(* 0.25 (sqrt (* -16.0 (/ F C))))
(- (/ (sqrt (* -2.0 (* B F))) B)))))
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -6.5e-57) {
tmp = -1.0 * sqrt((2.0 * (F / B)));
} else if (B <= 8.5e-82) {
tmp = 0.25 * sqrt((-16.0 * (F / C)));
} else {
tmp = -(sqrt((-2.0 * (B * F))) / 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 (b <= (-6.5d-57)) then
tmp = (-1.0d0) * sqrt((2.0d0 * (f / b)))
else if (b <= 8.5d-82) then
tmp = 0.25d0 * sqrt(((-16.0d0) * (f / c)))
else
tmp = -(sqrt(((-2.0d0) * (b * f))) / b)
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -6.5e-57) {
tmp = -1.0 * Math.sqrt((2.0 * (F / B)));
} else if (B <= 8.5e-82) {
tmp = 0.25 * Math.sqrt((-16.0 * (F / C)));
} else {
tmp = -(Math.sqrt((-2.0 * (B * F))) / B);
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if B <= -6.5e-57: tmp = -1.0 * math.sqrt((2.0 * (F / B))) elif B <= 8.5e-82: tmp = 0.25 * math.sqrt((-16.0 * (F / C))) else: tmp = -(math.sqrt((-2.0 * (B * F))) / B) return tmp
function code(A, B, C, F) tmp = 0.0 if (B <= -6.5e-57) tmp = Float64(-1.0 * sqrt(Float64(2.0 * Float64(F / B)))); elseif (B <= 8.5e-82) tmp = Float64(0.25 * sqrt(Float64(-16.0 * Float64(F / C)))); else tmp = Float64(-Float64(sqrt(Float64(-2.0 * Float64(B * F))) / B)); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (B <= -6.5e-57) tmp = -1.0 * sqrt((2.0 * (F / B))); elseif (B <= 8.5e-82) tmp = 0.25 * sqrt((-16.0 * (F / C))); else tmp = -(sqrt((-2.0 * (B * F))) / B); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[B, -6.5e-57], N[(-1.0 * N[Sqrt[N[(2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 8.5e-82], N[(0.25 * N[Sqrt[N[(-16.0 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[(N[Sqrt[N[(-2.0 * N[(B * F), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / B), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -6.5 \cdot 10^{-57}:\\
\;\;\;\;-1 \cdot \sqrt{2 \cdot \frac{F}{B}}\\
\mathbf{elif}\;B \leq 8.5 \cdot 10^{-82}:\\
\;\;\;\;0.25 \cdot \sqrt{-16 \cdot \frac{F}{C}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{\sqrt{-2 \cdot \left(B \cdot F\right)}}{B}\\
\end{array}
\end{array}
if B < -6.49999999999999992e-57Initial program 19.4%
Taylor expanded in B around -inf
Applied rewrites14.9%
if -6.49999999999999992e-57 < B < 8.4999999999999997e-82Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
Taylor expanded in C around -inf
Applied rewrites11.3%
if 8.4999999999999997e-82 < B Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
Taylor expanded in B around 0
Applied rewrites14.1%
(FPCore (A B C F)
:precision binary64
(if (<= B -6.5e-57)
(* -1.0 (sqrt (* 2.0 (/ F B))))
(if (<= B 1.7e-74)
(* 0.25 (sqrt (* -16.0 (/ F C))))
(- (sqrt (/ (* -2.0 F) B))))))
double code(double A, double B, double C, double F) {
double tmp;
if (B <= -6.5e-57) {
tmp = -1.0 * sqrt((2.0 * (F / B)));
} else if (B <= 1.7e-74) {
tmp = 0.25 * sqrt((-16.0 * (F / C)));
} else {
tmp = -sqrt(((-2.0 * F) / 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 (b <= (-6.5d-57)) then
tmp = (-1.0d0) * sqrt((2.0d0 * (f / b)))
else if (b <= 1.7d-74) then
tmp = 0.25d0 * sqrt(((-16.0d0) * (f / c)))
else
tmp = -sqrt((((-2.0d0) * f) / b))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= -6.5e-57) {
tmp = -1.0 * Math.sqrt((2.0 * (F / B)));
} else if (B <= 1.7e-74) {
tmp = 0.25 * Math.sqrt((-16.0 * (F / C)));
} else {
tmp = -Math.sqrt(((-2.0 * F) / B));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if B <= -6.5e-57: tmp = -1.0 * math.sqrt((2.0 * (F / B))) elif B <= 1.7e-74: tmp = 0.25 * math.sqrt((-16.0 * (F / C))) else: tmp = -math.sqrt(((-2.0 * F) / B)) return tmp
function code(A, B, C, F) tmp = 0.0 if (B <= -6.5e-57) tmp = Float64(-1.0 * sqrt(Float64(2.0 * Float64(F / B)))); elseif (B <= 1.7e-74) tmp = Float64(0.25 * sqrt(Float64(-16.0 * Float64(F / C)))); else tmp = Float64(-sqrt(Float64(Float64(-2.0 * F) / B))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (B <= -6.5e-57) tmp = -1.0 * sqrt((2.0 * (F / B))); elseif (B <= 1.7e-74) tmp = 0.25 * sqrt((-16.0 * (F / C))); else tmp = -sqrt(((-2.0 * F) / B)); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[B, -6.5e-57], N[(-1.0 * N[Sqrt[N[(2.0 * N[(F / B), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[B, 1.7e-74], N[(0.25 * N[Sqrt[N[(-16.0 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(-2.0 * F), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq -6.5 \cdot 10^{-57}:\\
\;\;\;\;-1 \cdot \sqrt{2 \cdot \frac{F}{B}}\\
\mathbf{elif}\;B \leq 1.7 \cdot 10^{-74}:\\
\;\;\;\;0.25 \cdot \sqrt{-16 \cdot \frac{F}{C}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{-2 \cdot F}{B}}\\
\end{array}
\end{array}
if B < -6.49999999999999992e-57Initial program 19.4%
Taylor expanded in B around -inf
Applied rewrites14.9%
if -6.49999999999999992e-57 < B < 1.7e-74Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
Taylor expanded in C around -inf
Applied rewrites11.3%
if 1.7e-74 < B Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
(FPCore (A B C F) :precision binary64 (if (<= B 1.7e-74) (* 0.25 (sqrt (* -16.0 (/ F C)))) (- (sqrt (/ (* -2.0 F) B)))))
double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.7e-74) {
tmp = 0.25 * sqrt((-16.0 * (F / C)));
} else {
tmp = -sqrt(((-2.0 * F) / 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 (b <= 1.7d-74) then
tmp = 0.25d0 * sqrt(((-16.0d0) * (f / c)))
else
tmp = -sqrt((((-2.0d0) * f) / b))
end if
code = tmp
end function
public static double code(double A, double B, double C, double F) {
double tmp;
if (B <= 1.7e-74) {
tmp = 0.25 * Math.sqrt((-16.0 * (F / C)));
} else {
tmp = -Math.sqrt(((-2.0 * F) / B));
}
return tmp;
}
def code(A, B, C, F): tmp = 0 if B <= 1.7e-74: tmp = 0.25 * math.sqrt((-16.0 * (F / C))) else: tmp = -math.sqrt(((-2.0 * F) / B)) return tmp
function code(A, B, C, F) tmp = 0.0 if (B <= 1.7e-74) tmp = Float64(0.25 * sqrt(Float64(-16.0 * Float64(F / C)))); else tmp = Float64(-sqrt(Float64(Float64(-2.0 * F) / B))); end return tmp end
function tmp_2 = code(A, B, C, F) tmp = 0.0; if (B <= 1.7e-74) tmp = 0.25 * sqrt((-16.0 * (F / C))); else tmp = -sqrt(((-2.0 * F) / B)); end tmp_2 = tmp; end
code[A_, B_, C_, F_] := If[LessEqual[B, 1.7e-74], N[(0.25 * N[Sqrt[N[(-16.0 * N[(F / C), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Sqrt[N[(N[(-2.0 * F), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;B \leq 1.7 \cdot 10^{-74}:\\
\;\;\;\;0.25 \cdot \sqrt{-16 \cdot \frac{F}{C}}\\
\mathbf{else}:\\
\;\;\;\;-\sqrt{\frac{-2 \cdot F}{B}}\\
\end{array}
\end{array}
if B < 1.7e-74Initial program 19.4%
Taylor expanded in A around -inf
Applied rewrites19.5%
Taylor expanded in C around -inf
Applied rewrites11.3%
if 1.7e-74 < B Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
(FPCore (A B C F) :precision binary64 (- (sqrt (/ (* -2.0 F) B))))
double code(double A, double B, double C, double F) {
return -sqrt(((-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((((-2.0d0) * f) / b))
end function
public static double code(double A, double B, double C, double F) {
return -Math.sqrt(((-2.0 * F) / B));
}
def code(A, B, C, F): return -math.sqrt(((-2.0 * F) / B))
function code(A, B, C, F) return Float64(-sqrt(Float64(Float64(-2.0 * F) / B))) end
function tmp = code(A, B, C, F) tmp = -sqrt(((-2.0 * F) / B)); end
code[A_, B_, C_, F_] := (-N[Sqrt[N[(N[(-2.0 * F), $MachinePrecision] / B), $MachinePrecision]], $MachinePrecision])
\begin{array}{l}
\\
-\sqrt{\frac{-2 \cdot F}{B}}
\end{array}
Initial program 19.4%
Taylor expanded in B around inf
Applied rewrites13.8%
Applied rewrites13.8%
herbie shell --seed 2025160
(FPCore (A B C F)
:name "ABCF->ab-angle b"
:precision binary64
(/ (- (sqrt (* (* 2.0 (* (- (pow B 2.0) (* (* 4.0 A) C)) F)) (- (+ A C) (sqrt (+ (pow (- A C) 2.0) (pow B 2.0))))))) (- (pow B 2.0) (* (* 4.0 A) C))))