5 changed files with 130 additions and 22 deletions
@ -0,0 +1,100 @@ |
|||||||
|
{ |
||||||
|
"cells": [ |
||||||
|
{ |
||||||
|
"outputs": [], |
||||||
|
"cell_type": "markdown", |
||||||
|
"source": [ |
||||||
|
"# Rational numbers\n", |
||||||
|
"\n", |
||||||
|
"In julia rational numbers can be constructed with the `//` operator.\n", |
||||||
|
"Lets define two rational numbers, `x` and `y`:" |
||||||
|
], |
||||||
|
"metadata": {} |
||||||
|
}, |
||||||
|
{ |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"output_type": "execute_result", |
||||||
|
"data": { |
||||||
|
"text/plain": "1//3" |
||||||
|
}, |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 1 |
||||||
|
} |
||||||
|
], |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"x = 1//3" |
||||||
|
], |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 1 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"output_type": "execute_result", |
||||||
|
"data": { |
||||||
|
"text/plain": "2//5" |
||||||
|
}, |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 2 |
||||||
|
} |
||||||
|
], |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"y = 2//5" |
||||||
|
], |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 2 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"outputs": [], |
||||||
|
"cell_type": "markdown", |
||||||
|
"source": [ |
||||||
|
"When adding `x` and `y` together we obtain a new rational number:" |
||||||
|
], |
||||||
|
"metadata": {} |
||||||
|
}, |
||||||
|
{ |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"output_type": "execute_result", |
||||||
|
"data": { |
||||||
|
"text/plain": "11//15" |
||||||
|
}, |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 3 |
||||||
|
} |
||||||
|
], |
||||||
|
"cell_type": "code", |
||||||
|
"source": [ |
||||||
|
"z = x + y" |
||||||
|
], |
||||||
|
"metadata": {}, |
||||||
|
"execution_count": 3 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"outputs": [], |
||||||
|
"cell_type": "markdown", |
||||||
|
"source": [ |
||||||
|
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" |
||||||
|
], |
||||||
|
"metadata": {} |
||||||
|
} |
||||||
|
], |
||||||
|
"nbformat_minor": 3, |
||||||
|
"metadata": { |
||||||
|
"language_info": { |
||||||
|
"file_extension": ".jl", |
||||||
|
"mimetype": "application/julia", |
||||||
|
"name": "julia", |
||||||
|
"version": "0.6.2" |
||||||
|
}, |
||||||
|
"kernelspec": { |
||||||
|
"name": "julia-0.6", |
||||||
|
"display_name": "Julia 0.6.2", |
||||||
|
"language": "julia" |
||||||
|
} |
||||||
|
}, |
||||||
|
"nbformat": 4 |
||||||
|
} |
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,12 @@ |
|||||||
|
#' # Rational numbers |
||||||
|
#' |
||||||
|
#' In julia rational numbers can be constructed with the `//` operator. |
||||||
|
#' Lets define two rational numbers, `x` and `y`: |
||||||
|
|
||||||
|
x = 1//3 |
||||||
|
#- |
||||||
|
y = 2//5 |
||||||
|
|
||||||
|
#' When adding `x` and `y` together we obtain a new rational number: |
||||||
|
|
||||||
|
z = x + y |
||||||
Loading…
Reference in new issue