On 02/26/2013 04:34 PM, Rupert Swarbrick wrote:
> Jaime Villate <villate at fe.up.pt> writes:
>> Good point. Also, in Rupert's chop function a value of -%i*3000 would
>> be chopped when compared to eps=1e-8.
> Oops! I've just given an undergrad support class on the mean value
> theorem and made basically the same error about half an hour in. Maybe I
> should just start sticking absolute value signs around everything I
> write as a matter of principle...
Well, your error was very minor compared to mine (division by zero) :)
As Daniel Lakeland has kindly showed me, a better solution is:
chop (x, epsrel,epsabs) := if is (abs(imagpart (x)) < epsrel *
abs(realpart(x)) or abs(realpart(x)) = 0 and abs(imagpart(x)) <
epsabs)then realpart (x) else x$
Regards,
Jaime