Re: python math problem

2013-02-16 Thread Dave Angel
On 02/16/2013 08:55 AM, Nobody wrote: On Fri, 15 Feb 2013 11:47:33 -0800, Gary Herron wrote: Floating point calculations on a computer (ANY computer, and ANY programming language) can *never* be expected to be exact! "never" is incorrect. There are many floating-point calculations which can r

Re: python math problem

2013-02-16 Thread Roy Smith
In article , Nobody wrote: > IOW: floating-point arithmetic is deterministic. It follows rules. Not the > same rules as real arithmetic, but rules nonetheless. Contrary to > common superstition, the least-significant bits are *not* taken from > /dev/random. Unless you're using a Pentium :-) --

Re: python math problem

2013-02-16 Thread Chris Angelico
On Sun, Feb 17, 2013 at 12:55 AM, Nobody wrote: > Furthermore, any such calculation for which the correct answer isn't > exactly representable should produce the same result as if the correct > answer had been calculated to an infinite number of digits then rounded to > the nearest representable v

Re: python math problem

2013-02-16 Thread Nobody
On Fri, 15 Feb 2013 11:47:33 -0800, Gary Herron wrote: > Floating point calculations on a computer (ANY computer, and ANY > programming language) can *never* be expected to be exact! "never" is incorrect. There are many floating-point calculations which can reasonably be expected be exact[2].

Re: python math problem

2013-02-15 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > Classical CompSci teachings when working with floating point numbers > is to NEVER compare for equality. Instead one should compare against > some epsilon: "Don't compare floats for equality" is reasonably good advice. Adding "never" to that advice, especially when sho

Re: python math problem

2013-02-15 Thread John Machin
On Feb 16, 6:39 am, Kene Meniru wrote: > x = (math.sin(math.radians(angle)) * length) > y = (math.cos(math.radians(angle)) * length) A suggestion about coding style: from math import sin, cos, radians # etc etc x = sin(radians(angle)) * length y = cos(radians(angle)) * length ... easier to wri

Re: python math problem

2013-02-15 Thread Kene Meniru
Joel Goldstick wrote: > > This is not a string, it is scientific notion for 1.53... times 10 to the > -15th power. Because of rounding errors caused by doing floating point > math on in binary, you get a very small number instead of 0. > I was just doing some testing and it was not equating to

Re: python math problem

2013-02-15 Thread Kene Meniru
Bob Brusa wrote: > Kene, > are you sure your length is 120? It seems to be 25. I did these > calculations with length = 25 and then your numbers make perfect sense. > Bob Thanks. You are right I was actually using 25 -- Kene :: kemen...@gmail.com -- http://mail.python.org/mai

Re: python math problem

2013-02-15 Thread Bob Brusa
Am 15.02.2013 20:39, schrieb Kene Meniru: I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are s

Re: python math problem

2013-02-15 Thread Joel Goldstick
On Fri, Feb 15, 2013 at 2:39 PM, Kene Meniru wrote: > I am trying to calculate the coordinates at the end of a line. The length > and angle of the line are given and I am using the following formula: > > x = (math.sin(math.radians(angle)) * length) > y = (math.cos(math.radians(angle)) * length) >

Re: python math problem

2013-02-15 Thread Gary Herron
On 02/15/2013 11:39 AM, Kene Meniru wrote: I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are

python math problem

2013-02-15 Thread Kene Meniru
I am trying to calculate the coordinates at the end of a line. The length and angle of the line are given and I am using the following formula: x = (math.sin(math.radians(angle)) * length) y = (math.cos(math.radians(angle)) * length) The following are sample answers in the format (x, y) to the g