I suspect that this is because your initial array was typed to only contain integer values. I would write this as:
julia> using Polynomials julia> p = Poly([1,2,3]) julia> p / p[end] divide(p::Poly) = p / p[end] On Mon, May 19, 2014 at 5:26 PM, Albert Díaz <[email protected]> wrote: > I don't think it is an integer because when you create the array you can > assign float coefficients to each term in the Polynomial. > > El lunes, 19 de mayo de 2014 20:56:54 UTC+2, Tim Holy escribió: >> >> What's the element type of p? If it's an integer type, there's your >> problem. >> >> --Tim >> >> On Monday, May 19, 2014 10:32:38 AM Albert Díaz wrote: >> > I'm designing a function to, given a p Polynomial, divide the >> > coefficient >> > of each of its terms by the one in the first term. >> > >> > function divide(p) >> > >> > >> > red=p[1] >> > >> > >> > for j=1:length(p) >> > >> > >> > p[j]=p[j]/red >> > >> > >> > >> > >> > >> > end >> > >> > >> > return p >> > >> > >> > end >> > >> > >> > It used to work, but now, if the result in p[j]/red is not a whole >> > number, >> > it throws me an InexactError(). However, if p[j]/red is a whole number, >> > I >> > have no problems in reassigning the coefficient of p[j]. >> > >> > >> > Why does that happen and how can I solve it?
