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?

Reply via email to