# polynomials

##### SymPy: Factorization of polynomials over symbolic roots with combined square roots

SymPy factor function can factorize over symbolic roots, e.g. : In [1]: from sympy import * In [2]: init_printing(use_latex=False) In [3]: z, a, b = symbols('z a b') In [4]: poly = expand((z - sqrt(a))*(z - sqrt(b)), z) In [5]: poly Out[5]: 2 √a⋅√b - √a⋅z - √b⋅z + z In [6]: factor(poly, z) Out[6]: (-√a + z)⋅(-√b + z) but the factorization fails if b = a : In [10]: b = a In [11]: poly = expand((z - sqrt(a))*(z - sqrt(b)), z) In [12]: poly Out[12]: 2 -2⋅√a⋅z + a + z In [13]: factor(poly, z) Out[13]: 2 -2⋅√a⋅z + a + z Thus, the factorization fails if the identity sqrt(a) * sqrt(a) = a is applied

2021-09-08 09:17:29    分类:问答    python   math   sympy   polynomials   polynomial-math

##### I would like to print superscript and subscript with printf, like x¹?

I want to print out a polynomial expression in c but i don't know print x to the power of a number with printf

2021-09-04 07:54:48    分类:问答    c   unicode   polynomials   subscript   superscript

##### Setting up array of complex coefficients, avoiding the leading zero's

I have created a class for complex numbers: public class Complex { private double x; //Real part x of the complex number x+iy. private double y; //Imaginary part y of the complex number x+iy. public Complex(double x, double y) { //Constructor: Initializes x, y. this.x=x; this.y=y; } public Complex(double x) { //Real constructor - initialises with a real number. this(x, 0.0); } public Complex() { //Default constructor; initialiase x and y to zero. this(0.0, 0.0); } } What I would like to do is create a function Polynomial, which would take an array of coefficients, and filter it so that if for

2021-09-04 07:13:29    分类:问答    java   math   numbers   polynomials   polynomial-math

##### Find tangent points on a curve from a user-given point outside the curve

I am trying to find the tangent lines from a given point outside a closed curve (not on the curve). The curve is defined as 2D x and y coordinates of points，shaped like an irregular ellipse for example. If given a point by the user: (x0,y0) = (-30,80), how can I know the tangent points (obviously closest point among discrete points from the smooth curve) on curve (i.e. tangent lines from (x0,y0) to curve)?

2021-09-03 23:21:25    分类:问答    matlab   geometry   curve-fitting   polynomials

##### Sympy：删除多项式中的高阶项(Sympy: Drop higher order terms in polynomial)

2021-09-01 07:25:23    分类:技术分享    python   sympy   symbolic-math   computer-algebra-systems   polynomials

2021-08-31 21:16:38    分类:技术分享    java   linked-list   polynomials

##### Extract coefficients and corresponding monomials from a given polynomial in SymPy

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 function returns a list of exponents, e.g., in the example above we would get P.monoms() = [(2,0),(1,1),(0

2021-08-30 06:51:14    分类:问答    python   python-3.x   sympy   polynomials

##### Creating a python lmfit Model with arbitrary number of parameters

Is there a way to construct a an lmfit Model based on a function with an arbitrary number of dependent variables? For example: from lmfit import Model def my_poly(x, *params): func = 0 for i in range(len(params)): func+= params[i]*z**i return func #note: below does not work my_model = Model(my_poly, independent_vars = ['x'], param_names = ['A','B','C']) Something similar to the above would be wonderful if I am interested in a polynomial series and want to test the performance as the series grows or shrinks.

2021-08-30 00:47:16    分类:问答    python   curve-fitting   polynomials   lmfit

##### Find the coefficients of the polynomial given its roots

I am trying to write an algorithm which will find a(0),..., a(n-1), given the values of n, x_1, ..., x_n, a(n), such that: a(n)*p^n + a(n-1)*p^(n-1) + ... + a(1)*p + a(0) = a(n)(p-x_1)(p-x_2)...(p-x_n) for all real p. After multiplying a(n)(p-x_1)(p-x_2) I've thought of using Viete's formulas to find the coefficients. But it turns out writing the code down isn't as obvious as I expected. I want to use only the basics in my code - that is loops, if-s addition and multiplication - no ready/ complex functions. Here are the formulas: First, I would like to emphasise that I only need a pseudocode

2021-08-12 07:09:59    分类:问答    algorithm   loops   for-loop   polynomial-math   polynomials

##### 获取向量幂的有效方法(efficient way to take powers of a vector)

2021-08-12 00:57:45    分类:技术分享    arrays   matlab   polynomials