polynomials

Numerically calculate combinations of factorials and polynomials

一个人想着一个人 提交于 2021-02-19 03:36:29
问题 I am trying to write a short C++ routine to calculate the following function F(i,j,z) for given integers j > i (typically they lie between 0 and 100) and complex number z (bounded by |z| < 100), where L are the associated Laguerre Polynomials: The issue is that I want this function to be callable from within a CUDA kernel (i.e. with a __device__ attribute). Standard library/Boost/etc functions are therefore out of the questions, unless they are simple enough to re-implement on my own - this

How to propagate `\n` to sympy.latex()

僤鯓⒐⒋嵵緔 提交于 2021-02-10 15:59:52
问题 The Goal is to format a polynomial with more than 6 parameters into a plot title. Here is my polynomial parameter to string expression function, inspired by this answer, followed by sym.latex() : def func(p_list): str_expr = "" for i in range(len(p_list)-1,-1,-1): if (i%2 == 0 and i !=len(p_list)): str_expr =str_expr + " \n " if p_list[i]>0: sign = " +" else: sign = "" if i > 1: str_expr = str_expr+" + %s*x**%s"%(p_list[i],i) if i == 1: str_expr = str_expr+" + %s*x"%(p_list[i]) if i == 0: str

Regex for polynomial expression

一个人想着一个人 提交于 2021-01-29 17:45:55
问题 I have a string that I hope is a polynomial expression, something like "2x^2-3x+1 . I want to use a regex to group each term in the expression. I currently have "^(-?\d?x(\^\d)?)+" . I'm trying to capture a term as an optional minus sign, then a number, then x, then an optional exponent, which should be of the form "^someNumber". So for my above polynomial, I'd want group 1 to be "2x^2" , group 2 to be "-3x" and group 3 to be "+1" . Firstly, if I have (someGroupExpression)+ , will this

How can I use multiple dimensional polynomials with numpy.polynomial?

社会主义新天地 提交于 2021-01-28 08:20:18
问题 I'm able to use numpy.polynomial to fit terms to 1D polynomials like f(x) = 1 + x + x^2 . How can I fit multidimensional polynomials, like f(x,y) = 1 + x + x^2 + y + yx + y x^2 + y^2 + y^2 x + y^2 x^2 ? It looks like numpy doesn't support multidimensional polynomials at all: is that the case? In my real application, I have 5 dimensions of input and I am interested in hermite polynomials. It looks like the polynomials in scipy.special are also only available for one dimension of inputs. # One

Extract coefficients and corresponding monomials from a given polynomial in SymPy

匆匆过客 提交于 2021-01-27 12:24:54
问题 Given a symbolic multivariate polynomial P , I need to extract both its coefficients and corresponding monomials as lists: def poly_decomp(P): .... return coeffs, monoms such that P is the dot product of coefficients and monomials, e.g., if P(x,y) = ax**2 + bxy + cy**2 then we should get coeffs = [a, b, c] and monoms = [x**2, x*y, y**2] . Getting the coefficients is easy since the function is built in coeffs = P.coeffs() . However, I'm having trouble getting the monomials. Here the build in

List of coefficients to polynomial

和自甴很熟 提交于 2021-01-27 06:08:18
问题 How do I create a polynomial out of a list of coefficients in SymPy? For example, given a list [1, -2, 1] I would like to get Poly(x**2 - 2*x + 1) . I tried looking at the docs but could not find anything close to it. 回答1: You could use Poly.from_list to construct the polynomial: >>> x = sympy.Symbol('x') >>> sympy.Poly.from_list([1, -2, 1], gens=x) Poly(x**2 - 2*x + 1, x, domain='ZZ') 回答2: It looks to me like you would do something like: from sympy.abc import x from sympy import poly lst =

Cannot understand with sklearn's PolynomialFeatures

回眸只為那壹抹淺笑 提交于 2020-12-27 19:09:11
问题 Need help in sklearn's Polynomial Features. It works quite well with one feature but whenever I add multiple features, it also outputs some values in the array besides the values raised to the power of the degrees. For ex: For this array, X=np.array([[230.1,37.8,69.2]]) when I try to X_poly=poly.fit_transform(X) It outputs [[ 1.00000000e+00 2.30100000e+02 3.78000000e+01 6.92000000e+01 5.29460100e+04 8.69778000e+03 1.59229200e+04 1.42884000e+03 2.61576000e+03 4.78864000e+03]] Here, what is 8

Cannot understand with sklearn's PolynomialFeatures

瘦欲@ 提交于 2020-12-27 18:51:12
问题 Need help in sklearn's Polynomial Features. It works quite well with one feature but whenever I add multiple features, it also outputs some values in the array besides the values raised to the power of the degrees. For ex: For this array, X=np.array([[230.1,37.8,69.2]]) when I try to X_poly=poly.fit_transform(X) It outputs [[ 1.00000000e+00 2.30100000e+02 3.78000000e+01 6.92000000e+01 5.29460100e+04 8.69778000e+03 1.59229200e+04 1.42884000e+03 2.61576000e+03 4.78864000e+03]] Here, what is 8

Cannot understand with sklearn's PolynomialFeatures

风流意气都作罢 提交于 2020-12-27 18:49:22
问题 Need help in sklearn's Polynomial Features. It works quite well with one feature but whenever I add multiple features, it also outputs some values in the array besides the values raised to the power of the degrees. For ex: For this array, X=np.array([[230.1,37.8,69.2]]) when I try to X_poly=poly.fit_transform(X) It outputs [[ 1.00000000e+00 2.30100000e+02 3.78000000e+01 6.92000000e+01 5.29460100e+04 8.69778000e+03 1.59229200e+04 1.42884000e+03 2.61576000e+03 4.78864000e+03]] Here, what is 8