# Re: Why is there a seperate Math class?

**URL:** <https://www.ruby-forum.com/t/re-why-is-there-a-seperate-math-class/81550>\
**Category:** Ruby\
**Created:** [January 9, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/re-why-is-there-a-seperate-math-class/81550 "2007-01-09T21:38:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [January 9, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/re-why-is-there-a-seperate-math-class/81550/1 "2007-01-09T21:38:46Z")

</div>

From: Ilmari H. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

> On 1/9/07, Phrogz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > In addition to the answers by others, what would you do for those  
> > math  
> > functions whose arity isn’t 1?
> > 
> > Math.methods(false).select{ |n| Math.method(n).arity != 1 }  
> > #=\> [“hypot”, “atan2”, “ldexp”]
> > 
> > All three take two arguments. While 3.hypot(4) _might_ make  
> > sense–given one leg of a right triangle, how long is the hypotenuse  
> > to  
> > a given other leg–30.atan2( 40 ) makes little sense to me.
> 
> hypot and atan are vector methods, so [30, 40].atan2, [3,4].hypot  
> would be correct in the OO-sense, much like #max and #min are in Array  
> and not Math (compare to e.g. JavaScript where there is Math.max and  
> Math.min)

Good argument. In fact, one of them is there already:  
require ‘matrix’  
Vector[3,4].r #=\> 5.0

---

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [January 9, 2007, 11:01pm UTC](https://www.ruby-forum.com/t/re-why-is-there-a-seperate-math-class/81550/2 "2007-01-09T23:01:11Z")

</div>

> Good argument. In fact, one of them is there already:  
> require ‘matrix’  
> Vector[3,4].r #=\> 5.0

Gavin -

Just wanted to point out to you that each of your replies is creating a  
new thread. You might want to reply with the same subject to avoid this.  
Just thought you’d like to know.

-Drew
