+ 2

math module makes confusing!

>>> import math >>> math.cos(math.pi/2) 6.123233995736766e-17 >>> math.acos(0) 1.5707963267948966 >>> math.pi/2 1.5707963267948966 As I learn cos(pi/2) = 0 that means acos(0) = pi/2 why cos(pi/2) = 6.123233995736766e-17

7th Aug 2017, 3:07 PM
Seng Thai
Seng Thai - avatar
9 Respostas
+ 7
You could read up more in the python stuff on their documentationsfof each version. Search Python Documentation on Google
7th Aug 2017, 3:21 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
This actually *is* zero, with a floating-point accuracy! ;) https://en.m.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems
7th Aug 2017, 3:21 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
in advance,the PI representation is not real but it is also truncated with an appropriate accuracy and its half has less accuracy than in real.This is caused by mashine representation of decimal number(floating points operations).
7th Aug 2017, 3:33 PM
Highman
Highman - avatar
+ 1
Ahha! I got it @sayan chandra.
7th Aug 2017, 4:13 PM
Seng Thai
Seng Thai - avatar
0
here is it...check the output against each line of code... https://code.sololearn.com/cI1NCJ9BwpBA/?ref=app
7th Aug 2017, 3:30 PM
sayan chandra
sayan chandra - avatar
0
see this second verson of explaination @SENG THAI Red all the comments in code. https://code.sololearn.com/cCo62gBgC4kG/?ref=app
7th Aug 2017, 3:54 PM
sayan chandra
sayan chandra - avatar
0
@sayan chandra Thanks! But Why it shows up as exponential value. It is because it can not show all the floating number after ".", isn't it?
7th Aug 2017, 4:09 PM
Seng Thai
Seng Thai - avatar
0
of course.. exactly
7th Aug 2017, 4:10 PM
sayan chandra
sayan chandra - avatar
0
somewhere anyway u have to end... cause this floating points hav no end.. like 10 divided by 3....
7th Aug 2017, 4:11 PM
sayan chandra
sayan chandra - avatar