P
Pascal J. Bourguignon
Steven D'Aprano said:Which is why I said it was LIKE asking the second.
It's quite standard to discuss (say) sin(theta) where theta is an element
of â„. The fact that angles can extent to infinity in both directions is
kind of fundamental to the idea of saying that the trig functions are
periodic.
You're falling in a trap. It's costumary in mathematics to ellide the
trivial isomorphims. But they're still there.
When you're writing: 2+3.4 you have to use the trivial isomorphims
between â„• and the subset of â„ called 1.0â„•, let's call it t, so that when
you write: 2+3.4
you actually mean t(2)+3.4
with t(2) ∈ 1.0â„• ⊂ â„
3.4 ∈ â„
and + being the additive operator on â„ with 0.0 as neutral element.
Similarly, when you write sin(θ) with θ ∈ â„
what you actually mean is sin( angle-equivalence-class-of(θ) )
with angle-equivalence-class-of(θ) ∈ â„/2Ï€.
As a programmer, it should be obvious to you.
(defstruct angle
(representant 0.0 :type real))
(defun sinus (angle)
...)
(sinus 0.2) --> error
(sinus (make-angle :representant 0.2)) --> 0.19866933079506122
It just happen that
(defun cl:sin (representant)
(sinus (make-angle :representant representant)))
But this should not confuse you, nor the type checking.
Would it have been easier to understand if I had made the analogy between
angles and (say) time? A time of 1 minute and a time of 60 seconds are
the same time, regardless of what representation you use for it.
Yes, but time has a dimension (time), so you don't confuse it with
random numbers.