Hot answers tagged

9

Perhaps this? ip[f_, g_, v_] := Module[{x, y, int}, int = (((f /. v -> x) - (f /. v -> y)) ((g /. v -> x) - (g /. v -> y)))/(x - y)^2; Integrate[int, {x, -1, 1}, {y, -1, 1}] ]; Orthogonalize[x^Range[4], ip[##, x] &] (* {x/2, 1/2 Sqrt[3/2] x^2, 3/2 Sqrt[5/13] (-((2 x)/3) + x^3), 15/8 Sqrt[21/31] (-((14 x^2)/15) + x^4)} *) The ...


7

Here are a couple of options. Given: poly = Array[# a[#] x^# &, 5] (* x a[1] + 2 x^2 a[2] + 3 x^3 a[3] + 4 x^4 a[4] + 5 x^5 a[5] *) We can do c = CoefficientRules[Expand[poly], x] c /. HoldPattern[a_ -> b_] :> (a -> b^2) (* {{5} -> 5 a[5], {4} -> 4 a[4], {3} -> 3 a[3], {2} -> 2 a[2], {1} -> a[1]} *) (* {{5} -> 25 a[5]^2, ...


5

I seem to be getting different results depending on whether I use OP's suggested inner product in the comments, or if I use the polarization identity. Before everything else, however, here is a routine by Velvel Kahan for evaluating the divided difference of a polynomial, based on Horner's method: polynomialDividedDifference[poly_, {x_, a_, b_}] /; ...


5

You can get all the informations you want in a list, Then to pick the min. It will be the first. The largest is at the end. expr = a1/x + a2/x^2 + a3/x^3 + a4 x^5 + x^6; r = {Coefficient[#, x, Exponent[#, x]], #, Exponent[#, x]} & /@ (List @@ expr) To get the answer you want, now simply pull the second entry in the first cell r[[1, 2]]/r[[1, 1]] ...


4

f = # -> #2^2 & @@@ # &; poly = Plus @@ Array[# a[#] x^# &, 5]; c = CoefficientRules[poly, x] {{5} -> 5 a[5], {4} -> 4 a[4], {3} -> 3 a[3], {2} -> 2 a[2], {1} -> a[1]} f@c {{5} -> 25 a[5]^2, {4} -> 16 a[4]^2, {3} -> 9 a[3]^2, {2} -> 4 a[2]^2, {1} -> a[1]^2}


4

exp=a1/x + a2/x^2 + a3/x^3; v=Min@Cases[exp, Power[_, x_?NumberQ] :> x, -1]; Cases[exp, Times[x_, Power[_, v]], -1]


4

Not an answer, but just a collection of results on my computer (Mac OS X 11.4) The timings are in seconds as reported by AbsoluteTiming. They are in the same order as the test cases provided by OP On Mathematica 8: {1.44, 1.33, 271.7, 0.000066} On Mathematica 9: {0.62, 0.61, 9.00, 0.00012} On Mathematica 10.3: {8.82, 8.78, 8.62, 0.00006} On ...


3

When dealing with a list of rules ({a->b, c->d, ...}) you might also be interested in converting it first into an Association, which allow efficient treatment of its elements and with some more simple syntax. For example in your case: taking @March example: poly = Array[# a[#] x^# &, 5] (* x a[1] + 2 x^2 a[2] + 3 x^3 a[3] + 4 x^4 a[4] + 5 x^5 ...


3

This is probably similar to Salzer's algorithm J.M. refers to, but it seemed easier to figure it out from the recurrence relation $$T_{n+1} = 2x\,T_{n} - T_{n-1}$$ From it, we get the following identity for multiplying by $x$: $$\eqalign{ x\, T_0 &= T_1 \cr x\, T_{n} &= \frac{1}{2}\,T_{n+1} - \frac{1}{2}\,T_{n-1}, \quad n \ge 1\cr }$$ From the Horner ...


3

Replace[monomial, coefs_ t : Times[Power[_x, _.] ..] :> {coefs, 1 t}] Examples: Replace[C1 x[1] x[2]^2, coefs_ t : Times[Power[_x, _.] ..] :> {coefs, 1 t}] (* {C1, x[1] x[2]^2} *) Replace[C1 C2 x[1] x[2]^2 x[3], coefs_ t : Times[Power[_x, _.] ..] :> {coefs, 1 t}] (* {C1 C2, x[1] x[2]^2 x[3]} *)


1

exp2 = List @@ exp /. y -> x; xpow = Min@Cases[exp2, Power[x, p_] :> p, -1]; pos = Position[exp2, x^xpow, -1][[;; , 1]]; exp[[pos]] (*7/x^5 + 1/y^5 + 1/(x^4 y z^3)*)



Only top voted, non community-wiki answers of a minimum length are eligible