Operators
Operators
Clearing Memory | |
---|---|
1 2 3 |
|
Clearing Memory | |
---|---|
1 2 3 4 5 |
|
Clearing Memory | |
---|---|
1 2 3 4 5 6 |
|
Clearing Memory | |
---|---|
1 2 3 4 5 6 7 |
|
Exercise: \(0^0\)
Clear the workspace, program \(0^0\) and verify your results:
Code | |
---|---|
1 2 3 |
|
While in mathematical analysis, the expression \(0^0\) is sometimes left undefined, in algebra and combinatorics, one typically defines \(0^0 = 1\). In computer sciences, the standard answer is \(0^0 = 1\).
Exercise: \(x!\)
Clear the workspace, program the factorial value \(100!\):
Code | |
---|---|
1 2 3 |
|
Note that the mathematical symbol for factorial is given by \(x!\) whereas within the R language, !
operates as logical negation. The factorial is computed using the function factorial(100)
and equal to 9.332622e+157
.
Exercise: \(\pi\)
Clear the workspace, program the mathematical constant value \(\pi\):
Code | |
---|---|
1 2 3 |
|
Note that the mathematical symbol for factorial is given by \(x!\) whereas within the R language, !
operates as logical negation. The factorial is computed using the function factorial(100)
and equal to 9.332622e+157
.
Exercise: Exponential \(e^x\), and logarithmic function \(\log(x)\), \(\ln(x)\)
Clear the workspace, program the following:
- mathematical constant value \(e^1\),
- compute \(\log(e)\).
Code | |
---|---|
1 2 3 4 |
|
R language provides a default logarithmic fuction log()
operating as the natural logarithm. While there exists a short hand function log10(x)
to carry out the base-10 as a special case, more general cases can be defined via inputting an extended argument: log(x, base = 10)
.
Exercise: Price of a three-year bond
Clear the workspace, program the following which reflect the present value of a three-year 3% annual coupon bearing bond with the face value of $100 and a 5% market discount rate:
\(\frac{5}{1+5\%} + \frac{5}{(1+5\%)^2} + \frac{5}{(1+5\%)^3} + \frac{100}{(1+5\%)^3}\)
Code | |
---|---|
1 2 3 4 |
|
R language provides a default logarithmic fuction log()
operating as the natural logarithm. While there exists a short hand function log10(x)
to carry out the base-10 as a special case, more general cases can be defined via inputting an extended argument: log(x, base = 10)
.