algorithm,cryptography,bit-shift,polynomial-math,ecdsa

There is no generic answer to this question: you can use portable code that will be tedious to optimize or highly machine specific code that will be even more complicated to optimize without breaking. If you want real performance, you have to use MMX/AVX registers on the maximum width you...

matrix,sympy,symbolic-math,polynomial-math

Since collect(expand(V), ...) already shows V as a linear polynomial in the variables v_1, theta_1, v_2, theta_2, instead of using V.match(form), perhaps an easier, more direct way to get the coefficients is to use the V.coeff method: N = sy.Matrix([V.coeff(v) for v in (v_1, theta_1, v_2, theta_2)]).transpose() import sympy as...

c#,unity3d,polynomial-math,unityscript,normals

Hm... Should be like this: public Vector3 normalAt (float x, float z) { float argument = Time.realtimeSinceStartup + x * frequency * transform.forward.x + z * frequency * transform.forward.z; float nx = amplitude * frequency * transform.forward.x * Mathf.Cos(argument); float ny = -1.0f; float nz = amplitude * frequency *...

You can extract the numerator and denominator with numden, then get their coefficiens with coeffs, normalize the polynomials, and divide again. [n,d] = numden(T); cn = coeffs(n); cd = coeffs(d); T = (n/cn(end))/(d/cd(end)); The output of latex(T) (note: no simplifyFraction now; it would undo things): Of course this isn't equal...

python,python-3.x,sympy,polynomial-math,gmpy

There are a few obstacles: gmpy.mpfr has no ._sympy_ method, so it will be converted to float in an intermediate step. sympy.Poly, by default, uses sympy.polys.domain.RR for floating point coefficients, and will use it to convert. RR, when it loads, uses 53 as its precision, and ignores mpmath.mp.precision. When converting,...

python,graph,matplotlib,polynomial-math

A simple way would be to look at the 'rate in change of y with respect to x', known as the derivative. This usually works better with continuous (smooth) functions, and so you could implement it with your data by interpolating your data with an n-th order polynomial as already...

python,polynomial-math,deflate

I think he cannot call the function deflPoly outside the function. Because it is of local scope. For ex: def a(): print 'a function' def b(): print 'b function' a().b() This should be error, because function a() returns None, If even some value for function a() returns, it has no...

java,linked-list,polynomial-math

The biggest thing I see here is your lack of handling properly the case where either of your current variables are null, in a manner that will prevent a NPE (as you've seen)... Your code, better formatted below has a couple issues regarding the handling of null while (current1 !=...

c++,polynomial-math,nonlinear-functions

This approach makes use of the bisection method, and the fact that you can do a little math to find an upper bound for the highest zero, respectively. Reproduced at http://ideone.com/fFLjsh #include <iostream> #include <iomanip> #include <cmath> #include <vector> #include <utility> #define MINX (-20.0f) //MAXX Happens to be an upper...

Assuming you know the number of possible variables beforehand, you could express each term like this: (constant x-exponent y-exponent z-exponent ...). Then 5xy^2 would be (5 1 2 0), and a full expression would just be a list of those terms. If you want to be able to handle any...

python,numpy,sympy,symbolic-math,polynomial-math

In SymPy this would be simply: from sympy.abc import x f = x**2 + 3*x + 2 g = f.subs({x:2/x}) Resulting in: print(g) #2 + 6/x + 4/x**2 ...

python,linux,ubuntu,polynomial-math

Although we write (35 x) in mathematics to implicitly mean (35 * x), the Python interpreter canâ€™t work this out. You need to tell it 35 * (x ** 4) explicitly. So you modify the function to include return 35 * (x ** 4) - 17 * (x ** 3)...

matlab,matrix,interpolation,polynomial-math

I would use diag and cumprod to help you accomplish this. First use diag to extract the diagonals of your matrix Q. After, use cumprod to generate a vector of cumulative products. How cumprod works on a vector is that for each element in the vector, the i'th element collects...

matlab,polynomial-math,exponentiation,finite-field,polynomials

Try this u = f; for i=1:t [q{i},r{i}] = deconv(f,h); f = conv(f,u); end Your answer for each power will be in the cell array r....

You seem to be saying that you're asked to write a function to multiply two polynomials, but the function is supposed to have just one parameter. This, indeed, doesn't make a lot of sense. You can always use a tuple to bundle any number of values into a single value,...

ios,objective-c,math,polynomial-math

I spend several days getting through the math and getting it in code because I couldn't find a math library for iOS with the function I needed. I wouldn't recommend anyone do to that again, it wasn't a walk in the park, so I published my solution on my github....

algorithm,sympy,polynomial-math,polynomials

This is pretty well studied, as mcdowella's comment indicates. Here is how the Cantor-Zassenhaus random algorithm works for the case where you want to find the roots of a polynomial, instead of the more general factorization. Note that in the ring of polynomials with coefficients mod p, the product x(x-1)(x-2)...(x-p+1)...

c,segmentation-fault,runtime-error,polynomial-math

I think the problem occurs because you haven't allocated any memory for coeff of polys before using poly->coeff[i]= /*something*/ I haven't checked your whole code yet. So I don't know what you were trying to do. Try allocating some memory using malloc before using coeff of polys....

python,function,loops,iteration,polynomial-math

Your profiling can be much improved. Plus, we can make your code run 200-500x faster. (1) Rinse and repeat You can't run just one iteration of a performance test, for two reasons. Your time resolution might not be good enough. This is why you sometimes got the same time for...

For this specific case (where f(0) is not a root of the equation), you can simply do the following: r=[5 6 18] p=poly(r) f0=-2 p=p*f0/polyval(p,0) %// just scaling p so that f(0)=-2 polyval(p,0) %// checking the answer But in general, you can use polyfit p2=polyfit([0 r],[-2 0 0 0],3) %//...

algorithm,math,language-agnostic,equation,polynomial-math

Solving several polynomial equations in several variables is a hard problem. Doing so in polynomial time in the average case is Smale's 17th problem. It is unlikely that you will find a fast and simple algorithm for doing so that actually works. You might look at "Ideals, varieties, and algorithms"...

java,math,trigonometry,polynomial-math,equation-solving

I had two mistakes. All my "integer constants" should have been in double. In the Wikipedia method, when the depressed quartic is biquadratic, we must reconvert the roots to the original quartic. I was returning the depressed roots. Here is my resulting implementation public class QuarticFunction { private static final...