Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
math problem for experts
#1
While testing python code to rotate 3d points, I tried:

cos_ = np.cos((90.0/360.0) * (2.0*np.pi))

cos(90) was reported as 6.123234e-17, instead of correct value of zero.

tried both math.pi and numpy.pi with same result

os = windows 10, cpu = Intel i5-7200U
python = 3.8.10 provided by anaconda spyder 5.4.3

The same behavior occurred on Linux Mint os, using python 3.8.10 provided by anaconda spyder 4.5.3, cpu = AMD whatever

A simple c program compiled by gcc and executed on the Linux machine reported cos(90) as zero.

What causes this problem? What can be done about it?
Reply


Messages In This Thread
math problem for experts - by miltmobley - Jul-08-2023, 08:24 PM
RE: math problem for experts - by jefsummers - Jul-08-2023, 10:12 PM
RE: math problem for experts - by deanhystad - Jul-08-2023, 11:13 PM
RE: math problem for experts - by miltmobley - Jul-09-2023, 12:50 AM
RE: math problem for experts - by deanhystad - Jul-09-2023, 02:16 AM
RE: math problem for experts - by Gribouillis - Jul-09-2023, 07:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  math.log versus math.log10 stevendaprano 10 2,498 May-23-2022, 08:59 PM
Last Post: jefsummers
  Why getting ValueError : Math domain error in trig. function, math.asin() ? jahuja73 3 3,836 Feb-24-2021, 05:09 PM
Last Post: bowlofred
  Problem with the math.sin(x) function Carson147 4 2,994 Feb-21-2019, 05:12 PM
Last Post: Carson147
  matrices math problem lokoprof 1 2,239 Aug-27-2018, 07:48 PM
Last Post: perfringo
  Math problem python Dhaval 1 2,965 Jun-05-2017, 10:28 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020