FAQ Database Discussion Community

## Why is this polynomial function throwing a SyntaxError?

python,linux,ubuntu,polynomial-math
I am trying to write a basic algorithm to evaluate a fourth order polynomial using Python. The code is below, and I am not sure what I am doing wrong. I came up with this code and I am not sure if it is enough to do the trick: x...

I have the following code.. import java.io.*; class Link { public int coeff; public int exp; Link next; public Link(int a,int b) { coeff=a;exp=b; } public int retcof(){ return coeff; } public int retexp() { return exp; } public void displayLink(){ System.out.print(coeff+"x^"+exp); } } class LinkList{ Link first,last; public LinkList(){...

## Sympy polynomials with `mpfr` coefficients?

python,python-3.x,sympy,polynomial-math,gmpy
I want to use Sympy's polynomials, but I also want to use higher-precision coefficients. Just Doing It seems to give me polynomials with sympy.core.numbers.float coefficients. import sympy from sympy import Poly from sympy.abc import x from gmpy2 import mpfr, get_context get_context().precision = 150 #float64 can't tell this from 1.0 one_and_change...

## Roots of a polynomial mod a prime

algorithm,sympy,polynomial-math,polynomials
I'm looking for a speedy algorithm to find the roots of a univariate polynomial in a prime finite field. That is, if f = a0 + a1x + a2x2 + ... + anxn (n > 0) then an algorithm that finds all r < p satisfying f(r) = 0 mod...

## Problems in implementing Horner's method in Python

python,function,loops,iteration,polynomial-math
So I have written down the codes for evaluating polynomial using three different methods. Horner's method should be the fastest, while the naive method should be the slowest, right? But how come the time for computing it is not what I expect? And the time for calculation sometimes turns out...

## How many number of primitive operations does a 16, 32 or a 64-bit processor execute to perform logical right shift of an N-bit Binary number? [closed]

algorithm,cryptography,bit-shift,polynomial-math,ecdsa
Recently,I have been trying to understand how the Binary Extended Euclidean Algorithm works at the processor level. This question is all about finding an Inverse element in GF(2^m) with polynomial basis. Generally I came across the Extended Euclidean Algorithm for evaluating an inverse element but the fact is that it...

## Transforming polynomial variable in Numpy

python,numpy,sympy,symbolic-math,polynomial-math
I am trying to learn how to use Numpy. Consider I have the roots of a polynomial. I use coeff = np.polynomial.polynomial.polyfromroots(roots) to get the coefficients of the polynomial as an array. Then I use print np.poly1d(coeff) To print out the polynomial. Let that polynomial be x^2 +3x + 2...

## sympy: Collect symbols for matrix coefficients?

matrix,sympy,symbolic-math,polynomial-math
I am trying to factor an expression, and separate coefficients to matrix form, such that: Closely related to Factor sympy expression to matrix coefficients?, where Wild symbols are used with match(form) to determine coefficients for its matrix form. However, I am unable to get the match(form) method to work for...

## Python - 'function' object has no attribute 'deflPoly'

python,polynomial-math,deflate
Tried creating a little script to test out the different parts of a script called polyRoots. When I tried to utilize the deflating poly function I get an error. Their is nothing complicated about this code and I am unsure why it isn't working. import polyRoots as pr print( "Deflation...

## Objective-C Quadratic/Polynomial regression (Linest function in excel)

ios,objective-c,math,polynomial-math
The objective-c math library seems pretty basic. I'm looking for some statistics analysis functions like the Excel function "linest" to retrieve the quadratic or polynomial regressions of a data set with a given order. Is there any function similar to the "linest" function for objective-c? Or a known statistics library/framework?...

## Ocaml Product of two polynomials

ocaml,polynomial-math
How to compute the product of two polynomials ? For example: x^3 + 3x^2 +0.2x and 2x^4 + 3 First I made a type Type term = {coefficient:int; name:string; exponent:int};; Type polynomials = term list;; then I made a function calculate coefficient let product l l' = List.concat (List.map (fun...

## How to normalise polynomial coefficients in a fraction?

matlab,polynomial-math
I have the following code: syms z Gc=1.582*(1-0.3679*z^-1)/(1+.418*z^-1); Ghp=.3679*(z^-1)*(1+.718*z^-1)/((1-z^-1)*(1-.3679*z^-1)); T=(Gc*Ghp)/(1+Gc*Ghp); clipboard('copy', latex(simplifyFraction(T))); Which results in following for T: How can I normalise coefficients? I.e. I want the z2 in denominator and z in numerator to have the coefficient of 1. Is there any function in Matlab to do so?...