def standard_pade_approximants(pols, sols, idx=1, numdeg=2, dendeg=2, \ nbr=4, verbose=True): r""" Computes Pade approximants based on the series in standard double precision for the polynomials in *pols*, where the leading coefficients of the series are the solutions in *sols*. On entry are the following seven parameters: *pols*: a list of string representations of polynomials, *sols*: a list of solutions of the polynomials in *pols*, *idx*: index of the series parameter, by default equals 1, *numdeg*: the degree of the numerator, *dendeg*: the degree of the denominator, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_solutions from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 \ import py2c_standard_Pade_approximant as Pade_approximants from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c3 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print("the polynomials :") for pol in pols: print(pol) print("Number of variables :", nbsym) store_standard_system(pols, nbvar=nbsym) store_standard_solutions(nbsym, sols) fail = Pade_approximants(idx, numdeg, dendeg, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print("An error occurred in the Pade constructor.") else: print("Computed %d Pade approximants." % size) result = [] for k in range(1, size + 1): py2c_syspool_copy_to_standard_container(k) sersol = load_standard_system() substsersol = substitute_symbol(sersol, idx) result.append(make_fractions(substsersol)) py2c_syspool_standard_clear() return result
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading terms are given in the list *lser*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *lser*: a list of polynomials in the series parameter (e.g.: t), for use as start terms in Newton's method, *idx*: index of the series parameter, by default equals 1, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 import py2c_standard_Newton_power_series as newton from phcpy.phcpy2c3 import py2c_syspool_standard_init from phcpy.phcpy2c3 import py2c_syspool_standard_create from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c3 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print("the polynomials :") for pol in pols: print(pol) print("Number of variables :", nbsym) store_standard_system(lser, nbvar=1) py2c_syspool_standard_init(1) py2c_syspool_standard_create(1) store_standard_system(pols, nbvar=nbsym) fail = newton(idx, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print("An error occurred in the execution of Newton's method.") else: print("Computed one series solution.") py2c_syspool_copy_to_standard_container(1) result = load_standard_system() result = substitute_symbol(result, idx) py2c_syspool_standard_clear() return result
def standard_newton_power_series(pols, lser, idx=1, nbr=4, verbose=True): r""" Computes series in standard double precision for the polynomials in *pols*, where the leading terms are given in the list *lser*. On entry are the following five parameters: *pols*: a list of string representations of polynomials, *lser*: a list of polynomials in the series parameter (e.g.: t), for use as start terms in Newton's method, *idx*: index of the series parameter, by default equals 1, *nbr*: number of steps with Newton's method, *verbose*: whether to write intermediate output to screen or not. On return is a list of lists of strings. Each lists of strings represents the series solution for the variables in the list *pols*. """ from phcpy.solver import number_of_symbols from phcpy.interface import store_standard_system, load_standard_system from phcpy.phcpy2c3 import py2c_standard_Newton_power_series as newton from phcpy.phcpy2c3 import py2c_syspool_standard_init from phcpy.phcpy2c3 import py2c_syspool_standard_create from phcpy.phcpy2c3 import py2c_syspool_standard_size as poolsize from phcpy.phcpy2c3 import py2c_syspool_copy_to_standard_container from phcpy.phcpy2c3 import py2c_syspool_standard_clear nbsym = number_of_symbols(pols) if verbose: print("the polynomials :") for pol in pols: print(pol) print("Number of variables :", nbsym) store_standard_system(lser, nbvar=1) py2c_syspool_standard_init(1); py2c_syspool_standard_create(1); store_standard_system(pols, nbvar=nbsym) fail = newton(idx, nbr, int(verbose)) size = (-1 if fail else poolsize()) if verbose: if size == -1: print("An error occurred in the execution of Newton's method.") else: print("Computed one series solution.") py2c_syspool_copy_to_standard_container(1) result = load_standard_system() result = substitute_symbol(result, idx) py2c_syspool_standard_clear() return result