如何求解形式幂级数中的代数方程? [英] How to solve an algebraic equation in formal power series?

查看:35
本文介绍了如何求解形式幂级数中的代数方程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动机.众所周知,加泰罗尼亚数的生成函数满足二次方程.我想要一个函数的前几个系数,由代数方程隐式定义(不一定是二次方程!).

Motivation. It is well known that generating function for Catalan numbers satisfies quadratic equation. I would like to have first several coefficients of a function, implicitly defined by an algebraic equation (not necessarily a quadratic one!).

示例.

import sympy as sp
sp.init_printing() # math as latex
from IPython.display import display
z = sp.Symbol('z')
F = sp.Function('F')(z)
equation = 1 + z * F**2 - F
display(equation)

solution = sp.solve(equation, F)[0]
display(solution)

display(sp.series(solution))

问题.我们明确求解方程然后将其扩展为幂级数的方法仅适用于低次方程.如何获得更复杂代数方程的形式幂级数的第一系数?

Question. The approach where we explicitly solve the equation and then expand it as power series, works only for low-degree equations. How to obtain first coefficients of formal power series for more complicated algebraic equations?

相关.

由于代数和微分框架的行为可能不同,我发布了另一个问题.

Related.

Since algebraic and differential framework may behave differently, I posted another question.

Sympy:如何在形式上求解微分方程幂级数?

推荐答案

我不知道内置的方法,但是为 F 插入多项式并使系数相等就足够了.尽管不应试图从大型非线性系统中一次找到所有系数;这些会给 SymPy 带来麻烦.我采用迭代方法,首先将自由项等于零并求解 c0,然后等于 2 并求解 c1 等.

I don't know a built-in way, but plugging in a polynomial for F and equating the coefficients works well enough. Although one should not try to find all coefficients at once from a large nonlinear system; those will give SymPy trouble. I take iterative approach, first equating the free term to zero and solving for c0, then equating 2nd and solving for c1, etc.

这里假设一个正则代数方程,其中方程中z**k的系数涉及F的第k个泰勒系数,不涉及高阶系数.

This assumes a regular algebraic equation, in which the coefficient of z**k in the equation involves the k-th Taylor coefficient of F, and does not involve higher-order coefficients.

from sympy import *
z = Symbol('z')
d = 10                                 # how many coefficients to find
c = list(symbols('c:{}'.format(d)))    # undetermined coefficients
for k in range(d):
    F = sum([c[n]*z**n for n in range(k+1)])  # up to z**k inclusive
    equation = 1 + z * F**2 - F
    coeff_eqn = Poly(series(equation, z, n=k+1).removeO(), z).coeff_monomial(z**k)
    c[k] = solve(coeff_eqn, c[k])[0]
sol = sum([c[n]*z**n for n in range(d)])  # solution
print(series(sol + z**d, z, n=d))         # add z**d to get SymPy to print as a series

这个打印

1 + z + 2*z**2 + 5*z**3 + 14*z**4 + 42*z**5 + 132*z**6 + 429*z**7 + 1430*z**8 + 4862*z**9 + O(z**10)

这篇关于如何求解形式幂级数中的代数方程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆