-1

こんにちは、指定された x と正の整数 n に対して 1+x+x^2+...+x^n を計算し、それを使用して (1+x+x^2+.. .+x^10)(1+x^2+x^4+...+x^10) x=100?

4

6 に答える 6

1

Sage タグを付けたので、Sage でそれを行う楽しい方法を次に示します。

sage: R.<x> = PowerSeriesRing(ZZ)

は、R を x を変数とするべき級数として定義します。ZZ は、係数に整数を使用していることを意味します。それでは、それで何ができるか見てみましょう。

sage: R([1, 2])              # the array inside contains the coefficients 
1 + 2*x                      # for each element of the series
sage: R([1]*11)              # this gives us the first power series
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10
sage: R([1,0]*5 + [1])       # and here is our second one
1 + x^2 + x^4 + x^6 + x^8 + x^10
sage: R([1]*11).(5)          # we can evaluate these for various x values
12207031
sage: R([1]*11).subs(x=5)    # an alternate way to evaluate
12207031
sage: f = R([1]*11)*R([1,0]*5+[1])  # this constructs the desired function
sage: f(100)                   # we can evaluate it at any value

とにかく、これで Sage でこれを行う方法が理解できたと思います。私自身、Sage にはまったく慣れていませんが、これまでのところ本当に掘り下げています。

于 2010-12-17T07:57:42.367 に答える
1

これを使用して次を計算できます1+x+x^2+...+x^n

lambda x, n: sum([x**y for y in range(0, n + 1)])

ロジックを使用して 2 番目の関数を計算します。

于 2010-12-17T03:50:32.590 に答える
1
def myfunc(x, n, step):
  if n > 0:
    return x**n + myfunc(x, n - step, step)
  return 1

myfunc(100, 10, 1) * myfunc(100, 10, 2)
于 2010-12-17T03:49:47.720 に答える
0

あなたの最初の質問に対して、

x=2; (与えられた)

n=10; (与えられた)

それらの値が正であり、必要なものであるかどうかを自分で確認してください

結果=1;

for(a=2;a<=n;a++)

{

結果+=x^a;

}

于 2010-12-17T03:48:07.903 に答える
0

これはあなたが探している機能だと思います。

def f(x, n):
    answer = 0
    for y in range(n + 1):
        answer += x ** n
    return answer

後半はよくわかりません。

于 2010-12-17T03:48:21.370 に答える
0
function series($x, $n) {

    $answer = 1;           

    for($i = $n; $i > 0; $i--) {

         $answer += pow($x, $i);

    }

        return $answer;
}

series(100, 10) * series(100, 10)
于 2010-12-17T04:09:03.710 に答える