polynomial-math

polynomial projection

how to project polynomial wih binary value example,if the polynomialis p(x)=c4x^4+c3x^3+c2x^2+c1x+c0 and x=111111111 then what will be the p(x). ...

Modular Reduction of Polynomials in NTRUEncrypt

Hello everyone. I'm implementing the NTRUEncrypt algorithm, according to an NTRU tutorial, a polynomial f has an inverse g such that f*g=1 mod x, basically the polynomial multiplied by its inverse reduced modulo x gives 1. I get the concept but in an example they provide, a polynomial f = -1 + X + X^2 - X4 + X6 + X9 - X10 which we will ...

help with multiplying polynomials in lisp

for example: (3x2 - 5x + 2)(7x + 1) and you simplify it like this: ((3 2)(-5 1)(2 0))((7 1)(1 0)) ((21 3)(3 2)(-35 2)(-5 1)(14 1)(2 0)) (21 3)(32 2)(9 1)(2 0) and you get this answer: 21x3 + 32x2 + 9x + 2 i need this solution in lisp please help ...

Roots of a Quartic Function

Hey guys, I came across a situation doing some advanced collision detection, where I needed to calculate the roots of a quartic function. I wrote a function that seems to work fine using Ferrari's general solution as seen here: http://en.wikipedia.org/wiki/Quartic_function#Ferrari.27s_solution. Here's my function: private functi...

How to implement Horner's scheme for multivariate polynomials?

Background I need to solve polynomials in multiple variables using Horner's scheme in Fortran90/95. The main reason for doing this is the increased efficiency and accuracy that occurs when using Horner's scheme to evaluate polynomials. I currently have an implementation of Horner's scheme for univariate/single variable polynomials. How...

subset sum problem

I came up with a new algorithm to solve the subset sum problem, and I think it's in polynomial time. Tell me I'm either wrong or a total genius. Quick starter facts: Subset sum problem is an NP-complete problem. Solving it in polynomial time means that P = NP. The number of subsets in a set of length N, is 2^N. On the more useful hand...

Find a root of a polynomial modulo 2^r

I have a polynomial P and I would like to find y such that P(y) = 0 modulo 2^r. I have tried something along the lines of Hensel lifting, but I don't know if this could even work, because of the usual condition f'(y mod 2) != 0 mod 2 which is not usually true. Is there a different algorithm available ? Or could a variation of Hensel li...

Efficient polynomial evaluation with Horner's Algorithm

I have the equation y = 3(x+1)^2 + 5(x+1)^4. Using Horner's scheme I could evaluate this polynomial in this form, y = 8+x(26+x(33+x(20+5x))), thus requiring 8 arithmetic operations. I could also evaluate it in this form, y = (x+1)^2 * ((5x+10)x+8), requiring 7 operations. I've been told this can be done in 5 operations but Horner's a...

Fitting polynomial model to data in R

I've read the answers to this question and they are quite helpful, but I need help particularly in R. I have an example data set in R as follows: x <- c(32,64,96,118,126,144,152.5,158) y <- c(99.5,104.8,108.5,100,86,64,35.3,15) I want to fit a model to these data so that y = f(x). I want it to be a 3rd order polynomial model. How...

3D Polynomial Regression

I need some pointers for writing a polynomial regression routine for 3-dimensional points (i.e. find the coefficients of an X order polynomial that is fitted to a certain number of 3D points). I've found code for 2D polynomial regression, however, I need to account for a 3rd dimension. I'm looking for code examples and/or explanations....

Good scripting language/framework for recreating polynomial root calculator

I was just wondering what the best online scripting language is to use for "simple" mathematical calculations, like solving for roots in 2nd 3rd or 4th degree polynomials. For example, creating a little web "applet" like the one found here which inserts the values inputed into the text boxes and inputs them as variables into the "quadra...

Does this method work for solving the quadratic equation using JavaScript?

I'm trying to do some "complex" math where I need to call upon some of JavaScript's Math properties to solve the quadratic equation. Does the following method work? root = Math.pow(inputb,2) - 4 * inputa * inputc; root1 = (-inputb + Math.sqrt(root))/2*inputa; root2 = (-inputb - Math.sqrt(root))/2*inputa; Does this look co...

Is this a bug in NSolve in mathematica?

One would expect and hope that if you ask Mathematica to find the roots of a polynomial, it should give the same (approximate) answers whether you do this symbolically, then find numerical approximations to these exact answers, or whether you do it numerically. Here's an example which (in Mathematica 7, running on OS X) where this fails ...

Lagrange interpolation in Python

I want to interpolate a polynomial with the Lagrange method, but this code doesn't work: def interpolate(x_values, y_values): def _basis(j): p = [(x - x_values[m])/(x_values[j] - x_values[m]) for m in xrange(k + 1) if m != j] return reduce(operator.mul, p) assert len(x_values) != 0 and (len(x_values) == len(y_va...

What's the opposite of JavaScript's Math.pow ?

I'm having a mental block here, and algebra not really being my thing, can you tell me how to re-write the JavaScript code below to derive the variable, c, in terms of a and b?: a = Math.pow(b, c); c = ? Thanks! ...

Durand-kerner implementation doesn't work

What's wrong with this implementation of the Durand-Kerner algorithm (here) ? def durand_kerner(poly, start=complex(.4, .9), epsilon=10**-16):#float('-inf')): roots = [] for e in xrange(poly.degree): roots.append(start ** e) while True: new = [] for i, r in enumerate(roots): new_r = r - (p...

C# Mathematics Calculation not working properly

OK, so I'm performing an annoying math computation here, trying to solve for one of the cubic roots. Now, here is my C# code: public void CubeCalculate() { //Calculate discriminant double insideSquareRoot = (18 * cubicAValue * cubicBValue * cubicCValue * cubicDValue) + (-4 * (Math.Pow(cubicBValue, 3) * cubicDValue) + (Math.Pow...