
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -8.0 c (* -4.0 c)))
(t_1 (fma (* -4.0 a) c (* b b)))
(t_2 (sqrt t_1))
(t_3 (* t_2 t_2))
(t_4 (- (fma 16.0 (* c c) (* 32.0 (* c c))) (* 0.25 (pow t_0 2.0))))
(t_5 (- (* -64.0 (pow c 3.0)) (* 0.5 (* t_0 t_4)))))
(if (<= b 0.048)
(/
(/ (fma (* b b) (- b) (pow t_1 1.5)) (fma b b (- t_3 (* (- b) t_2))))
(* 2.0 a))
(/
(/
(*
a
(fma
0.5
(* b t_0)
(*
a
(fma
0.5
(/ t_4 b)
(*
a
(fma
-0.5
(/ (* a (fma 0.25 (pow t_4 2.0) (* 0.5 (* t_0 t_5)))) (pow b 5.0))
(* 0.5 (/ t_5 (pow b 3.0)))))))))
(fma
b
b
(-
t_3
(fma
-1.0
(* b b)
(*
c
(fma
2.0
a
(*
c
(fma
2.0
(/ (* a a) (* b b))
(* 4.0 (/ (* (pow a 3.0) c) (pow b 4.0)))))))))))
(* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = fma(-8.0, c, (-4.0 * c));
double t_1 = fma((-4.0 * a), c, (b * b));
double t_2 = sqrt(t_1);
double t_3 = t_2 * t_2;
double t_4 = fma(16.0, (c * c), (32.0 * (c * c))) - (0.25 * pow(t_0, 2.0));
double t_5 = (-64.0 * pow(c, 3.0)) - (0.5 * (t_0 * t_4));
double tmp;
if (b <= 0.048) {
tmp = (fma((b * b), -b, pow(t_1, 1.5)) / fma(b, b, (t_3 - (-b * t_2)))) / (2.0 * a);
} else {
tmp = ((a * fma(0.5, (b * t_0), (a * fma(0.5, (t_4 / b), (a * fma(-0.5, ((a * fma(0.25, pow(t_4, 2.0), (0.5 * (t_0 * t_5)))) / pow(b, 5.0)), (0.5 * (t_5 / pow(b, 3.0))))))))) / fma(b, b, (t_3 - fma(-1.0, (b * b), (c * fma(2.0, a, (c * fma(2.0, ((a * a) / (b * b)), (4.0 * ((pow(a, 3.0) * c) / pow(b, 4.0))))))))))) / (2.0 * a);
}
return tmp;
}
function code(a, b, c) t_0 = fma(-8.0, c, Float64(-4.0 * c)) t_1 = fma(Float64(-4.0 * a), c, Float64(b * b)) t_2 = sqrt(t_1) t_3 = Float64(t_2 * t_2) t_4 = Float64(fma(16.0, Float64(c * c), Float64(32.0 * Float64(c * c))) - Float64(0.25 * (t_0 ^ 2.0))) t_5 = Float64(Float64(-64.0 * (c ^ 3.0)) - Float64(0.5 * Float64(t_0 * t_4))) tmp = 0.0 if (b <= 0.048) tmp = Float64(Float64(fma(Float64(b * b), Float64(-b), (t_1 ^ 1.5)) / fma(b, b, Float64(t_3 - Float64(Float64(-b) * t_2)))) / Float64(2.0 * a)); else tmp = Float64(Float64(Float64(a * fma(0.5, Float64(b * t_0), Float64(a * fma(0.5, Float64(t_4 / b), Float64(a * fma(-0.5, Float64(Float64(a * fma(0.25, (t_4 ^ 2.0), Float64(0.5 * Float64(t_0 * t_5)))) / (b ^ 5.0)), Float64(0.5 * Float64(t_5 / (b ^ 3.0))))))))) / fma(b, b, Float64(t_3 - fma(-1.0, Float64(b * b), Float64(c * fma(2.0, a, Float64(c * fma(2.0, Float64(Float64(a * a) / Float64(b * b)), Float64(4.0 * Float64(Float64((a ^ 3.0) * c) / (b ^ 4.0))))))))))) / Float64(2.0 * a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(-8.0 * c + N[(-4.0 * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(16.0 * N[(c * c), $MachinePrecision] + N[(32.0 * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.25 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(-64.0 * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(t$95$0 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.048], N[(N[(N[(N[(b * b), $MachinePrecision] * (-b) + N[Power[t$95$1, 1.5], $MachinePrecision]), $MachinePrecision] / N[(b * b + N[(t$95$3 - N[((-b) * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[(0.5 * N[(b * t$95$0), $MachinePrecision] + N[(a * N[(0.5 * N[(t$95$4 / b), $MachinePrecision] + N[(a * N[(-0.5 * N[(N[(a * N[(0.25 * N[Power[t$95$4, 2.0], $MachinePrecision] + N[(0.5 * N[(t$95$0 * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(t$95$5 / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * b + N[(t$95$3 - N[(-1.0 * N[(b * b), $MachinePrecision] + N[(c * N[(2.0 * a + N[(c * N[(2.0 * N[(N[(a * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(N[Power[a, 3.0], $MachinePrecision] * c), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-8, c, -4 \cdot c\right)\\
t_1 := \mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)\\
t_2 := \sqrt{t\_1}\\
t_3 := t\_2 \cdot t\_2\\
t_4 := \mathsf{fma}\left(16, c \cdot c, 32 \cdot \left(c \cdot c\right)\right) - 0.25 \cdot {t\_0}^{2}\\
t_5 := -64 \cdot {c}^{3} - 0.5 \cdot \left(t\_0 \cdot t\_4\right)\\
\mathbf{if}\;b \leq 0.048:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b \cdot b, -b, {t\_1}^{1.5}\right)}{\mathsf{fma}\left(b, b, t\_3 - \left(-b\right) \cdot t\_2\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a \cdot \mathsf{fma}\left(0.5, b \cdot t\_0, a \cdot \mathsf{fma}\left(0.5, \frac{t\_4}{b}, a \cdot \mathsf{fma}\left(-0.5, \frac{a \cdot \mathsf{fma}\left(0.25, {t\_4}^{2}, 0.5 \cdot \left(t\_0 \cdot t\_5\right)\right)}{{b}^{5}}, 0.5 \cdot \frac{t\_5}{{b}^{3}}\right)\right)\right)}{\mathsf{fma}\left(b, b, t\_3 - \mathsf{fma}\left(-1, b \cdot b, c \cdot \mathsf{fma}\left(2, a, c \cdot \mathsf{fma}\left(2, \frac{a \cdot a}{b \cdot b}, 4 \cdot \frac{{a}^{3} \cdot c}{{b}^{4}}\right)\right)\right)\right)}}{2 \cdot a}\\
\end{array}
\end{array}
if b < 0.048000000000000001Initial program 84.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites84.8%
lift-+.f64N/A
lift-neg.f64N/A
lift-pow.f64N/A
unpow3N/A
sqr-neg-revN/A
pow2N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lift-neg.f64N/A
sqrt-pow2N/A
lower-pow.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval86.2
Applied rewrites86.2%
if 0.048000000000000001 < b Initial program 52.3%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites52.3%
Taylor expanded in b around inf
Applied rewrites92.8%
Taylor expanded in c around 0
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites93.0%
Taylor expanded in a around 0
Applied rewrites93.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -8.0 c (* -4.0 c)))
(t_1 (fma (* -4.0 a) c (* b b)))
(t_2 (sqrt t_1))
(t_3 (fma b b (- (* t_2 t_2) (* (- b) t_2))))
(t_4 (- (fma 16.0 (* c c) (* 32.0 (* c c))) (* 0.25 (pow t_0 2.0))))
(t_5 (- (* -64.0 (pow c 3.0)) (* 0.5 (* t_0 t_4)))))
(if (<= b 0.048)
(/ (/ (fma (* b b) (- b) (pow t_1 1.5)) t_3) (* 2.0 a))
(/
(/
(*
a
(fma
0.5
(* b t_0)
(*
a
(fma
0.5
(/ t_4 b)
(*
a
(fma
-0.5
(/ (* a (fma 0.25 (pow t_4 2.0) (* 0.5 (* t_0 t_5)))) (pow b 5.0))
(* 0.5 (/ t_5 (pow b 3.0)))))))))
t_3)
(* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = fma(-8.0, c, (-4.0 * c));
double t_1 = fma((-4.0 * a), c, (b * b));
double t_2 = sqrt(t_1);
double t_3 = fma(b, b, ((t_2 * t_2) - (-b * t_2)));
double t_4 = fma(16.0, (c * c), (32.0 * (c * c))) - (0.25 * pow(t_0, 2.0));
double t_5 = (-64.0 * pow(c, 3.0)) - (0.5 * (t_0 * t_4));
double tmp;
if (b <= 0.048) {
tmp = (fma((b * b), -b, pow(t_1, 1.5)) / t_3) / (2.0 * a);
} else {
tmp = ((a * fma(0.5, (b * t_0), (a * fma(0.5, (t_4 / b), (a * fma(-0.5, ((a * fma(0.25, pow(t_4, 2.0), (0.5 * (t_0 * t_5)))) / pow(b, 5.0)), (0.5 * (t_5 / pow(b, 3.0))))))))) / t_3) / (2.0 * a);
}
return tmp;
}
function code(a, b, c) t_0 = fma(-8.0, c, Float64(-4.0 * c)) t_1 = fma(Float64(-4.0 * a), c, Float64(b * b)) t_2 = sqrt(t_1) t_3 = fma(b, b, Float64(Float64(t_2 * t_2) - Float64(Float64(-b) * t_2))) t_4 = Float64(fma(16.0, Float64(c * c), Float64(32.0 * Float64(c * c))) - Float64(0.25 * (t_0 ^ 2.0))) t_5 = Float64(Float64(-64.0 * (c ^ 3.0)) - Float64(0.5 * Float64(t_0 * t_4))) tmp = 0.0 if (b <= 0.048) tmp = Float64(Float64(fma(Float64(b * b), Float64(-b), (t_1 ^ 1.5)) / t_3) / Float64(2.0 * a)); else tmp = Float64(Float64(Float64(a * fma(0.5, Float64(b * t_0), Float64(a * fma(0.5, Float64(t_4 / b), Float64(a * fma(-0.5, Float64(Float64(a * fma(0.25, (t_4 ^ 2.0), Float64(0.5 * Float64(t_0 * t_5)))) / (b ^ 5.0)), Float64(0.5 * Float64(t_5 / (b ^ 3.0))))))))) / t_3) / Float64(2.0 * a)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(-8.0 * c + N[(-4.0 * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[t$95$1], $MachinePrecision]}, Block[{t$95$3 = N[(b * b + N[(N[(t$95$2 * t$95$2), $MachinePrecision] - N[((-b) * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(16.0 * N[(c * c), $MachinePrecision] + N[(32.0 * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.25 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(-64.0 * N[Power[c, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(t$95$0 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 0.048], N[(N[(N[(N[(b * b), $MachinePrecision] * (-b) + N[Power[t$95$1, 1.5], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a * N[(0.5 * N[(b * t$95$0), $MachinePrecision] + N[(a * N[(0.5 * N[(t$95$4 / b), $MachinePrecision] + N[(a * N[(-0.5 * N[(N[(a * N[(0.25 * N[Power[t$95$4, 2.0], $MachinePrecision] + N[(0.5 * N[(t$95$0 * t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(t$95$5 / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-8, c, -4 \cdot c\right)\\
t_1 := \mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)\\
t_2 := \sqrt{t\_1}\\
t_3 := \mathsf{fma}\left(b, b, t\_2 \cdot t\_2 - \left(-b\right) \cdot t\_2\right)\\
t_4 := \mathsf{fma}\left(16, c \cdot c, 32 \cdot \left(c \cdot c\right)\right) - 0.25 \cdot {t\_0}^{2}\\
t_5 := -64 \cdot {c}^{3} - 0.5 \cdot \left(t\_0 \cdot t\_4\right)\\
\mathbf{if}\;b \leq 0.048:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b \cdot b, -b, {t\_1}^{1.5}\right)}{t\_3}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a \cdot \mathsf{fma}\left(0.5, b \cdot t\_0, a \cdot \mathsf{fma}\left(0.5, \frac{t\_4}{b}, a \cdot \mathsf{fma}\left(-0.5, \frac{a \cdot \mathsf{fma}\left(0.25, {t\_4}^{2}, 0.5 \cdot \left(t\_0 \cdot t\_5\right)\right)}{{b}^{5}}, 0.5 \cdot \frac{t\_5}{{b}^{3}}\right)\right)\right)}{t\_3}}{2 \cdot a}\\
\end{array}
\end{array}
if b < 0.048000000000000001Initial program 84.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites84.8%
lift-+.f64N/A
lift-neg.f64N/A
lift-pow.f64N/A
unpow3N/A
sqr-neg-revN/A
pow2N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lift-neg.f64N/A
sqrt-pow2N/A
lower-pow.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval86.2
Applied rewrites86.2%
if 0.048000000000000001 < b Initial program 52.3%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites52.3%
Taylor expanded in b around inf
Applied rewrites92.8%
Taylor expanded in a around 0
Applied rewrites92.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -4.0 a) c (* b b))) (t_1 (sqrt t_0)))
(if (<= b 0.048)
(/
(/
(fma (* b b) (- b) (pow t_0 1.5))
(fma b b (- (* t_1 t_1) (* (- b) t_1))))
(* 2.0 a))
(fma
(*
(* c c)
(-
(*
c
(fma -5.0 (/ (* (* a a) c) (pow b 7.0)) (* -2.0 (/ a (pow b 5.0)))))
(pow b -3.0)))
a
(/ (- c) b)))))
double code(double a, double b, double c) {
double t_0 = fma((-4.0 * a), c, (b * b));
double t_1 = sqrt(t_0);
double tmp;
if (b <= 0.048) {
tmp = (fma((b * b), -b, pow(t_0, 1.5)) / fma(b, b, ((t_1 * t_1) - (-b * t_1)))) / (2.0 * a);
} else {
tmp = fma(((c * c) * ((c * fma(-5.0, (((a * a) * c) / pow(b, 7.0)), (-2.0 * (a / pow(b, 5.0))))) - pow(b, -3.0))), a, (-c / b));
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-4.0 * a), c, Float64(b * b)) t_1 = sqrt(t_0) tmp = 0.0 if (b <= 0.048) tmp = Float64(Float64(fma(Float64(b * b), Float64(-b), (t_0 ^ 1.5)) / fma(b, b, Float64(Float64(t_1 * t_1) - Float64(Float64(-b) * t_1)))) / Float64(2.0 * a)); else tmp = fma(Float64(Float64(c * c) * Float64(Float64(c * fma(-5.0, Float64(Float64(Float64(a * a) * c) / (b ^ 7.0)), Float64(-2.0 * Float64(a / (b ^ 5.0))))) - (b ^ -3.0))), a, Float64(Float64(-c) / b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[b, 0.048], N[(N[(N[(N[(b * b), $MachinePrecision] * (-b) + N[Power[t$95$0, 1.5], $MachinePrecision]), $MachinePrecision] / N[(b * b + N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[((-b) * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * c), $MachinePrecision] * N[(N[(c * N[(-5.0 * N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(a / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[b, -3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + N[((-c) / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;b \leq 0.048:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b \cdot b, -b, {t\_0}^{1.5}\right)}{\mathsf{fma}\left(b, b, t\_1 \cdot t\_1 - \left(-b\right) \cdot t\_1\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(c \cdot c\right) \cdot \left(c \cdot \mathsf{fma}\left(-5, \frac{\left(a \cdot a\right) \cdot c}{{b}^{7}}, -2 \cdot \frac{a}{{b}^{5}}\right) - {b}^{-3}\right), a, \frac{-c}{b}\right)\\
\end{array}
\end{array}
if b < 0.048000000000000001Initial program 84.9%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites84.8%
lift-+.f64N/A
lift-neg.f64N/A
lift-pow.f64N/A
unpow3N/A
sqr-neg-revN/A
pow2N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lift-neg.f64N/A
sqrt-pow2N/A
lower-pow.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval86.2
Applied rewrites86.2%
if 0.048000000000000001 < b Initial program 52.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites92.6%
Taylor expanded in c around 0
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
Applied rewrites92.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* -4.0 a) c (* b b))) (t_1 (sqrt t_0)))
(if (<= b 0.25)
(/
(/
(fma (* b b) (- b) (pow t_0 1.5))
(fma b b (- (* t_1 t_1) (* (- b) t_1))))
(* 2.0 a))
(*
-1.0
(/
(+ c (* (* c c) (fma 2.0 (/ (* (* a a) c) (pow b 4.0)) (/ a (* b b)))))
b)))))
double code(double a, double b, double c) {
double t_0 = fma((-4.0 * a), c, (b * b));
double t_1 = sqrt(t_0);
double tmp;
if (b <= 0.25) {
tmp = (fma((b * b), -b, pow(t_0, 1.5)) / fma(b, b, ((t_1 * t_1) - (-b * t_1)))) / (2.0 * a);
} else {
tmp = -1.0 * ((c + ((c * c) * fma(2.0, (((a * a) * c) / pow(b, 4.0)), (a / (b * b))))) / b);
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(-4.0 * a), c, Float64(b * b)) t_1 = sqrt(t_0) tmp = 0.0 if (b <= 0.25) tmp = Float64(Float64(fma(Float64(b * b), Float64(-b), (t_0 ^ 1.5)) / fma(b, b, Float64(Float64(t_1 * t_1) - Float64(Float64(-b) * t_1)))) / Float64(2.0 * a)); else tmp = Float64(-1.0 * Float64(Float64(c + Float64(Float64(c * c) * fma(2.0, Float64(Float64(Float64(a * a) * c) / (b ^ 4.0)), Float64(a / Float64(b * b))))) / b)); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[b, 0.25], N[(N[(N[(N[(b * b), $MachinePrecision] * (-b) + N[Power[t$95$0, 1.5], $MachinePrecision]), $MachinePrecision] / N[(b * b + N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[((-b) * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(c + N[(N[(c * c), $MachinePrecision] * N[(2.0 * N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;b \leq 0.25:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b \cdot b, -b, {t\_0}^{1.5}\right)}{\mathsf{fma}\left(b, b, t\_1 \cdot t\_1 - \left(-b\right) \cdot t\_1\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c + \left(c \cdot c\right) \cdot \mathsf{fma}\left(2, \frac{\left(a \cdot a\right) \cdot c}{{b}^{4}}, \frac{a}{b \cdot b}\right)}{b}\\
\end{array}
\end{array}
if b < 0.25Initial program 83.1%
lift-neg.f64N/A
lift-+.f64N/A
lift-sqrt.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites83.1%
lift-+.f64N/A
lift-neg.f64N/A
lift-pow.f64N/A
unpow3N/A
sqr-neg-revN/A
pow2N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lift-neg.f64N/A
sqrt-pow2N/A
lower-pow.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
metadata-eval84.5
Applied rewrites84.5%
if 0.25 < b Initial program 51.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites93.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in c around 0
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.4
Applied rewrites90.4%
(FPCore (a b c)
:precision binary64
(if (<= b 0.25)
(/ (+ (- b) (sqrt (fma b b (* -4.0 (* c a))))) (* 2.0 a))
(*
-1.0
(/
(+ c (* (* c c) (fma 2.0 (/ (* (* a a) c) (pow b 4.0)) (/ a (* b b)))))
b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.25) {
tmp = (-b + sqrt(fma(b, b, (-4.0 * (c * a))))) / (2.0 * a);
} else {
tmp = -1.0 * ((c + ((c * c) * fma(2.0, (((a * a) * c) / pow(b, 4.0)), (a / (b * b))))) / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.25) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(-4.0 * Float64(c * a))))) / Float64(2.0 * a)); else tmp = Float64(-1.0 * Float64(Float64(c + Float64(Float64(c * c) * fma(2.0, Float64(Float64(Float64(a * a) * c) / (b ^ 4.0)), Float64(a / Float64(b * b))))) / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.25], N[(N[((-b) + N[Sqrt[N[(b * b + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(c + N[(N[(c * c), $MachinePrecision] * N[(2.0 * N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.25:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -4 \cdot \left(c \cdot a\right)\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c + \left(c \cdot c\right) \cdot \mathsf{fma}\left(2, \frac{\left(a \cdot a\right) \cdot c}{{b}^{4}}, \frac{a}{b \cdot b}\right)}{b}\\
\end{array}
\end{array}
if b < 0.25Initial program 83.1%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
if 0.25 < b Initial program 51.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites93.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in c around 0
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.4
Applied rewrites90.4%
(FPCore (a b c)
:precision binary64
(if (<= b 0.25)
(/ (+ (- b) (sqrt (fma b b (* -4.0 (* c a))))) (* 2.0 a))
(*
-1.0
(/
(* c (+ 1.0 (* c (fma 2.0 (/ (* (* a a) c) (pow b 4.0)) (/ a (* b b))))))
b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.25) {
tmp = (-b + sqrt(fma(b, b, (-4.0 * (c * a))))) / (2.0 * a);
} else {
tmp = -1.0 * ((c * (1.0 + (c * fma(2.0, (((a * a) * c) / pow(b, 4.0)), (a / (b * b)))))) / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.25) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(-4.0 * Float64(c * a))))) / Float64(2.0 * a)); else tmp = Float64(-1.0 * Float64(Float64(c * Float64(1.0 + Float64(c * fma(2.0, Float64(Float64(Float64(a * a) * c) / (b ^ 4.0)), Float64(a / Float64(b * b)))))) / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.25], N[(N[((-b) + N[Sqrt[N[(b * b + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(N[(c * N[(1.0 + N[(c * N[(2.0 * N[(N[(N[(a * a), $MachinePrecision] * c), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(a / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.25:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -4 \cdot \left(c \cdot a\right)\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{c \cdot \left(1 + c \cdot \mathsf{fma}\left(2, \frac{\left(a \cdot a\right) \cdot c}{{b}^{4}}, \frac{a}{b \cdot b}\right)\right)}{b}\\
\end{array}
\end{array}
if b < 0.25Initial program 83.1%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6483.3
Applied rewrites83.3%
if 0.25 < b Initial program 51.4%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites93.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites90.4%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.2
Applied rewrites90.2%
(FPCore (a b c) :precision binary64 (if (<= b 0.44) (/ (+ (- b) (sqrt (fma b b (* -4.0 (* c a))))) (* 2.0 a)) (/ (fma (/ (* (* c c) a) (* b b)) -1.0 (- c)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.44) {
tmp = (-b + sqrt(fma(b, b, (-4.0 * (c * a))))) / (2.0 * a);
} else {
tmp = fma((((c * c) * a) / (b * b)), -1.0, -c) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 0.44) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(-4.0 * Float64(c * a))))) / Float64(2.0 * a)); else tmp = Float64(fma(Float64(Float64(Float64(c * c) * a) / Float64(b * b)), -1.0, Float64(-c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 0.44], N[(N[((-b) + N[Sqrt[N[(b * b + N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * -1.0 + (-c)), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.44:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, -4 \cdot \left(c \cdot a\right)\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -1, -c\right)}{b}\\
\end{array}
\end{array}
if b < 0.440000000000000002Initial program 82.4%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6482.6
Applied rewrites82.6%
if 0.440000000000000002 < b Initial program 50.9%
Taylor expanded in b around inf
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-neg.f6485.2
Applied rewrites85.2%
(FPCore (a b c) :precision binary64 (/ (fma (/ (* (* c c) a) (* b b)) -1.0 (- c)) b))
double code(double a, double b, double c) {
return fma((((c * c) * a) / (b * b)), -1.0, -c) / b;
}
function code(a, b, c) return Float64(fma(Float64(Float64(Float64(c * c) * a) / Float64(b * b)), -1.0, Float64(-c)) / b) end
code[a_, b_, c_] := N[(N[(N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] * -1.0 + (-c)), $MachinePrecision] / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -1, -c\right)}{b}
\end{array}
Initial program 55.3%
Taylor expanded in b around inf
lower-/.f64N/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-neg.f6481.6
Applied rewrites81.6%
(FPCore (a b c) :precision binary64 (* -1.0 (/ (* c (+ 1.0 (/ (* a c) (* b b)))) b)))
double code(double a, double b, double c) {
return -1.0 * ((c * (1.0 + ((a * c) / (b * b)))) / 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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-1.0d0) * ((c * (1.0d0 + ((a * c) / (b * b)))) / b)
end function
public static double code(double a, double b, double c) {
return -1.0 * ((c * (1.0 + ((a * c) / (b * b)))) / b);
}
def code(a, b, c): return -1.0 * ((c * (1.0 + ((a * c) / (b * b)))) / b)
function code(a, b, c) return Float64(-1.0 * Float64(Float64(c * Float64(1.0 + Float64(Float64(a * c) / Float64(b * b)))) / b)) end
function tmp = code(a, b, c) tmp = -1.0 * ((c * (1.0 + ((a * c) / (b * b)))) / b); end
code[a_, b_, c_] := N[(-1.0 * N[(N[(c * N[(1.0 + N[(N[(a * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot \frac{c \cdot \left(1 + \frac{a \cdot c}{b \cdot b}\right)}{b}
\end{array}
Initial program 55.3%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites91.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites87.8%
Taylor expanded in c around 0
lower-*.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f6481.5
Applied rewrites81.5%
(FPCore (a b c) :precision binary64 (/ (- c) b))
double code(double a, double b, double c) {
return -c / 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)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -c / b
end function
public static double code(double a, double b, double c) {
return -c / b;
}
def code(a, b, c): return -c / b
function code(a, b, c) return Float64(Float64(-c) / b) end
function tmp = code(a, b, c) tmp = -c / b; end
code[a_, b_, c_] := N[((-c) / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{-c}{b}
\end{array}
Initial program 55.3%
Taylor expanded in a around 0
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6464.5
Applied rewrites64.5%
herbie shell --seed 2025108
(FPCore (a b c)
:name "Quadratic roots, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))