瀏覽代碼

minor changes to format

Rafael Arce Nazario 9 年之前
父節點
當前提交
b43cf2b6eb
共有 1 個文件被更改,包括 74 次插入95 次删除
  1. 74
    95
      README.md

+ 74
- 95
README.md 查看文件

@@ -56,7 +56,7 @@ Antes de llegar al laboratorio  debes:
56 56
 ##Funciones
57 57
 
58 58
 
59
-En matemática, una función $f$ es una regla que se usa para asignar a cada elemento $x$ de un conjunto que se llama *dominio*, uno (y solo un) elemento $y$ de un conjunto que se llama *campo de valores*. Por lo general, esa regla se representa como una ecuación, $y=f(x)$. La variable $x$ es el parámetro de la función y la variable $y$ contendrá el resultado de la función. Una función puede tener más de un parámetro pero solo un resultado. Por ejemplo, una función puede tener la forma $y=f(x_1,x_2)$ en donde hay dos parámetros y para cada par $(a,b)$ que se use como argumento de la función, la función tiene un solo valor de $y=f(a,b)$. El dominio de la función te dice el tipo de valor que debe tener el parámetro y el campo de valores el tipo de valor que tendrá el resultado que devuelve la función.
59
+En matemática, una función $$f$$ es una regla que se usa para asignar a cada elemento $$x$$ de un conjunto que se llama *dominio*, uno (y solo un) elemento $$y$$ de un conjunto que se llama *campo de valores*. Por lo general, esa regla se representa como una ecuación, $$y=f(x)$$. La variable $$x$$ es el parámetro de la función y la variable $$y$$ contendrá el resultado de la función. Una función puede tener más de un parámetro pero solo un resultado. Por ejemplo, una función puede tener la forma $$y=f(x_1,x_2)$$ en donde hay dos parámetros y para cada par $$(a,b)$$ que se use como argumento de la función, la función tiene un solo valor de $$y=f(a,b)$$. El dominio de la función te dice el tipo de valor que debe tener el parámetro y el campo de valores el tipo de valor que tendrá el resultado que devuelve la función.
60 60
 
61 61
 Las funciones en lenguajes de programación de computadoras son similares. Una función 
62 62
 tiene una serie de instrucciones que toman los valores asignados a los parámetros y realiza alguna tarea. En C++ y en algunos otros lenguajes de programación,  las funciones solo pueden devolver un resultado, tal y como sucede en matemáticas. La única diferencia es que una función en programación puede que no devuelva valor (en este caso la función se declara `void`). Si la función va a devolver algún valor, se hace con la instrucción `return`. Al igual que en matemática tienes que especificar el dominio y el campo de valores, en programación tienes que especificar los tipos de valores que tienen los parámetros y el resultado que devuelve la función; esto lo haces al declarar la función.
@@ -69,7 +69,9 @@ La primera oración de una función se llama el *encabezado* y su estructura es
69 69
 
70 70
 Por ejemplo,
71 71
 
72
-`int ejemplo(int var1, float var2, char &var3)`
72
+```cpp
73
+int ejemplo(int var1, float var2, char &var3)
74
+```
73 75
 
74 76
 sería el encabezado de la función llamada `ejemplo`, que devuelve un valor entero. La función recibe como argumentos un valor entero (y guardará una copia en `var1`), un valor de tipo `float` (y guardará una copia en `var2`) y la referencia a una variable de tipo  `char` que se guardará en la variable de referencia `var3`. Nota que `var3` tiene el signo `&` antes del nombre de la variable. Esto indica que `var3` contendrá la referencia a un caracter.
75 77
 
@@ -77,18 +79,23 @@ sería el encabezado de la función llamada `ejemplo`, que devuelve un valor ent
77 79
 
78 80
 Si queremos guardar el valor del resultado de la función `ejemplo` en la variable `resultado` (que deberá ser de tipo entero), invocamos la función pasando argumentos de manera similar a:
79 81
 
80
-`resultado=ejemplo(2, 3.5, unCar);`
82
+```cpp
83
+resultado = ejemplo(2, 3.5, unCar);
84
+```
81 85
 
82 86
 Nota que al invocar funciones no incluyes el tipo de las variables en los argumentos. Como en la definición de la función `ejemplo` el tercer parámetro `&var3` es una variable de referencia, lo que se está enviando en el tercer argumento de la invocación es una *referencia* a la variable `unCar`. Los cambios que se hagan en la variable `var3` están cambiando el contenido de la variable `unCar`.
83 87
 
84 88
 También puedes usar el resultado de la función sin tener que guardarlo en una variable. Por ejemplo puedes imprimirlo:
85 89
 
86
-`cout << "El resultado de la función ejemplo es:" << ejemplo(2, 3.5, unCar);`
90
+```cpp
91
+cout << "El resultado de la función ejemplo es:" << ejemplo(2, 3.5, unCar);
92
+```
87 93
 
88 94
 o utilizarlo en una expresión aritmética:
89 95
 
90
-`y=3 + ejemplo(2, 3.5, unCar);`
91
-
96
+```
97
+y = 3 + ejemplo(2, 3.5, unCar);
98
+```
92 99
 
93 100
 
94 101
 
@@ -99,7 +106,7 @@ La firma de una función se compone del nombre de la función, y los tipos de pa
99 106
 
100 107
 Los siguientes prototipos de funciones tienen la misma firma:
101 108
 
102
-```
109
+```cpp
103 110
 int ejemplo(int, int) ;
104 111
 void ejemplo(int, int) ; 
105 112
 string ejemplo(int, int) ;
@@ -109,7 +116,7 @@ Nota que todas tienen el mismo nombre, `ejemplo`, y reciben la misma cantidad de
109 116
 
110 117
 Los siguientes prototipos de  funciones tienen firmas diferentes:
111 118
 
112
-```
119
+```cpp
113 120
 int ejemplo(int) ;
114 121
 int olpmeje(int) ;
115 122
 ```
@@ -117,7 +124,7 @@ Nota que a pesar de que las funciones tienen la misma cantidad de parámetros co
117 124
 
118 125
 Los siguientes prototipos de funciones son versiones sobrecargadas de la función `ejemplo`:
119 126
 
120
-```
127
+```cpp
121 128
 int ejemplo(int) ;
122 129
 void ejemplo(char) ;
123 130
 int ejemplo(int, int) ;
@@ -174,52 +181,49 @@ Se pueden asignar valores por defecto ("default") a los parámetros de las funci
174 181
 2. `int ejemplo(int var1=1, float var2, int var3=10)` Este encabezado es inválido porque no se pueden poner parámetros sin valores en medio de parámetros con valores por defecto. En este caso  `var2` no tiene valor pero `var1` y `var3` si.
175 182
 
176 183
 
177
-
178
----
179
-
180 184
 ---
181 185
 
182 186
 ##Ecuaciones paramétricas
183 187
 
184
-Las *ecuaciones paramétricas* nos permiten representar una cantidad como función de una o más variables independientes llamadas *parámetros*. En muchas ocasiones resulta útil representar curvas utilizando un conjunto de ecuaciones paramétricas que expresen las coordenadas de los puntos de la curva como funciones de los parámetros. Por ejemplo, en tu curso de trigonometría debes haber estudiado que la ecuación de un círculo con radio $r$ y centro en el origen tiene una forma así: 
188
+Las *ecuaciones paramétricas* nos permiten representar una cantidad como función de una o más variables independientes llamadas *parámetros*. En muchas ocasiones resulta útil representar curvas utilizando un conjunto de ecuaciones paramétricas que expresen las coordenadas de los puntos de la curva como funciones de los parámetros. Por ejemplo, en tu curso de trigonometría debes haber estudiado que la ecuación de un círculo con radio $$r$$ y centro en el origen tiene una forma así: 
185 189
 
186 190
 $$x^2+y^2=r^2.$$
187 191
 
188 192
 
189
-Los puntos $(x,y)$ que satisfacen esta ecuación son los puntos que forman el círculo de radio $r$ y centro en el origen.  Por ejemplo, el círculo con $r=2$ y centro en el origen tiene ecuación
193
+Los puntos $$(x,y)$$ que satisfacen esta ecuación son los puntos que forman el círculo de radio $$r$$ y centro en el origen.  Por ejemplo, el círculo con $$r=2$$ y centro en el origen tiene ecuación
190 194
 
191 195
 $$x^2+y^2=4,$$
192 196
 
193
-y sus puntos son los pares ordenados $(x,y)$ que satisfacen esa ecuación. Una forma paramétrica de expresar las coordenadas de los puntos del círculo con radio $r$ y centro en el origen es: 
197
+y sus puntos son los pares ordenados $$(x,y)$$ que satisfacen esa ecuación. Una forma paramétrica de expresar las coordenadas de los puntos del círculo con radio $$r$$ y centro en el origen es: 
194 198
 
195 199
 $$x=r \cos(t)$$
196 200
 
197 201
 $$y=r \sin(t),$$
198 202
 
199
-donde $t$ es un parámetro que corresponde a la medida (en radianes) del ángulo positivo con lado inicial que coincide con la parte positiva del eje de $x$, y lado terminal que contiene el punto $(x,y)$, como se muestra en la Figura 1.
203
+donde $$t$$ es un parámetro que corresponde a la medida (en radianes) del ángulo positivo con lado inicial que coincide con la parte positiva del eje de $$x$$, y lado terminal que contiene el punto $$(x,y)$$, como se muestra en la Figura 1.
200 204
 
201 205
 
202 206
 ---
203 207
 
204 208
 ![circulo.jpg](images/circulo.jpg)
205 209
 
206
-<b>Figura 1.</b> Círculo con centro en el origen y radio $r$.
210
+<b>Figura 1.</b> Círculo con centro en el origen y radio $$r$$.
207 211
 
208 212
 
209 213
 ---
210 214
 
211
-Para graficar una curva que está definida usando ecuaciones paramétricas, computamos los valores de $x$ y $y$ para un conjunto de valores del parámetro. Por ejemplo, para $r = 2$, algunos de los valores son
215
+Para graficar una curva que está definida usando ecuaciones paramétricas, computamos los valores de $$x$$ y $$y$$ para un conjunto de valores del parámetro. Por ejemplo, para $$r = 2$$, algunos de los valores son
212 216
 
213 217
 ---
214 218
 
215
-| $t$ | $x$ | $y$ |
219
+| $$t$$ | $$x$$ | $$y$$ |
216 220
 |-----|-----|-----|
217
-| $0$ | $2$ | $0$ |
218
-| $\frac{\pi}{4}$ | $\frac{\sqrt{2}}{2}$ | $\frac{\sqrt{2}}{2}$ |
219
-| $\frac{\pi}{2}$ | $0$ | $2$ |
221
+| $$0$$ | $$2$$ | $$0$$ |
222
+| $$\frac{\pi}{4}$$ | $$\frac{\sqrt{2}}{2}$$ | $$\frac{\sqrt{2}}{2}$$ |
223
+| $$\frac{\pi}{2}$$ | $$0$$ | $$2$$ |
220 224
 
221 225
 
222
-**Figura 2.** Algunas coordenadas de los puntos $(x,y)$ del círculo con radio $r=2$ y centro en el origen.
226
+**Figura 2.** Algunas coordenadas de los puntos $$(x,y)$$ del círculo con radio $$r=2$$ y centro en el origen.
223 227
 
224 228
 ---
225 229
 
@@ -246,8 +250,7 @@ En este ejercicio estudiarás la diferencia entre pase por valor y pase por refe
246 250
     **Figura 3.** Gráfica de un círculo de radio 5 y centro en el origen desplegada por el programa *PrettyPlot*.
247 251
     
248 252
     ---
249
-
250
-
253
+    
251 254
 3. Abre el archivo `main.cpp` (en Sources).  Estudia la función `illustration` y su invocación desde la función `main`. Nota que las variables `argValue` y `argRef` están inicializadas a 0 y que la invocación a `illustration` hace un pase por valor de `argValue` y un pase por referencia de `argRef`. Nota también que a los parámetros correspondientes en `illustration` se les asigna el valor 1.
252 255
 
253 256
 4. Ejecuta el programa y observa lo que se despliega en la ventana `Application Output`. Nota la diferencia entre el contenido las variables `argValue` y `argRef` a pesar de que ambas tenían el mismo valor inicial y de que a `paramValue` y `paramRef` se les asignó el mismo valor. Explica por qué el contenido de `argValor` no cambia, mientras que el contenido de `argRef` cambia de 0 a 1.
@@ -258,14 +261,13 @@ En este ejercicio practicarás la creación de una función sobrecargada.
258 261
 
259 262
 **Instrucciones**
260 263
 
261
-1. Estudia el código de la función `main()` del archivo `main.cpp`. La línea `XYPlotWindow wCircleR5;` crea el objeto `wCircleR5` que será la ventana en donde se dibujará una gráfica, en este caso la gráfica de un círculo de radio 5. De manera similar se crean los objetos `wCircle` y `wButterfly`. Observa el ciclo `for`. En este ciclo se genera una serie de valores para el ángulo $t$ y se invoca la función `circle`, pasándole el valor de $t$ y las referencias a $x$ y $y$. La función `circle` no devuelve valor pero, usando parámetros por referencia, calcula valores para las coordenadas $xCoord$ y $yCoord$ del círculo con centro en el origen y radio 5 y permite que la función `main` tenga esos valores en las variables `x` , `y`. 
262
-
264
+1. Estudia el código de la función `main()` del archivo `main.cpp`. La línea `XYPlotWindow wCircleR5;` crea el objeto `wCircleR5` que será la ventana en donde se dibujará una gráfica, en este caso la gráfica de un círculo de radio 5. De manera similar se crean los objetos `wCircle` y `wButterfly`. Observa el ciclo `for`. En este ciclo se genera una serie de valores para el ángulo $$t$$ y se invoca la función `circle`, pasándole el valor de $$t$$ y las referencias a $$x$$ y $$y$$. La función `circle` no devuelve valor pero, usando parámetros por referencia, calcula valores para las coordenadas $$xCoord$$ y $$yCoord$$ del círculo con centro en el origen y radio 5 y permite que la función `main` tenga esos valores en las variables `x` , `y`. 
263 265
 
264
-    Luego de la invocación, cada par ordenado $(x,y)$  es añadido a la gráfica del círculo por el método `AddPointToGraph(x,y)`. Luego del ciclo se invoca el método `Plot()`, que "dibuja" los puntos, y el método `show()`, que muestra la gráfica. Los *métodos* son funciones que nos permiten trabajar con los datos de los objetos. Nota que cada uno de los métodos se escribe luego de `wCircleR5`, seguido de un punto. En una experiencia de laboratorio posterior aprenderás más sobre objetos y practicarás cómo crearlos e invocar sus métodos.
266
+    Luego de la invocación, cada par ordenado $$(x,y)$$  es añadido a la gráfica del círculo por el método `AddPointToGraph(x,y)`. Luego del ciclo se invoca el método `Plot()`, que "dibuja" los puntos, y el método `show()`, que muestra la gráfica. Los *métodos* son funciones que nos permiten trabajar con los datos de los objetos. Nota que cada uno de los métodos se escribe luego de `wCircleR5`, seguido de un punto. En una experiencia de laboratorio posterior aprenderás más sobre objetos y practicarás cómo crearlos e invocar sus métodos.
265 267
 
266
-    La función `circle` implementada en el programa es muy restrictiva ya que siempre calcula los valores para las coordenadas $x$ y $y$ del mismo círculo: el círculo con centro en el origen y radio 5.
268
+    La función `circle` implementada en el programa es muy restrictiva ya que siempre calcula los valores para las coordenadas $$x$$ y $$y$$ del mismo círculo: el círculo con centro en el origen y radio 5.
267 269
 
268
-2. Ahora crearás una función sobrecargada `circle` que reciba como argumentos el valor del ángulo $t$, la referencia a las variables $x$ y $y$, y el valor para el radio del círculo. Invoca desde `main()` la función sobrecargada  `circle` que acabas de implementar para calcular los valores de las coordenadas $x$ y $y$ del círculo con radio 15 y dibujar su gráfica. Grafica el círculo dentro del objeto `wCircle`. Para esto, debes invocar desde `main()` los métodos `AddPointToGraph(x,y)`, `Plot` y `show`. Recuerda que éstos deben ser precedidos por `wCircle`, por ejemplo, `wCircle.show()`.
270
+2. Ahora crearás una función sobrecargada `circle` que reciba como argumentos el valor del ángulo $$t$$, la referencia a las variables $$x$$ y $$y$$, y el valor para el radio del círculo. Invoca desde `main()` la función sobrecargada  `circle` que acabas de implementar para calcular los valores de las coordenadas $$x$$ y $$y$$ del círculo con radio 15 y dibujar su gráfica. Grafica el círculo dentro del objeto `wCircle`. Para esto, debes invocar desde `main()` los métodos `AddPointToGraph(x,y)`, `Plot` y `show`. Recuerda que éstos deben ser precedidos por `wCircle`, por ejemplo, `wCircle.show()`.
269 271
 
270 272
 ###Ejercicio 3
271 273
 
@@ -274,19 +276,15 @@ En este ejercicio implantarás otra función para calcular las coordenadas de lo
274 276
 **Instrucciones**
275 277
 
276 278
 1. Ahora crearás una función para calcular las coordenadas de los puntos de la gráfica que parece una mariposa. Las ecuaciones paramétricas para las coordenadas de los puntos de la gráfica están dadas por:
277
-
278
-
279
-
279
+    
280 280
     $$x=5\cos(t) \left[ \sin^2(1.2t) + \cos^3(6t) \right]$$
281 281
     $$y= 10\sin(t) \left[ \sin^2(1.2t) +  \cos^3(6t) \right].$$
282
-
283
-
284
-    Observa que ambas expresiones son casi iguales, excepto que una comienza con $5\cos(t)$ y la otra con $10\sin(t)$. En lugar de realizar el cómputo de $ \sin^2(1.2t) + \cos^3(6t)$ dos veces, puedes asignar su valor a otra variable $q$ y realizar el cómputo así:
285
-
282
+    
283
+    Observa que ambas expresiones son casi iguales, excepto que una comienza con $$5\cos(t)$$ y la otra con $$10\sin(t)$$. En lugar de realizar el cómputo de $$ \sin^2(1.2t) + \cos^3(6t)$$ dos veces, puedes asignar su valor a otra variable $$q$$ y realizar el cómputo así:
284
+    
286 285
     $$q =  \sin^2(1.2t) + \cos^3(6t)$$
287 286
     $$x = 5 \cos(t)(q)$$
288 287
     $$y = 10  \sin(t)(q).$$
289
-
290 288
     
291 289
 2. Implementa la función `butterfly` utilizando las expresiones de arriba, invoca la función desde `main()` y observa la gráfica que resulta. Se supone que parezca una mariposa. Esta gráfica debe haber sido obtenida dentro de un objeto `XYPlotWindow` llamado `wButterfly`, invocando métodos de manera similar a como hiciste en el Ejercicio 2 para el círculo.
292 290
 
@@ -295,16 +293,11 @@ En [3] puedes encontrar otras ecuaciones paramétricas de otras curvas interesan
295 293
 
296 294
 ---
297 295
 
298
----
299 296
 
300 297
 ##Entregas
301 298
 
302 299
 Utiliza "Entrega" en Moodle para entregar el archivo `main.cpp` que contiene las funciones que implementaste, las invocaciones y  cambios que hiciste en los ejercicios 2 y 3. Recuerda utilizar buenas prácticas de programación, incluir el nombre de los programadores y documentar tu programa.
303 300
 
304
-
305
-
306
----
307
-
308 301
 ---
309 302
 
310 303
 ##Referencias
@@ -370,11 +363,9 @@ Before you get to the laboratory you should have:
370 363
 
371 364
 ---
372 365
 
373
----
374
-
375 366
 ##Functions
376 367
 
377
-In mathematics, a function $f$ is a rule that is used to assign to each element $x$ from a set called *domain*, one (and only one) element $y$ from a set called *range*. This rule is commonly represented with an equation, $y=f(x)$. The variable $x$ is the parameter of the function and the variable $y$ will contain the result of the function. A function can have more than one parameter, but only one result. For example, a  function can have the form $y=f(x_1,x_2)$ where there are two parameters, and for each pair $(a,b)$ that is used as an argument in the function, the function has only one value of $y=f(a,b)$. The domain of the function tells us the type of value that the parameter should have and the range tells us the value that the returned result will have.
368
+In mathematics, a function $$f$$ is a rule that is used to assign to each element $$x$$ from a set called *domain*, one (and only one) element $$y$$ from a set called *range*. This rule is commonly represented with an equation, $$y=f(x)$$. The variable $$x$$ is the parameter of the function and the variable $$y$$ will contain the result of the function. A function can have more than one parameter, but only one result. For example, a  function can have the form $$y=f(x_1,x_2)$$ where there are two parameters, and for each pair $$(a,b)$$ that is used as an argument in the function, the function has only one value of $$y=f(a,b)$$. The domain of the function tells us the type of value that the parameter should have and the range tells us the value that the returned result will have.
378 369
 
379 370
 Functions in programming languages are similar. A function has a series of instructions that take the assigned values as parameters and performs a certain task. In C++ and other programming languages, functions return only one result, as it happens in mathematics. The only difference is that a *programming* function could possibly not return any value (in this case the function is declared as `void`). If the function will return a value, we use the instruction `return`. As in math, you need to specify the types of values that the function's parameters and result will have; this is done when declaring the function.
380 371
 
@@ -386,7 +377,9 @@ The first sentence of a function is called the *header* and its structure is as
386 377
 
387 378
 For example,
388 379
 
389
-`int example(int var1, float var2, char &var3)`
380
+```cpp
381
+int example(int var1, float var2, char &var3)
382
+```
390 383
 
391 384
 would be the header of the function called `example`, which returns an integer value. The function receives as arguments an integer value (and will store a copy in `var1`), a value of type `float` (and will store a copy in `var2`) and the reference to a variable of type `char` that will be stored in the reference variable `var3`. Note that `var3` has a & symbol before the name of the variable. This indicates that `var3` will contain the reference to a character.
392 385
 
@@ -396,20 +389,23 @@ would be the header of the function called `example`, which returns an integer v
396 389
 
397 390
 If we want to store the value of the `example` function's result in a variable `result` (that would be of type integer), we invoke the function by passing arguments as follows:
398 391
 
399
-`result=example(2, 3.5, unCar);`
392
+```cpp
393
+result = example(2, 3.5, unCar);
394
+```
400 395
 
401 396
 Note that as the function is invoked, you don't include the type of the variables in the arguments. As in the definition for the function `example`, the third parameter `&var3` is a reference variable; what is being sent to the third argument when invoking the function is a *reference* to the variable `unCar`. Any changes that are made on the variable `var3` will change the contents of the variable `unCar`.
402 397
 
403 398
 You can also use the function's result without having to store it in a variable. For example you could print it:
404 399
 
405
-`cout << "The result of the function example is:" << example(2, 3.5, unCar);`
400
+```cpp
401
+cout << "The result of the function example is:" << example(2, 3.5, unCar);
402
+```
406 403
 
407 404
 or use it in an arithmetic expression:
408 405
 
409
-`y=3 + example(2, 3.5, unCar);`
410
-
411
-
412
-
406
+```cpp
407
+y = 3 + example(2, 3.5, unCar);
408
+```
413 409
 
414 410
 
415 411
 ###Overloaded functions
@@ -420,7 +416,7 @@ The signature of a function is composed of the name of the function, and the typ
420 416
 
421 417
 The following function prototypes have the same signature:
422 418
 
423
-```
419
+```cpp
424 420
 int example(int, int) ;
425 421
 void example(int, int) ; 
426 422
 string example(int, int) ;
@@ -431,7 +427,7 @@ Note that each has the same name, `example`, and receives the same amount of par
431 427
 
432 428
 The following function prototypes have different signatures:
433 429
 
434
-```
430
+```cpp
435 431
 int example(int) ;
436 432
 int elpmaxe(int) ;
437 433
 ```
@@ -440,7 +436,7 @@ Note that even though the functions have the same amount of parameters with the
440 436
 
441 437
 The following function prototypes are overloaded versions of the function `example`:
442 438
 
443
-```
439
+```cpp
444 440
 int example(int) ;
445 441
 void example(char) ;
446 442
 int example(int, int) ;
@@ -461,7 +457,7 @@ Values by default can be assigned to the parameters of the functions starting fr
461 457
 **Examples of function headers and valid invocations:**
462 458
 
463 459
 1. **Headers:** `int example(int var1, float var2, int var3 = 10)` Here `var3` is initialized to 10.
464
-
460
+    
465 461
     **Invocations:**
466 462
 
467 463
     a. `example(5, 3.3, 12)` This function call assigns the value 5 to `var1`, the value 3.3 to `var2`, and the value of 12 to `var3`.
@@ -472,8 +468,7 @@ Values by default can be assigned to the parameters of the functions starting fr
472 468
 Here `var2` is initialized to 5 and `var3` to 10.
473 469
 
474 470
     **Invocations:**
475
-
476
-
471
+    
477 472
     a. `example(5, 3.3, 12)` This function call assigns the value 5 to `var1`, the value 3.3 to `var2`, and the value 12 to `var3`.
478 473
 
479 474
     b. `example(5, 3.3)` In this function call only the first two parameters are given values, and the value for the last parameter is the value by default. That is, the value for `var1` within the function will be 5, that of `var2` will be 3.3, and `var3` will be 10.
@@ -483,8 +478,7 @@ Here `var2` is initialized to 5 and `var3` to 10.
483 478
 
484 479
 **Example of a valid function header with invalid invocations:**
485 480
 1. **Header:** `int example(int var1, float var2=5.0, int var3 = 10)` 
486
-
487
-
481
+    
488 482
     **Invocation:**
489 483
 
490 484
     a. `example(5, , 10)` This function call is **invalid** because it leaves an empty space in the middle argument.
@@ -499,54 +493,50 @@ Here `var2` is initialized to 5 and `var3` to 10.
499 493
 2. `int example(int var1=1, float var2, int var3=10)` This header is invalid because you can't place parameters without values between other parameters with default values. In this case, `var2` doesn't have a default value but `var1` and `var3` do.
500 494
 
501 495
 
502
----
503 496
 
504 497
 ---
505 498
 
506 499
 ## Parametric equations
507 500
 
508
-*Parametric equations* allow us to represent a quantity as a function of one or more independent variables called *parameters*. In many occasions it is useful to represent curves using a set of parametric equations that express the coordinates of the points of the curve as functions of the parameters. For example, in your trigonometry course you should have studied that the equation of the circle of radius $r$ and centered at the origin has the following form:
509
-
501
+*Parametric equations* allow us to represent a quantity as a function of one or more independent variables called *parameters*. In many occasions it is useful to represent curves using a set of parametric equations that express the coordinates of the points of the curve as functions of the parameters. For example, in your trigonometry course you should have studied that the equation of the circle of radius $$r$$ and centered at the origin has the following form:
510 502
 
511 503
 $$x^2+y^2=r^2.$$
512 504
 
513
-The points $(x,y)$ that satisfy this equation are the points that form the circle of radius $r$ and center at the origin. For example, the circle with $r=2$ and center at the origin has equation
514
-
505
+The points $$(x,y)$$ that satisfy this equation are the points that form the circle of radius $$r$$ and center at the origin. For example, the circle with $$r=2$$ and center at the origin has equation
515 506
 
516 507
 $$x^2+y^2=4,$$
517 508
 
518
-and its points are the ordered pairs $(x,y)$ that satisfy this equation. A parametric representation of the coordinates of the points in the circle of radius $r$ and center at the origin is:
519
-
509
+and its points are the ordered pairs $$(x,y)$$ that satisfy this equation. A parametric representation of the coordinates of the points in the circle of radius $$r$$ and center at the origin is:
520 510
 
521 511
 $$x=r \cos(t)$$
522 512
 
523
-$$y=r \sin(t),$$
513
+$$y=r \sin(t)$$,
524 514
 
525
-where $t$ is a parameter that corresponds to the measure (in radians) of the positive angle  with initial side that coincides with the positive part of the $x$-axis and terminal side that contains the point $(x,y)$, as it is illustrated in Figure 1.
515
+where $$t$$ is a parameter that corresponds to the measure (in radians) of the positive angle  with initial side that coincides with the positive part of the $$x$$-axis and terminal side that contains the point $$(x,y)$$, as it is illustrated in Figure 1.
526 516
 
527 517
 
528 518
 ---
529 519
 
530 520
 ![circulo.jpg](images/circulo.jpg)
531 521
 
532
-<b>Figure 1.</b> Circle with center in the origin and radius $r$.
522
+<b>Figure 1.</b> Circle with center in the origin and radius $$r$$.
533 523
 
534 524
 
535 525
 ---
536 526
 
537
-To plot a curve that is described  by parametric equations, we compute the $x$ and $y$ values for a set of values of the parameter. For example, for $r=2$, some of the values are
527
+To plot a curve that is described  by parametric equations, we compute the $$x$$ and $$y$$ values for a set of values of the parameter. For example, for $$r=2$$, some of the values are
538 528
 
539 529
 
540 530
 ---
541 531
 
542
-| $t$ | $x$ | $y$ |
532
+| $$t$$ | $$x$$ | $$y$$ |
543 533
 |-----|-----|-----|
544
-| $0$ | $2$ | $0$ |
545
-| $\frac{\pi}{4}$ | $\frac{\sqrt{2}}{2}$ | $\frac{\sqrt{2}}{2}$ |
546
-| $\frac{\pi}{2}$ | $0$ | $2$ |
534
+| $$0$$ | $$2$$ | $$0$$ |
535
+| $$\frac{\pi}{4}$$ | $$\frac{\sqrt{2}}{2}$$ | $$\frac{\sqrt{2}}{2}$$ |
536
+| $$\frac{\pi}{2}$$ | $$0$$ | $$2$$ |
547 537
 
548 538
 
549
-**Figure 2.** Some coordinates for the points $(x,y)$ for the circle with radius $r=2$ and center in the origin.
539
+**Figure 2.** Some coordinates for the points $$(x,y)$$ for the circle with radius $$r=2$$ and center in the origin.
550 540
 
551 541
 ---
552 542
 
@@ -573,7 +563,7 @@ In this exercise you will study the difference between pass by value and pass by
573 563
     **Figure 3.**  Graph of a circle with radius 5 and center in the origin displayed by the program *PrettyPlot*.
574 564
     
575 565
     ---
576
-
566
+    
577 567
 3. Open the file `main.cpp` (in Sources). Study the `illustration` function and how to call it from the `main` function. Note that the variables `argValue` and `argRef`are initialized to 0 and that the function call for `illustration` makes a pass by value of `argValue` and a pass by reference of `argRef`. Also note that the corresponding parameters in `illustration` are assigned a value of 1.
578 568
 
579 569
 4. Execute the program and observe what is displayed in the window `Application Output`. Notice the difference between the content of the variables `argValue` and `argRef` despite the fact that both had the same initial value, and that `paramValue` and `paramRef` were assigned the same value. Explain why the content of `argValor` does not change, while the content of `argRef` changes from 0 to 1.
@@ -584,13 +574,13 @@ In this exercise you will practice the creation of an overloaded function.
584 574
 
585 575
 **Instructions**
586 576
 
587
-1. Study the code in the `main()` function in the file `main.cpp`. The line `XYPlotWindow wCircleR5;` creates a `wCircleR5` object that will be the window where the graph will be drawn, in this case the graph of a circle of radius 5. In a similar way, the objects `wCircle` and `wButterfly` are created. Observe the `for` cycle. In this cycle a series of values for the angle $t$ is generated and the function `circle` is invoked, passing the value for $t$ and the references to $x$ and $y$. The `circle` function does not return a value, but using parameters by reference, it calculates the values for the coordinates $xCoord$ and $yCoord$ for the circle with center in the origin and radius 5, and allows the `main` function  to have these values in the `x` , `y` variables.
577
+1. Study the code in the `main()` function in the file `main.cpp`. The line `XYPlotWindow wCircleR5;` creates a `wCircleR5` object that will be the window where the graph will be drawn, in this case the graph of a circle of radius 5. In a similar way, the objects `wCircle` and `wButterfly` are created. Observe the `for` cycle. In this cycle a series of values for the angle $$t$$ is generated and the function `circle` is invoked, passing the value for $$t$$ and the references to $$x$$ and $$y$$. The `circle` function does not return a value, but using parameters by reference, it calculates the values for the coordinates $$xCoord$$ and $$yCoord$$ for the circle with center in the origin and radius 5, and allows the `main` function  to have these values in the `x` , `y` variables.
588 578
 
589
-    After the function call, each ordered pair $(x,y)$ is added to the circle’s graph by the member function `AddPointToGraph(x,y)`. After the cycle, the member function `Plot()` is invoked, which draws the points, and the member function `show()`, which displays the graph. The *members functions* are functions that allow use to work with and object’s data. Notice that each one of the member functions is written after `wCircleR5`, followed by a period. In an upcoming laboratory experience you will learn more about objects, and practice how to create them and invoke their method functions.
579
+    After the function call, each ordered pair $$(x,y)$$ is added to the circle’s graph by the member function `AddPointToGraph(x,y)`. After the cycle, the member function `Plot()` is invoked, which draws the points, and the member function `show()`, which displays the graph. The *members functions* are functions that allow use to work with and object’s data. Notice that each one of the member functions is written after `wCircleR5`, followed by a period. In an upcoming laboratory experience you will learn more about objects, and practice how to create them and invoke their method functions.
590 580
 
591
-    The `circle` function implemented in the program is very restrictive since it always calculates the values for the coordinates $x$ and $y$ of the same circle: the circle with center in the origin and radius 5.
581
+    The `circle` function implemented in the program is very restrictive since it always calculates the values for the coordinates $$x$$ and $$y$$ of the same circle: the circle with center in the origin and radius 5.
592 582
 
593
-2. Now you will create an overloaded function `circle` that receives as arguments the value of the angle $t$, the reference to the variables $x$ and $y$, and the value for the radius of the circle. Invoke the overloaded function `circle` that you just implemented from `main()` to calculate the values of the coordinates $x$ and $y$ for the circle with radius 15 and draw its graph. Graph the circle within the `wCircle` object. To do this, you must invoke the method functions `AddPointToGraph(x,y)`, `Plot` and `show` from `main()`. Remember that these should be preceded by `wCircle`, for example, `wCircle.show()`.
583
+2. Now you will create an overloaded function `circle` that receives as arguments the value of the angle $$t$$, the reference to the variables $$x$$ and $$y$$, and the value for the radius of the circle. Invoke the overloaded function `circle` that you just implemented from `main()` to calculate the values of the coordinates $$x$$ and $$y$$ for the circle with radius 15 and draw its graph. Graph the circle within the `wCircle` object. To do this, you must invoke the method functions `AddPointToGraph(x,y)`, `Plot` and `show` from `main()`. Remember that these should be preceded by `wCircle`, for example, `wCircle.show()`.
594 584
 
595 585
 ###Exercise 3
596 586
 
@@ -599,12 +589,11 @@ In this exercise you will implement another function to calculate the coordinate
599 589
 **Instructions**
600 590
 
601 591
 1. Now you will create a function to calculate the coordinates of the points of a graph that resembles a butterfly. The parametric equations for the coordinates of the points in the graph are given by:
602
-
603
-
592
+    
604 593
     $$x=5\cos(t) \left[ \sin^2(1.2t) + \cos^3(6t) \right]$$
605 594
     $$y= 10\sin(t) \left[ \sin^2(1.2t) +  \cos^3(6t) \right].$$
606 595
 
607
-    Observe that both expressions are almost the same, except that one starts with $5\cos(t)$ and the other with $10\sin(t)$. Instead of doing the calculation for $ \sin^2(1.2t) + \cos^3(6t)$ twice, you can assign its value to another variable $q$ and calculate it as such:
596
+    Observe that both expressions are almost the same, except that one starts with $$5\cos(t)$$ and the other with $$10\sin(t)$$. Instead of doing the calculation for $$ \sin^2(1.2t) + \cos^3(6t)$$ twice, you can assign its value to another variable $$q$$ and calculate it as such:
608 597
 
609 598
     $$q =  \sin^2(1.2t) + \cos^3(6t)$$
610 599
     $$x = 5 \cos(t)(q)$$
@@ -615,15 +604,11 @@ In this exercise you will implement another function to calculate the coordinate
615 604
 In [3] you can find other parametric equations from other interesting curves.
616 605
 
617 606
 ---
618
----
619 607
 
620 608
 ##Deliverables
621 609
 
622 610
 Use "Deliverables" in Moodle to hand in the file `main()` that contains the functions you implemented, the function calls and changes you made in exercises 2 and 3. Remember to use good programming techniques, include the name of the programmers involved and document your program.
623 611
 
624
-
625
----
626
-
627 612
 ---
628 613
 
629 614
 ##References
@@ -633,9 +618,3 @@ Use "Deliverables" in Moodle to hand in the file `main()` that contains the func
633 618
 [2] http://paulbourke.net/geometry/butterfly/
634 619
 
635 620
 [3] http://en.wikipedia.org/wiki/Parametric_equation
636
-
637
-
638
-
639
-
640
-
641
-