# Khan/khan-exercises

### Subversion checkout URL

You can clone with
or
.
Fetching contributors…

Cannot retrieve contributors at this time

160 lines (143 sloc) 9.181 kB
 Adding and subtracting mixed numbers with unlike denominators
randRangeNonZero( -1, 1 ) ( PM === 1 ? "+" : "-") randRange( 2, 19 ) ( PM === 1 ? randRange( 1, 19 ) : randRange( -W1 + 1, -1 ))
randRange( 3, 20 ) randRange( 3, 20 )
randRange( 1, D1 - 1 ) randRange( 1, D2 - 1 )
getGCD( N1, D1 ) N1 / GCD1 D1 / GCD1 getGCD( N2, D2 ) N2 / GCD2 D2 / GCD2 getLCM( SIMP_D1, SIMP_D2 ) getGCD( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2 , LCM )

expr(["+", W1 + fraction( N1, D1 ), W2 + fraction( N2, D2 )]) = {?}

W1 + W2 + N1 / D1 + PM * N2 / D2

Separate the whole numbers from the fractional parts:

= \blue{W1} + \blue{fraction( N1, D1 )} SIGN \pink{abs( W2 )} SIGN \pink{fraction( N2, D2 )}

Bring the whole numbers together and the fractions together:

= \blue{W1} SIGN \pink{abs( W2 )} + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

=W1 + W2 + \blue{fraction( N1, D1 )} SIGN \pink{fraction( N2, D2 )}

Simplify each fraction:

= W1+W2 + \blue{fraction( SIMP_N1, SIMP_D1 )} SIGN \pink{fraction( SIMP_N2, SIMP_D2 )}

Find a common denominator for the fractions:

= expr(["+", W1 + W2, fraction( SIMP_N1 * LCM / SIMP_D1, LCM ),fraction( PM * SIMP_N2 * LCM / SIMP_D2, LCM )])

= expr(["+", W1 + W2, fraction( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2, LCM )])

Combine the whole and fractional parts into a mixed number:

= W1 + W2 + fraction( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2, LCM )

Simplify to lowest terms:

= W1 + W2 + fractionReduce( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2, LCM )

-1 "-" randRange( 2, 19 ) randRange( -W1 + 1, -1 )
randRange( 3, 20 ) randRange( 3, 20 )
randRange( 1, D1 - 1 ) randRange( 1, D2 - 1 )
getGCD( N1, D1 ) N1 / GCD1 D1 / GCD1 getGCD( N2, D2 ) N2 / GCD2 D2 / GCD2 getLCM( SIMP_D1, SIMP_D2 ) getGCD( SIMP_N1 * LCM / SIMP_D1 + PM * SIMP_N2 * LCM / SIMP_D2 , LCM )

expr(["+", W1 + 1 + fraction( N1, D1 ), W2 + fraction( N2, D2 )]) = {?}

W1 + 1 + W2 + N1 / D1 + PM * N2 / D2

Simplify each fraction.

= \blue{W1 + 1fraction( SIMP_N1, SIMP_D1 )} SIGN \pink{abs( W2 )fraction( SIMP_N2, SIMP_D2 )}

Find a common denominator for the fractions:

= \blue{W1 + 1fraction( SIMP_N1 * LCM / SIMP_D1, LCM )}SIGN\pink{abs( W2 )fraction( SIMP_N2 * LCM / SIMP_D2, LCM )}

Convert \blue{W1 + 1fraction( SIMP_N1 * LCM / SIMP_D1, LCM)} to \blue{ W1 + fraction( LCM, LCM) + fraction( SIMP_N1 * LCM / SIMP_D1, LCM)}.

So the problem becomes:

\blue{W1fraction( LCM + SIMP_N1 * LCM / SIMP_D1, LCM)}SIGN\pink{abs( W2 )fraction( SIMP_N2 * LCM / SIMP_D2, LCM)}

Separate the whole numbers from the fractional parts:

= \blue{W1} + \blue{fraction( LCM + SIMP_N1 * LCM / SIMP_D1, LCM )} SIGN \pink{abs( W2 )} SIGN \pink{fraction( SIMP_N2 * LCM / SIMP_D2, LCM)}

Bring the whole numbers together and the fractions together:

= \blue{W1} SIGN \pink{abs( W2 )} + \blue{fraction( LCM + SIMP_N1 * LCM / SIMP_D1, LCM )} SIGN \pink{fraction( SIMP_N2 * LCM / SIMP_D2, LCM )}

=W1 + W2 + \blue{fraction( LCM + SIMP_N1 * LCM / SIMP_D1, LCM )} SIGN \pink{fraction( SIMP_N2 * LCM / SIMP_D2, LCM)}
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://github.com/Khan/khan-exercises/blob/out-of-date/exercises/adding_subtracting_mixed_numbers_1.html", "fetch_time": 1436317805000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2015-27/segments/1435375635143.91/warc/CC-MAIN-20150627032715-00067-ip-10-179-60-89.ec2.internal.warc.gz", "warc_record_offset": 1015981395, "warc_record_length": 12545, "token_count": 1324, "char_count": 3234, "score": 3.703125, "int_score": 4, "crawl": "CC-MAIN-2015-27", "snapshot_type": "latest", "language": "en", "language_score": 0.38759806752204895, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00019-of-00064.parquet"}