
(FPCore (p r q) :precision binary64 :pre TRUE (* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))
double code(double p, double r, double q) {
return (1.0 / 2.0) * ((fabs(p) + fabs(r)) - sqrt((pow((p - r), 2.0) + (4.0 * pow(q, 2.0)))));
}
real(8) function code(p, r, q)
use fmin_fmax_functions
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
code = (1.0d0 / 2.0d0) * ((abs(p) + abs(r)) - sqrt((((p - r) ** 2.0d0) + (4.0d0 * (q ** 2.0d0)))))
end function
public static double code(double p, double r, double q) {
return (1.0 / 2.0) * ((Math.abs(p) + Math.abs(r)) - Math.sqrt((Math.pow((p - r), 2.0) + (4.0 * Math.pow(q, 2.0)))));
}
def code(p, r, q): return (1.0 / 2.0) * ((math.fabs(p) + math.fabs(r)) - math.sqrt((math.pow((p - r), 2.0) + (4.0 * math.pow(q, 2.0)))))
function code(p, r, q) return Float64(Float64(1.0 / 2.0) * Float64(Float64(abs(p) + abs(r)) - sqrt(Float64((Float64(p - r) ^ 2.0) + Float64(4.0 * (q ^ 2.0)))))) end
function tmp = code(p, r, q) tmp = (1.0 / 2.0) * ((abs(p) + abs(r)) - sqrt((((p - r) ^ 2.0) + (4.0 * (q ^ 2.0))))); end
code[p_, r_, q_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(N[Abs[p], $MachinePrecision] + N[Abs[r], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(p - r), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[Power[q, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = ((1) / (2)) * (((abs(p)) + (abs(r))) - (sqrt((((p - r) ^ (2)) + ((4) * (q ^ (2))))))) END code
\frac{1}{2} \cdot \left(\left(\left|p\right| + \left|r\right|\right) - \sqrt{{\left(p - r\right)}^{2} + 4 \cdot {q}^{2}}\right)
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (p r q) :precision binary64 :pre TRUE (* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))
double code(double p, double r, double q) {
return (1.0 / 2.0) * ((fabs(p) + fabs(r)) - sqrt((pow((p - r), 2.0) + (4.0 * pow(q, 2.0)))));
}
real(8) function code(p, r, q)
use fmin_fmax_functions
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
code = (1.0d0 / 2.0d0) * ((abs(p) + abs(r)) - sqrt((((p - r) ** 2.0d0) + (4.0d0 * (q ** 2.0d0)))))
end function
public static double code(double p, double r, double q) {
return (1.0 / 2.0) * ((Math.abs(p) + Math.abs(r)) - Math.sqrt((Math.pow((p - r), 2.0) + (4.0 * Math.pow(q, 2.0)))));
}
def code(p, r, q): return (1.0 / 2.0) * ((math.fabs(p) + math.fabs(r)) - math.sqrt((math.pow((p - r), 2.0) + (4.0 * math.pow(q, 2.0)))))
function code(p, r, q) return Float64(Float64(1.0 / 2.0) * Float64(Float64(abs(p) + abs(r)) - sqrt(Float64((Float64(p - r) ^ 2.0) + Float64(4.0 * (q ^ 2.0)))))) end
function tmp = code(p, r, q) tmp = (1.0 / 2.0) * ((abs(p) + abs(r)) - sqrt((((p - r) ^ 2.0) + (4.0 * (q ^ 2.0))))); end
code[p_, r_, q_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(N[Abs[p], $MachinePrecision] + N[Abs[r], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(p - r), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[Power[q, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = ((1) / (2)) * (((abs(p)) + (abs(r))) - (sqrt((((p - r) ^ (2)) + ((4) * (q ^ (2))))))) END code
\frac{1}{2} \cdot \left(\left(\left|p\right| + \left|r\right|\right) - \sqrt{{\left(p - r\right)}^{2} + 4 \cdot {q}^{2}}\right)
(FPCore (p r q) :precision binary64 :pre TRUE (if (<= (pow (fabs q) 2.0) 5e+262) (fma -1.0 (* (fabs q) (/ (fabs q) (fabs (- p r)))) (* 0.5 (+ (- (fabs p) 0.0) (* p (copysign 1.0 r))))) (- (fabs q))))
double code(double p, double r, double q) {
double tmp;
if (pow(fabs(q), 2.0) <= 5e+262) {
tmp = fma(-1.0, (fabs(q) * (fabs(q) / fabs((p - r)))), (0.5 * ((fabs(p) - 0.0) + (p * copysign(1.0, r)))));
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) tmp = 0.0 if ((abs(q) ^ 2.0) <= 5e+262) tmp = fma(-1.0, Float64(abs(q) * Float64(abs(q) / abs(Float64(p - r)))), Float64(0.5 * Float64(Float64(abs(p) - 0.0) + Float64(p * copysign(1.0, r))))); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := If[LessEqual[N[Power[N[Abs[q], $MachinePrecision], 2.0], $MachinePrecision], 5e+262], N[(-1.0 * N[(N[Abs[q], $MachinePrecision] * N[(N[Abs[q], $MachinePrecision] / N[Abs[N[(p - r), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(N[Abs[p], $MachinePrecision] - 0.0), $MachinePrecision] + N[(p * N[With[{TMP1 = Abs[1.0], TMP2 = Sign[r]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]
\begin{array}{l}
\mathbf{if}\;{\left(\left|q\right|\right)}^{2} \leq 5 \cdot 10^{+262}:\\
\;\;\;\;\mathsf{fma}\left(-1, \left|q\right| \cdot \frac{\left|q\right|}{\left|p - r\right|}, 0.5 \cdot \left(\left(\left|p\right| - 0\right) + p \cdot \mathsf{copysign}\left(1, r\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if (pow.f64 q #s(literal 2 binary64)) < 5.0000000000000001e262Initial program 23.8%
Taylor expanded in q around 0
Applied rewrites18.9%
Applied rewrites20.2%
Taylor expanded in p around 0
Applied rewrites13.5%
Applied rewrites53.3%
if 5.0000000000000001e262 < (pow.f64 q #s(literal 2 binary64)) Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q)
:precision binary64
:pre TRUE
(let* ((t_0 (fabs (fmax p r)))
(t_1 (fabs (fmin p r)))
(t_2 (fabs (- (fmin p r) (fmax p r)))))
(if (<= (fabs q) 5.36940421531915e-191)
(fma 0.5 t_1 (* 0.5 (fmin p r)))
(if (<= (fabs q) 8.09018202335526e-100)
(fma 0.5 t_0 (* -0.5 (fmax p r)))
(if (<= (fabs q) 3.4921617425343053e+131)
(- (* 0.5 (- (+ t_1 t_0) t_2)) (/ (* (fabs q) (fabs q)) t_2))
(- (fabs q)))))))double code(double p, double r, double q) {
double t_0 = fabs(fmax(p, r));
double t_1 = fabs(fmin(p, r));
double t_2 = fabs((fmin(p, r) - fmax(p, r)));
double tmp;
if (fabs(q) <= 5.36940421531915e-191) {
tmp = fma(0.5, t_1, (0.5 * fmin(p, r)));
} else if (fabs(q) <= 8.09018202335526e-100) {
tmp = fma(0.5, t_0, (-0.5 * fmax(p, r)));
} else if (fabs(q) <= 3.4921617425343053e+131) {
tmp = (0.5 * ((t_1 + t_0) - t_2)) - ((fabs(q) * fabs(q)) / t_2);
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) t_0 = abs(fmax(p, r)) t_1 = abs(fmin(p, r)) t_2 = abs(Float64(fmin(p, r) - fmax(p, r))) tmp = 0.0 if (abs(q) <= 5.36940421531915e-191) tmp = fma(0.5, t_1, Float64(0.5 * fmin(p, r))); elseif (abs(q) <= 8.09018202335526e-100) tmp = fma(0.5, t_0, Float64(-0.5 * fmax(p, r))); elseif (abs(q) <= 3.4921617425343053e+131) tmp = Float64(Float64(0.5 * Float64(Float64(t_1 + t_0) - t_2)) - Float64(Float64(abs(q) * abs(q)) / t_2)); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := Block[{t$95$0 = N[Abs[N[Max[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Min[p, r], $MachinePrecision] - N[Max[p, r], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[q], $MachinePrecision], 5.36940421531915e-191], N[(0.5 * t$95$1 + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 8.09018202335526e-100], N[(0.5 * t$95$0 + N[(-0.5 * N[Max[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 3.4921617425343053e+131], N[(N[(0.5 * N[(N[(t$95$1 + t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Abs[q], $MachinePrecision] * N[Abs[q], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]]]]]]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp = IF (p > r) THEN p ELSE r ENDIF IN LET t_0 = (abs(tmp)) IN LET tmp_1 = IF (p < r) THEN p ELSE r ENDIF IN LET t_1 = (abs(tmp_1)) IN LET tmp_2 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_3 = IF (p > r) THEN p ELSE r ENDIF IN LET t_2 = (abs((tmp_2 - tmp_3))) IN LET tmp_6 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_9 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_10 = IF ((abs(q)) <= (349216174253430531175005111321427954808209121420992526320759574349841032853605563124659701398649630875310478202201383466257711366144)) THEN (((5e-1) * ((t_1 + t_0) - t_2)) - (((abs(q)) * (abs(q))) / t_2)) ELSE (- (abs(q))) ENDIF IN LET tmp_8 = IF ((abs(q)) <= (8090182023355259495940432708722595855324228324423732375349457772194918817392176809386013820831290792736518267407924416786636103969651310468535044643700420264637301175379536151120602045571181872859051769063885261480412051151667549429526547929113211576890307696885429322719573974609375e-382)) THEN (((5e-1) * t_0) + ((-5e-1) * tmp_9)) ELSE tmp_10 ENDIF IN LET tmp_5 = IF ((abs(q)) <= (536940421531915006867631165022153464668122279414846984205212983959402568711900151385020404652487562807560417041190503025225567003625150801299618147861978055801560858308852788217657838524052986817851819441663309328634001481341509781502327953917316449762552696873625795635596673702380800635157350197697633736071140834292251302633376685403513437760664780715118204144730705501269672666046720609480782559520655476420778444136379362359212495058440554555128049023238201442609351943247020244598388671875e-685)) THEN (((5e-1) * t_1) + ((5e-1) * tmp_6)) ELSE tmp_8 ENDIF IN tmp_5 END code
\begin{array}{l}
t_0 := \left|\mathsf{max}\left(p, r\right)\right|\\
t_1 := \left|\mathsf{min}\left(p, r\right)\right|\\
t_2 := \left|\mathsf{min}\left(p, r\right) - \mathsf{max}\left(p, r\right)\right|\\
\mathbf{if}\;\left|q\right| \leq 5.36940421531915 \cdot 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_1, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 8.09018202335526 \cdot 10^{-100}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, -0.5 \cdot \mathsf{max}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 3.4921617425343053 \cdot 10^{+131}:\\
\;\;\;\;0.5 \cdot \left(\left(t\_1 + t\_0\right) - t\_2\right) - \frac{\left|q\right| \cdot \left|q\right|}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if q < 5.3694042153191501e-191Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.3694042153191501e-191 < q < 8.0901820233552595e-100Initial program 23.8%
Applied rewrites21.0%
Taylor expanded in r around inf
Applied rewrites17.3%
if 8.0901820233552595e-100 < q < 3.4921617425343053e131Initial program 23.8%
Taylor expanded in q around 0
Applied rewrites18.9%
Applied rewrites40.4%
if 3.4921617425343053e131 < q Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q)
:precision binary64
:pre TRUE
(let* ((t_0 (fabs (fmax p r)))
(t_1 (fabs (fmin p r)))
(t_2 (fabs (- (fmin p r) (fmax p r)))))
(if (<= (fabs q) 5.36940421531915e-191)
(fma 0.5 t_1 (* 0.5 (fmin p r)))
(if (<= (fabs q) 8.09018202335526e-100)
(fma 0.5 t_0 (* -0.5 (fmax p r)))
(if (<= (fabs q) 3.4921617425343053e+131)
(- (* 0.5 (- (+ t_1 t_0) t_2)) (* (fabs q) (/ (fabs q) t_2)))
(- (fabs q)))))))double code(double p, double r, double q) {
double t_0 = fabs(fmax(p, r));
double t_1 = fabs(fmin(p, r));
double t_2 = fabs((fmin(p, r) - fmax(p, r)));
double tmp;
if (fabs(q) <= 5.36940421531915e-191) {
tmp = fma(0.5, t_1, (0.5 * fmin(p, r)));
} else if (fabs(q) <= 8.09018202335526e-100) {
tmp = fma(0.5, t_0, (-0.5 * fmax(p, r)));
} else if (fabs(q) <= 3.4921617425343053e+131) {
tmp = (0.5 * ((t_1 + t_0) - t_2)) - (fabs(q) * (fabs(q) / t_2));
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) t_0 = abs(fmax(p, r)) t_1 = abs(fmin(p, r)) t_2 = abs(Float64(fmin(p, r) - fmax(p, r))) tmp = 0.0 if (abs(q) <= 5.36940421531915e-191) tmp = fma(0.5, t_1, Float64(0.5 * fmin(p, r))); elseif (abs(q) <= 8.09018202335526e-100) tmp = fma(0.5, t_0, Float64(-0.5 * fmax(p, r))); elseif (abs(q) <= 3.4921617425343053e+131) tmp = Float64(Float64(0.5 * Float64(Float64(t_1 + t_0) - t_2)) - Float64(abs(q) * Float64(abs(q) / t_2))); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := Block[{t$95$0 = N[Abs[N[Max[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Min[p, r], $MachinePrecision] - N[Max[p, r], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[q], $MachinePrecision], 5.36940421531915e-191], N[(0.5 * t$95$1 + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 8.09018202335526e-100], N[(0.5 * t$95$0 + N[(-0.5 * N[Max[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 3.4921617425343053e+131], N[(N[(0.5 * N[(N[(t$95$1 + t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[Abs[q], $MachinePrecision] * N[(N[Abs[q], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]]]]]]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp = IF (p > r) THEN p ELSE r ENDIF IN LET t_0 = (abs(tmp)) IN LET tmp_1 = IF (p < r) THEN p ELSE r ENDIF IN LET t_1 = (abs(tmp_1)) IN LET tmp_2 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_3 = IF (p > r) THEN p ELSE r ENDIF IN LET t_2 = (abs((tmp_2 - tmp_3))) IN LET tmp_6 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_9 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_10 = IF ((abs(q)) <= (349216174253430531175005111321427954808209121420992526320759574349841032853605563124659701398649630875310478202201383466257711366144)) THEN (((5e-1) * ((t_1 + t_0) - t_2)) - ((abs(q)) * ((abs(q)) / t_2))) ELSE (- (abs(q))) ENDIF IN LET tmp_8 = IF ((abs(q)) <= (8090182023355259495940432708722595855324228324423732375349457772194918817392176809386013820831290792736518267407924416786636103969651310468535044643700420264637301175379536151120602045571181872859051769063885261480412051151667549429526547929113211576890307696885429322719573974609375e-382)) THEN (((5e-1) * t_0) + ((-5e-1) * tmp_9)) ELSE tmp_10 ENDIF IN LET tmp_5 = IF ((abs(q)) <= (536940421531915006867631165022153464668122279414846984205212983959402568711900151385020404652487562807560417041190503025225567003625150801299618147861978055801560858308852788217657838524052986817851819441663309328634001481341509781502327953917316449762552696873625795635596673702380800635157350197697633736071140834292251302633376685403513437760664780715118204144730705501269672666046720609480782559520655476420778444136379362359212495058440554555128049023238201442609351943247020244598388671875e-685)) THEN (((5e-1) * t_1) + ((5e-1) * tmp_6)) ELSE tmp_8 ENDIF IN tmp_5 END code
\begin{array}{l}
t_0 := \left|\mathsf{max}\left(p, r\right)\right|\\
t_1 := \left|\mathsf{min}\left(p, r\right)\right|\\
t_2 := \left|\mathsf{min}\left(p, r\right) - \mathsf{max}\left(p, r\right)\right|\\
\mathbf{if}\;\left|q\right| \leq 5.36940421531915 \cdot 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_1, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 8.09018202335526 \cdot 10^{-100}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, -0.5 \cdot \mathsf{max}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 3.4921617425343053 \cdot 10^{+131}:\\
\;\;\;\;0.5 \cdot \left(\left(t\_1 + t\_0\right) - t\_2\right) - \left|q\right| \cdot \frac{\left|q\right|}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if q < 5.3694042153191501e-191Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.3694042153191501e-191 < q < 8.0901820233552595e-100Initial program 23.8%
Applied rewrites21.0%
Taylor expanded in r around inf
Applied rewrites17.3%
if 8.0901820233552595e-100 < q < 3.4921617425343053e131Initial program 23.8%
Taylor expanded in q around 0
Applied rewrites18.9%
Applied rewrites40.4%
Applied rewrites45.9%
if 3.4921617425343053e131 < q Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q)
:precision binary64
:pre TRUE
(let* ((t_0 (fabs (fmax p r)))
(t_1 (fabs (fmin p r)))
(t_2 (fabs (- (fmin p r) (fmax p r)))))
(if (<= (fabs q) 5.36940421531915e-191)
(fma 0.5 t_1 (* 0.5 (fmin p r)))
(if (<= (fabs q) 8.09018202335526e-100)
(fma 0.5 t_0 (* -0.5 (fmax p r)))
(if (<= (fabs q) 3.4921617425343053e+131)
(- (* 0.5 (+ t_1 (- t_0 t_2))) (/ (* (fabs q) (fabs q)) t_2))
(- (fabs q)))))))double code(double p, double r, double q) {
double t_0 = fabs(fmax(p, r));
double t_1 = fabs(fmin(p, r));
double t_2 = fabs((fmin(p, r) - fmax(p, r)));
double tmp;
if (fabs(q) <= 5.36940421531915e-191) {
tmp = fma(0.5, t_1, (0.5 * fmin(p, r)));
} else if (fabs(q) <= 8.09018202335526e-100) {
tmp = fma(0.5, t_0, (-0.5 * fmax(p, r)));
} else if (fabs(q) <= 3.4921617425343053e+131) {
tmp = (0.5 * (t_1 + (t_0 - t_2))) - ((fabs(q) * fabs(q)) / t_2);
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) t_0 = abs(fmax(p, r)) t_1 = abs(fmin(p, r)) t_2 = abs(Float64(fmin(p, r) - fmax(p, r))) tmp = 0.0 if (abs(q) <= 5.36940421531915e-191) tmp = fma(0.5, t_1, Float64(0.5 * fmin(p, r))); elseif (abs(q) <= 8.09018202335526e-100) tmp = fma(0.5, t_0, Float64(-0.5 * fmax(p, r))); elseif (abs(q) <= 3.4921617425343053e+131) tmp = Float64(Float64(0.5 * Float64(t_1 + Float64(t_0 - t_2))) - Float64(Float64(abs(q) * abs(q)) / t_2)); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := Block[{t$95$0 = N[Abs[N[Max[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Min[p, r], $MachinePrecision] - N[Max[p, r], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[q], $MachinePrecision], 5.36940421531915e-191], N[(0.5 * t$95$1 + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 8.09018202335526e-100], N[(0.5 * t$95$0 + N[(-0.5 * N[Max[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 3.4921617425343053e+131], N[(N[(0.5 * N[(t$95$1 + N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Abs[q], $MachinePrecision] * N[Abs[q], $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]]]]]]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp = IF (p > r) THEN p ELSE r ENDIF IN LET t_0 = (abs(tmp)) IN LET tmp_1 = IF (p < r) THEN p ELSE r ENDIF IN LET t_1 = (abs(tmp_1)) IN LET tmp_2 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_3 = IF (p > r) THEN p ELSE r ENDIF IN LET t_2 = (abs((tmp_2 - tmp_3))) IN LET tmp_6 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_9 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_10 = IF ((abs(q)) <= (349216174253430531175005111321427954808209121420992526320759574349841032853605563124659701398649630875310478202201383466257711366144)) THEN (((5e-1) * (t_1 + (t_0 - t_2))) - (((abs(q)) * (abs(q))) / t_2)) ELSE (- (abs(q))) ENDIF IN LET tmp_8 = IF ((abs(q)) <= (8090182023355259495940432708722595855324228324423732375349457772194918817392176809386013820831290792736518267407924416786636103969651310468535044643700420264637301175379536151120602045571181872859051769063885261480412051151667549429526547929113211576890307696885429322719573974609375e-382)) THEN (((5e-1) * t_0) + ((-5e-1) * tmp_9)) ELSE tmp_10 ENDIF IN LET tmp_5 = IF ((abs(q)) <= (536940421531915006867631165022153464668122279414846984205212983959402568711900151385020404652487562807560417041190503025225567003625150801299618147861978055801560858308852788217657838524052986817851819441663309328634001481341509781502327953917316449762552696873625795635596673702380800635157350197697633736071140834292251302633376685403513437760664780715118204144730705501269672666046720609480782559520655476420778444136379362359212495058440554555128049023238201442609351943247020244598388671875e-685)) THEN (((5e-1) * t_1) + ((5e-1) * tmp_6)) ELSE tmp_8 ENDIF IN tmp_5 END code
\begin{array}{l}
t_0 := \left|\mathsf{max}\left(p, r\right)\right|\\
t_1 := \left|\mathsf{min}\left(p, r\right)\right|\\
t_2 := \left|\mathsf{min}\left(p, r\right) - \mathsf{max}\left(p, r\right)\right|\\
\mathbf{if}\;\left|q\right| \leq 5.36940421531915 \cdot 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_1, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 8.09018202335526 \cdot 10^{-100}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, -0.5 \cdot \mathsf{max}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 3.4921617425343053 \cdot 10^{+131}:\\
\;\;\;\;0.5 \cdot \left(t\_1 + \left(t\_0 - t\_2\right)\right) - \frac{\left|q\right| \cdot \left|q\right|}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if q < 5.3694042153191501e-191Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.3694042153191501e-191 < q < 8.0901820233552595e-100Initial program 23.8%
Applied rewrites21.0%
Taylor expanded in r around inf
Applied rewrites17.3%
if 8.0901820233552595e-100 < q < 3.4921617425343053e131Initial program 23.8%
Taylor expanded in q around 0
Applied rewrites18.9%
Applied rewrites40.4%
Applied rewrites30.1%
if 3.4921617425343053e131 < q Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q)
:precision binary64
:pre TRUE
(let* ((t_0 (fabs (fmax p r)))
(t_1 (fabs (fmin p r)))
(t_2 (fabs (- (fmin p r) (fmax p r)))))
(if (<= (fabs q) 5.36940421531915e-191)
(fma 0.5 t_1 (* 0.5 (fmin p r)))
(if (<= (fabs q) 8.09018202335526e-100)
(fma 0.5 t_0 (* -0.5 (fmax p r)))
(if (<= (fabs q) 3.4921617425343053e+131)
(- (* 0.5 (+ t_1 (- t_0 t_2))) (* (fabs q) (/ (fabs q) t_2)))
(- (fabs q)))))))double code(double p, double r, double q) {
double t_0 = fabs(fmax(p, r));
double t_1 = fabs(fmin(p, r));
double t_2 = fabs((fmin(p, r) - fmax(p, r)));
double tmp;
if (fabs(q) <= 5.36940421531915e-191) {
tmp = fma(0.5, t_1, (0.5 * fmin(p, r)));
} else if (fabs(q) <= 8.09018202335526e-100) {
tmp = fma(0.5, t_0, (-0.5 * fmax(p, r)));
} else if (fabs(q) <= 3.4921617425343053e+131) {
tmp = (0.5 * (t_1 + (t_0 - t_2))) - (fabs(q) * (fabs(q) / t_2));
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) t_0 = abs(fmax(p, r)) t_1 = abs(fmin(p, r)) t_2 = abs(Float64(fmin(p, r) - fmax(p, r))) tmp = 0.0 if (abs(q) <= 5.36940421531915e-191) tmp = fma(0.5, t_1, Float64(0.5 * fmin(p, r))); elseif (abs(q) <= 8.09018202335526e-100) tmp = fma(0.5, t_0, Float64(-0.5 * fmax(p, r))); elseif (abs(q) <= 3.4921617425343053e+131) tmp = Float64(Float64(0.5 * Float64(t_1 + Float64(t_0 - t_2))) - Float64(abs(q) * Float64(abs(q) / t_2))); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := Block[{t$95$0 = N[Abs[N[Max[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[Min[p, r], $MachinePrecision] - N[Max[p, r], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[q], $MachinePrecision], 5.36940421531915e-191], N[(0.5 * t$95$1 + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 8.09018202335526e-100], N[(0.5 * t$95$0 + N[(-0.5 * N[Max[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 3.4921617425343053e+131], N[(N[(0.5 * N[(t$95$1 + N[(t$95$0 - t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Abs[q], $MachinePrecision] * N[(N[Abs[q], $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]]]]]]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp = IF (p > r) THEN p ELSE r ENDIF IN LET t_0 = (abs(tmp)) IN LET tmp_1 = IF (p < r) THEN p ELSE r ENDIF IN LET t_1 = (abs(tmp_1)) IN LET tmp_2 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_3 = IF (p > r) THEN p ELSE r ENDIF IN LET t_2 = (abs((tmp_2 - tmp_3))) IN LET tmp_6 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_9 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_10 = IF ((abs(q)) <= (349216174253430531175005111321427954808209121420992526320759574349841032853605563124659701398649630875310478202201383466257711366144)) THEN (((5e-1) * (t_1 + (t_0 - t_2))) - ((abs(q)) * ((abs(q)) / t_2))) ELSE (- (abs(q))) ENDIF IN LET tmp_8 = IF ((abs(q)) <= (8090182023355259495940432708722595855324228324423732375349457772194918817392176809386013820831290792736518267407924416786636103969651310468535044643700420264637301175379536151120602045571181872859051769063885261480412051151667549429526547929113211576890307696885429322719573974609375e-382)) THEN (((5e-1) * t_0) + ((-5e-1) * tmp_9)) ELSE tmp_10 ENDIF IN LET tmp_5 = IF ((abs(q)) <= (536940421531915006867631165022153464668122279414846984205212983959402568711900151385020404652487562807560417041190503025225567003625150801299618147861978055801560858308852788217657838524052986817851819441663309328634001481341509781502327953917316449762552696873625795635596673702380800635157350197697633736071140834292251302633376685403513437760664780715118204144730705501269672666046720609480782559520655476420778444136379362359212495058440554555128049023238201442609351943247020244598388671875e-685)) THEN (((5e-1) * t_1) + ((5e-1) * tmp_6)) ELSE tmp_8 ENDIF IN tmp_5 END code
\begin{array}{l}
t_0 := \left|\mathsf{max}\left(p, r\right)\right|\\
t_1 := \left|\mathsf{min}\left(p, r\right)\right|\\
t_2 := \left|\mathsf{min}\left(p, r\right) - \mathsf{max}\left(p, r\right)\right|\\
\mathbf{if}\;\left|q\right| \leq 5.36940421531915 \cdot 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_1, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 8.09018202335526 \cdot 10^{-100}:\\
\;\;\;\;\mathsf{fma}\left(0.5, t\_0, -0.5 \cdot \mathsf{max}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 3.4921617425343053 \cdot 10^{+131}:\\
\;\;\;\;0.5 \cdot \left(t\_1 + \left(t\_0 - t\_2\right)\right) - \left|q\right| \cdot \frac{\left|q\right|}{t\_2}\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if q < 5.3694042153191501e-191Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.3694042153191501e-191 < q < 8.0901820233552595e-100Initial program 23.8%
Applied rewrites21.0%
Taylor expanded in r around inf
Applied rewrites17.3%
if 8.0901820233552595e-100 < q < 3.4921617425343053e131Initial program 23.8%
Taylor expanded in q around 0
Applied rewrites18.9%
Applied rewrites40.4%
Applied rewrites30.1%
Applied rewrites35.1%
if 3.4921617425343053e131 < q Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q)
:precision binary64
:pre TRUE
(if (<= (fabs q) 5.36940421531915e-191)
(fma 0.5 (fabs (fmin p r)) (* 0.5 (fmin p r)))
(if (<= (fabs q) 7.787488261081638e-85)
(fma 0.5 (fabs (fmax p r)) (* -0.5 (fmax p r)))
(- (fabs q)))))double code(double p, double r, double q) {
double tmp;
if (fabs(q) <= 5.36940421531915e-191) {
tmp = fma(0.5, fabs(fmin(p, r)), (0.5 * fmin(p, r)));
} else if (fabs(q) <= 7.787488261081638e-85) {
tmp = fma(0.5, fabs(fmax(p, r)), (-0.5 * fmax(p, r)));
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) tmp = 0.0 if (abs(q) <= 5.36940421531915e-191) tmp = fma(0.5, abs(fmin(p, r)), Float64(0.5 * fmin(p, r))); elseif (abs(q) <= 7.787488261081638e-85) tmp = fma(0.5, abs(fmax(p, r)), Float64(-0.5 * fmax(p, r))); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := If[LessEqual[N[Abs[q], $MachinePrecision], 5.36940421531915e-191], N[(0.5 * N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Abs[q], $MachinePrecision], 7.787488261081638e-85], N[(0.5 * N[Abs[N[Max[p, r], $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[Max[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp_3 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_4 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_8 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_9 = IF (p > r) THEN p ELSE r ENDIF IN LET tmp_7 = IF ((abs(q)) <= (778748826108163804208766857159266349094468015058461109889708351320311983313603916688376123073077997295472532815465593254842482251414857048497357284755730285493972951794794840441913677130380040631875190730061542243589656209223903715610504150390625e-330)) THEN (((5e-1) * (abs(tmp_8))) + ((-5e-1) * tmp_9)) ELSE (- (abs(q))) ENDIF IN LET tmp_2 = IF ((abs(q)) <= (536940421531915006867631165022153464668122279414846984205212983959402568711900151385020404652487562807560417041190503025225567003625150801299618147861978055801560858308852788217657838524052986817851819441663309328634001481341509781502327953917316449762552696873625795635596673702380800635157350197697633736071140834292251302633376685403513437760664780715118204144730705501269672666046720609480782559520655476420778444136379362359212495058440554555128049023238201442609351943247020244598388671875e-685)) THEN (((5e-1) * (abs(tmp_3))) + ((5e-1) * tmp_4)) ELSE tmp_7 ENDIF IN tmp_2 END code
\begin{array}{l}
\mathbf{if}\;\left|q\right| \leq 5.36940421531915 \cdot 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|\mathsf{min}\left(p, r\right)\right|, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{elif}\;\left|q\right| \leq 7.787488261081638 \cdot 10^{-85}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|\mathsf{max}\left(p, r\right)\right|, -0.5 \cdot \mathsf{max}\left(p, r\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if q < 5.3694042153191501e-191Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.3694042153191501e-191 < q < 7.787488261081638e-85Initial program 23.8%
Applied rewrites21.0%
Taylor expanded in r around inf
Applied rewrites17.3%
if 7.787488261081638e-85 < q Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q) :precision binary64 :pre TRUE (if (<= (pow (fabs q) 2.0) 5e-170) (fma 0.5 (fabs (fmin p r)) (* 0.5 (fmin p r))) (- (fabs q))))
double code(double p, double r, double q) {
double tmp;
if (pow(fabs(q), 2.0) <= 5e-170) {
tmp = fma(0.5, fabs(fmin(p, r)), (0.5 * fmin(p, r)));
} else {
tmp = -fabs(q);
}
return tmp;
}
function code(p, r, q) tmp = 0.0 if ((abs(q) ^ 2.0) <= 5e-170) tmp = fma(0.5, abs(fmin(p, r)), Float64(0.5 * fmin(p, r))); else tmp = Float64(-abs(q)); end return tmp end
code[p_, r_, q_] := If[LessEqual[N[Power[N[Abs[q], $MachinePrecision], 2.0], $MachinePrecision], 5e-170], N[(0.5 * N[Abs[N[Min[p, r], $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[Min[p, r], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp_3 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_4 = IF (p < r) THEN p ELSE r ENDIF IN LET tmp_2 = IF (((abs(q)) ^ (2)) <= (50000000000000001005897896399759447471663533251681488230631673082178993512233877041951504141337718672782395574383719360739346127312822404793014987451483155735953233572139998721523190708243228387841467383029606869434144008536067884865524710326518014000764983693195045464120416181063784414611472713361231600365858598841095313775215944350820782849125325027755638627155853348802458171985828261675066213273201619349261903835213161073625087738037109375e-615)) THEN (((5e-1) * (abs(tmp_3))) + ((5e-1) * tmp_4)) ELSE (- (abs(q))) ENDIF IN tmp_2 END code
\begin{array}{l}
\mathbf{if}\;{\left(\left|q\right|\right)}^{2} \leq 5 \cdot 10^{-170}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \left|\mathsf{min}\left(p, r\right)\right|, 0.5 \cdot \mathsf{min}\left(p, r\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if (pow.f64 q #s(literal 2 binary64)) < 5.0000000000000001e-170Initial program 23.8%
Applied rewrites21.2%
Taylor expanded in p around -inf
Applied rewrites17.6%
if 5.0000000000000001e-170 < (pow.f64 q #s(literal 2 binary64)) Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q) :precision binary64 :pre TRUE (if (<= (pow (fabs q) 2.0) 5e-222) (* 0.5 (sqrt (* p p))) (- (fabs q))))
double code(double p, double r, double q) {
double tmp;
if (pow(fabs(q), 2.0) <= 5e-222) {
tmp = 0.5 * sqrt((p * p));
} else {
tmp = -fabs(q);
}
return tmp;
}
real(8) function code(p, r, q)
use fmin_fmax_functions
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
real(8) :: tmp
if ((abs(q) ** 2.0d0) <= 5d-222) then
tmp = 0.5d0 * sqrt((p * p))
else
tmp = -abs(q)
end if
code = tmp
end function
public static double code(double p, double r, double q) {
double tmp;
if (Math.pow(Math.abs(q), 2.0) <= 5e-222) {
tmp = 0.5 * Math.sqrt((p * p));
} else {
tmp = -Math.abs(q);
}
return tmp;
}
def code(p, r, q): tmp = 0 if math.pow(math.fabs(q), 2.0) <= 5e-222: tmp = 0.5 * math.sqrt((p * p)) else: tmp = -math.fabs(q) return tmp
function code(p, r, q) tmp = 0.0 if ((abs(q) ^ 2.0) <= 5e-222) tmp = Float64(0.5 * sqrt(Float64(p * p))); else tmp = Float64(-abs(q)); end return tmp end
function tmp_2 = code(p, r, q) tmp = 0.0; if ((abs(q) ^ 2.0) <= 5e-222) tmp = 0.5 * sqrt((p * p)); else tmp = -abs(q); end tmp_2 = tmp; end
code[p_, r_, q_] := If[LessEqual[N[Power[N[Abs[q], $MachinePrecision], 2.0], $MachinePrecision], 5e-222], N[(0.5 * N[Sqrt[N[(p * p), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-N[Abs[q], $MachinePrecision])]
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = LET tmp = IF (((abs(q)) ^ (2)) <= (500000000000000008482296292842844653003018847120501430120651755224086621501780404131494075169416189205883798540023086400694351865018123269431435027656570060610576963555425217569608593413413482565836984953252182271241000501522927739997994931101299789431035873779958743754089556205216782091543177669938469351871121273944196353925555024236772438898944085631209958536076868001482940518827684820471270683030692910284420193251324845665750466190599802159907915100658966471944439389678379997040714629822808787505420865402039886990080870543540214612221461720764636993408203125e-788)) THEN ((5e-1) * (sqrt((p * p)))) ELSE (- (abs(q))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;{\left(\left|q\right|\right)}^{2} \leq 5 \cdot 10^{-222}:\\
\;\;\;\;0.5 \cdot \sqrt{p \cdot p}\\
\mathbf{else}:\\
\;\;\;\;-\left|q\right|\\
\end{array}
if (pow.f64 q #s(literal 2 binary64)) < 5.0000000000000001e-222Initial program 23.8%
Taylor expanded in p around inf
Applied rewrites6.7%
Taylor expanded in p around 0
Applied rewrites4.5%
Applied rewrites6.7%
if 5.0000000000000001e-222 < (pow.f64 q #s(literal 2 binary64)) Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
(FPCore (p r q) :precision binary64 :pre TRUE (- (fabs q)))
double code(double p, double r, double q) {
return -fabs(q);
}
real(8) function code(p, r, q)
use fmin_fmax_functions
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
code = -abs(q)
end function
public static double code(double p, double r, double q) {
return -Math.abs(q);
}
def code(p, r, q): return -math.fabs(q)
function code(p, r, q) return Float64(-abs(q)) end
function tmp = code(p, r, q) tmp = -abs(q); end
code[p_, r_, q_] := (-N[Abs[q], $MachinePrecision])
f(p, r, q): p in [-inf, +inf], r in [-inf, +inf], q in [-inf, +inf] code: THEORY BEGIN f(p, r, q: real): real = - (abs(q)) END code
-\left|q\right|
Initial program 23.8%
Taylor expanded in q around inf
Applied rewrites19.5%
Applied rewrites19.5%
herbie shell --seed 2026089 +o generate:egglog
(FPCore (p r q)
:name "1/2(abs(p)+abs(r) - sqrt((p-r)^2 + 4q^2))"
:precision binary64
(* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))