What would you say is the difference between "fraction" and "rational number"?

(Context: teaching an intro programming course and we have an example class for...these things. The existing materials call it "Fraction", but somehow I feel like RationalNumber or Rational would be better, but I can't articulate why.)

(Further context: I haven't looked up *anything* about this. Taking a "ask the hivemind first, do actual thinking later" approach...)

@ddrake a rational number is an equivalence class for a set of fractions. If a and b are integers with b positive and such that the only divisor that a and b have in common is 1, then the rational number a/b is the canonical representative of the equivalence class for the fractions of the form ma/mb where m is a nonzero integer

@ddrake at least that is how I teach it.

Consider the set S=ZxZ^+ (the Cartesian product of the integers and the positive integers) and we define (p,q)~(p’,q’) if pq’=p’q.

This is an equivalence relation on S, an equivalence class consists of all equivalent fractions, the canonical representative for a given equivalence class is a rational number.

@mathematicalsynesthesia @ddrake Perhaps 'fraction' doesn't feel right for numbers like 2/1 and 'rational' would be better.

Usually fraction implies 'not a whole number', e.g. 1/3. (But 3/3 is a fraction and is equivalent to a whole number, so who knows?)

#fraction #math

@foldworks @mathematicalsynesthesia actually I think "fraction" is a good description for "2/1". It's true that the real number represented by those three symbols is an integer, but it seems like when you're writing something in the form a/b, you are, somehow, writing a fraction.

Of course this is kinda getting into the weeds with semantics, semiotics, conventions for writing such things, and so on...

@mathematicalsynesthesia @ddrake
"a rational number is an equivalence class for a set of fractions" - right, and more precisely a rational is a decimal, whereas fractions aren't decimals.

@ddrake

I agree that calling a (programming) class type 'Fractions' isn't great

A fraction is a way of writing numbers.

Fractions: 2/3, (pi+e)/log(2)

Not fractions: 7, 0.5

The rational numbers is a basically the smallest set of numbers that will let us deal with all the fractions of integers.

@ddrake

It depends on what kinds of things are allowed as the parts of the fraction. In general rational numbers are a proper subset of the set of fractions. For instance \sqrt{2}/2 is a perfectly good fraction but it's not rational. If the constraints of the context require the parts of the fraction to be whole numbers you can use the words fraction and rational number interchangeably, and the stuff about equivalence classes doesn't seem relevant. After all, we teach little kids about equivalent fractions many years before anyone tells them about equivalence relations.

This might be a pure-math-biased POV, though. I feel like your word "class" has some technical meaning I don't know.

@AdrianRiskin the sqrt(2)/2 example is good for something everyone would think is a fraction, but is not rational.

And yes, "class" here is the kind you have in object-oriented programming.

In that spirit, if the constructor or setters for such a class accept types other than integer, then Fraction is better -- you could pass in floats or complex numbers. Rational would do the type-checking for integer numerator and denominator.

Ooh now this is smelling like inheritance...but we're not doing that with my intro Python class. :)

@ddrake I would use the word "fraction" to denote a symbol consisting of two numerals and a fraction bar, whereas a rational number is the abstract thing that the fraction represents.

@mathematicalsynesthesia I think it'd be premature to say the rational numbers *are* the equivalence classes. At least, I don't think that's how most mathematicians think. (And we don't think of integers as equivalence classes of pairs of naturals either, and we don't think of naturals as finite transitive sets)

@aleph_omega_plus_four @ddrake i am a mathematician and that is how I think about it. Formally speaking that is how the integers and rational numbers are β€œunderstood”, if one wants to build the rational numbers via the Peano axioms.

The definition of rational number that I always use is: β€œa number is rational if it can be expressed as a/b with a an integer, b a positive integer and a and b coprime”. You need the coprime part to prove that square root of 2 is irrational via a simple contradiction, without using infinite descent

@mathematicalsynesthesia @ddrake

Formally speaking, sure, but we all learn what a rational number (viz integer) is in school, before formalising them. So personally I imagine rational numbers as being some position on a number line (which is not topologically complete). I think that's more common, but I haven't done a survey.

If you view the rationals via their construction your definition isn't necessary! The definition was already the set of equivalence classes with that relation.

@mathematicalsynesthesia

BTW you don't need the coprime part to be part of the definition of rational number, because you can prove if q = a/b then there are a', b' coprime such that q = a'/b'. (Just divide both by HCF, which exists by the fundamental theorem of arithmetic/Euclidean theorem/however you want to prove it)

Then, if you want to prove that sqrt(2) is irrational, you are free to assume a and b are coprime.

@aleph_omega_plus_four I was going to say something along those lines: that I'd say fraction if I am emphasizing the numerator and denominator, and rational number if that is not the focus. I might use them somewhat interchangeably, though. @ddrake @mathematicalsynesthesia
@aleph_omega_plus_four @ddrake @mathematicalsynesthesia I'd probably restrict fraction to cases where the numerator and denominator are integers. Something like 0.5 / 3 or √2 / 2 I think I'd call a quotient (or maybe other terminology)