Numpys Cosinus- und Sinusdomänen
Posted: 20 Feb 2025, 11:14
Ich verwende Numpys trigonometrische Funktionen und fand gerade etwas Faszinierendes: Ich weiß, dass die Sinus- und Cosinus -Funktionen eine unendliche Domäne haben, aber aus einigen Gründen np.cos () und np.sin ()
from numpy import pi
# Just in order to keep it simple
π = pi
def sin(x):
# If our angle is bigger than 360°
if x >= 2*π:
while x >= 2*π:
x -= 2*π
# If our angle is smaller than 0°
elif x < 0:
while x < 0:
x += 2*π
# If our angle is in [0, 2*π[ domain
return result
< /code>
Ist es etwas, das aus mathematischer Sicht nicht funktionieren würde? Warum?
from numpy import pi
# Just in order to keep it simple
π = pi
def sin(x):
# If our angle is bigger than 360°
if x >= 2*π:
while x >= 2*π:
x -= 2*π
# If our angle is smaller than 0°
elif x < 0:
while x < 0:
x += 2*π
# If our angle is in [0, 2*π[ domain
return result
< /code>
Ist es etwas, das aus mathematischer Sicht nicht funktionieren würde? Warum?