| 1 |
<html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 |
<title>Formulas 1.2. Numeric expressions</title> |
| 3 |
<style> |
| 4 |
td { padding-left: 5pt; padding-right: 5pt; } |
| 5 |
th { padding-left: 5pt; padding-right: 5pt; } |
| 6 |
code { white-space: pre-wrap; } |
| 7 |
dd { white-space: pre-wrap; } |
| 8 |
</style> |
| 9 |
</head><body bgcolor="#FFFFFF"> |
| 10 |
|
| 11 |
<table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 |
Formulas 1.2. Numeric expressions |
| 13 |
</b></font></table></table> |
| 14 |
<p>All the formulas whose outcome is a number are called numeric expressions. For the following examples, all the outcomes can be checked with the <a href="Calculator.html">calculator</a>.</p> |
| 15 |
<h2>Examples with numbers</h2> |
| 16 |
<p>Some numeric expressions involve numbers only:</p> |
| 17 |
<dl> |
| 18 |
<dt><b>8*17</b> |
| 19 |
<dd>computes a multiplication. Outcome: 136.</dd> |
| 20 |
<dt><b>2^10</b> |
| 21 |
<dd>computes the tenth power of 2. Outcome: 1024.</dd> |
| 22 |
<dt><b>sqrt (2) / 2</b> |
| 23 |
<dd>computes the square root of 2, and divides the result by 2. Outcome: 0.7071067811865476.</dd> |
| 24 |
<dt><b>sin (1/4 * pi)</b> |
| 25 |
<dd>computes the sine of <i>π</i>/4. Outcome: 0.7071067811865476 (again).</dd> |
| 26 |
</dl> |
| 27 |
<h2>Examples with strings</h2> |
| 28 |
<p>Some numeric expressions compute numeric properties of strings:</p> |
| 29 |
<dl> |
| 30 |
<dt><b>length ("internationalization")</b> |
| 31 |
<dd>computes the length of the string "internationalization". Outcome: 20.</dd> |
| 32 |
<dt><b>index ("internationalization", "ation")</b> |
| 33 |
<dd>computes the location of the first occurrence of the string "ation" in the string "internationalization". Outcome: 7, because the first letter of "ation" lines up with the seventh letter of "internationalization". If the substring does not occur, the outcome is 0.</dd> |
| 34 |
</dl> |
| 35 |
<h2>Examples with arrays</h2> |
| 36 |
<p>Some numeric expressions compute numeric properties of numeric vectors:</p> |
| 37 |
<dl> |
| 38 |
<dt><b>size ({ 40, 70, 60, 50 })</b> |
| 39 |
<dd>computes the length of the vector { 40, 70, 60, 50 }, i.e. the number of its elements. Outcome: 4.</dd> |
| 40 |
<dt><b>mean ({ 40, 70, 60, 50 })</b> |
| 41 |
<dd>computes the mean of the four numbers 40, 70, 60 and 50. Outcome: 55.</dd> |
| 42 |
</dl> |
| 43 |
<h3>Links to this page</h3> |
| 44 |
<ul> |
| 45 |
<li><a href="Formulas.html">Formulas</a> |
| 46 |
<li><a href="Formulas_1__My_first_formulas.html">Formulas 1. My first formulas</a> |
| 47 |
</ul> |
| 48 |
<hr> |
| 49 |
<address> |
| 50 |
<p>© ppgb 20170916</p> |
| 51 |
</address> |
| 52 |
</body> |
| 53 |
</html> |