section_path: Types/Rational number arithmetic
section_name: Rational number arithmetic
paragraph_text: Rational number arithmetic
  
  Rational number arithmetic is the branch of arithmetic that deals with the manipulation of numbers that can be expressed as a ratio of two integers. Most arithmetic operations on rational numbers can be calculated by performing a series of integer arithmetic operations on the numerators and the denominators of the involved numbers. If two rational numbers have the same denominator then they can be added by adding their numerators and keeping the common denominator. For example, 2 7 + 3 7 = 5 7 {\displaystyle {\tfrac {2}{7}}+{\tfrac {3}{7}}={\tfrac {5}{7}}}. A similar procedure is used for subtraction. If the two numbers do not have the same denominator then they must be transformed to find a common denominator. This can be achieved by scaling the first number with the denominator of the second number while scaling the second number with the denominator of the first number. For instance, 1 3 + 1 2 = 1 ⋅ 2 3 ⋅ 2 + 1 ⋅ 3 2 ⋅ 3 = 2 6 + 3 6 = 5 6 {\displaystyle {\tfrac {1}{3}}+{\tfrac {1}{2}}={\tfrac {1\cdot 2}{3\cdot 2}}+{\tfrac {1\cdot 3}{2\cdot 3}}={\tfrac {2}{6}}+{\tfrac {3}{6}}={\tfrac {5}{6}}}.
  
  Two rational numbers are multiplied by multiplying their numerators and their denominators respectively, as in 2 3 ⋅ 2 5 = 2 ⋅ 2 3 ⋅ 5 = 4 15 {\displaystyle {\tfrac {2}{3}}\cdot {\tfrac {2}{5}}={\tfrac {2\cdot 2}{3\cdot 5}}={\tfrac {4}{15}}}. Dividing one rational number by another can be achieved by multiplying the first number with the reciprocal of the second number. This means that the numerator and the denominator of the second number change position. For example, 3 5: 2 7 = 3 5 ⋅ 7 2 = 21 10 {\displaystyle {\tfrac {3}{5}}:{\tfrac {2}{7}}={\tfrac {3}{5}}\cdot {\tfrac {7}{2}}={\tfrac {21}{10}}}. Unlike integer arithmetic, rational number arithmetic is closed under division as long as the divisor is not 0.
  
  Both integer arithmetic and rational number arithmetic are not closed under exponentiation and logarithm. One way to calculate exponentiation with a fractional exponent is to perform two separate calculations: one exponentiation using the numerator of the exponent followed by drawing the nth root of the result based on the denominator of the exponent. For example, 5 2 3 = 5 2 3 {\displaystyle 5^{\frac {2}{3}}={\sqrt{5^{2}}}}. The first operation can be completed using methods like repeated multiplication or exponentiation by squaring. One way to get an approximate result for the second operation is to employ Newton's method, which uses a series of steps to gradually refine an initial guess until it reaches the desired level of accuracy. The Taylor series or the continued fraction method can be utilized to calculate logarithms.
  
  The decimal fraction notation is a special way of representing rational numbers whose denominator is a power of 10. For instance, the rational numbers 1 10 {\displaystyle {\tfrac {1}{10}}}, 371 100 {\displaystyle {\tfrac {371}{100}}}, and 44 10000 {\displaystyle {\tfrac {44}{10000}}} are written as 0.1, 3.71, and 0.0044 in the decimal fraction notation. Modified versions of integer calculation methods like addition with carry and long multiplication can be applied to calculations with decimal fractions. Not all rational numbers have a finite representation in the decimal notation. For example, the rational number 1 3 {\displaystyle {\tfrac {1}{3}}} corresponds to 0.333... with an infinite number of 3s. The shortened notation for this type of repeating decimal is 0. 3. Every repeating decimal expresses a rational number.