Skip to content

Commit 870c95e

Browse files
author
StephenElston
authored
Merge pull request #2 from eddjberry/master
Fix typos and use ^ rather than for ** raising to a power
2 parents f07ffc8 + 1862316 commit 870c95e

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

Module01/01-04-Exponentials Radicals and Logarithms.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"\n",
1717
"\\begin{equation}2^{3} = 2 \\cdot 2 \\cdot 2 = 8\\end{equation}\n",
1818
"\n",
19-
"In R, you use the ****** operator, like this example in which **x** is assigned the value of 5 raised to the power of 3 (in other words, 5 x 5 x 5, or 5-cubed):"
19+
"In R, you use the **\\^** operator, like this example in which **x** is assigned the value of 5 raised to the power of 3 (in other words, 5 x 5 x 5, or 5-cubed):"
2020
]
2121
},
2222
{
@@ -25,7 +25,7 @@
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
28-
"x = 5**3\n",
28+
"x = 5^3\n",
2929
"print(x)"
3030
]
3131
},
@@ -68,7 +68,7 @@
6868
"print(x)\n",
6969
"\n",
7070
"## calculate and display the cube root of 64\n",
71-
"cr = 64**(1/3)\n",
71+
"cr = 64^(1/3)\n",
7272
"print(cr)"
7373
]
7474
},
@@ -95,7 +95,7 @@
9595
"metadata": {},
9696
"outputs": [],
9797
"source": [
98-
"print(9**0.5)\n",
98+
"print(9^0.5)\n",
9999
"print(sqrt(9))"
100100
]
101101
},
@@ -199,7 +199,7 @@
199199
"df = data.frame(x = seq(-10, 10))\n",
200200
"\n",
201201
"# Add a y column by applying the slope-intercept equation to x\n",
202-
"df$y = 3*df$x**3\n",
202+
"df$y = 3*df$x^3\n",
203203
"\n",
204204
"#Display the dataframe\n",
205205
"print(df)\n",
@@ -236,7 +236,7 @@
236236
"df = data.frame(x = seq(-10, 10))\n",
237237
"\n",
238238
"# Add a y column by applying the slope-intercept equation to x\n",
239-
"df$y = 2.0**df$x\n",
239+
"df$y = 2.0^df$x\n",
240240
"\n",
241241
"## Plot the line\n",
242242
"ggplot(df, aes(x,y)) + \n",
@@ -289,7 +289,7 @@
289289
"df = data.frame(Year = seq(1, 20))\n",
290290
"\n",
291291
"# Calculate the balance for each year based on the exponential growth from interest\n",
292-
"df$Balance = 100 * (1.05**df$Year)\n",
292+
"df$Balance = 100 * (1.05^df$Year)\n",
293293
"\n",
294294
"## Plot the line\n",
295295
"ggplot(df, aes(Year, Balance)) + \n",

Module01/01-05-Polynomials.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"source": [
6565
"x = sample.int(100, 1)\n",
6666
"\n",
67-
"(x**3 + 2*x**3 - 3*x - x + 8 - 3) == (3*x**3 - 4*x + 5)"
67+
"(x^3 + 2*x^3 - 3*x - x + 8 - 3) == (3*x^3 - 4*x + 5)"
6868
]
6969
},
7070
{
@@ -95,7 +95,7 @@
9595
"source": [
9696
"x = sample.int(100, 1)\n",
9797
"\n",
98-
"(3*x**3 - 4*x + 5) + (2*x**3 + 3*x**2 - 2*x + 2) == 5*x**3 + 3*x**2 - 6*x + 7"
98+
"(3*x^3 - 4*x + 5) + (2*x^3 + 3*x^2 - 2*x + 2) == 5*x^3 + 3*x^2 - 6*x + 7"
9999
]
100100
},
101101
{
@@ -132,7 +132,7 @@
132132
"source": [
133133
"x = sample.int(100, 1)\n",
134134
"\n",
135-
"(2*x**2 - 4*x + 5) - (x**2 - 2*x + 2) == x**2 - 2*x + 3"
135+
"(2*x^2 - 4*x + 5) - (x^2 - 2*x + 2) == x^2 - 2*x + 3"
136136
]
137137
},
138138
{
@@ -163,7 +163,7 @@
163163
"source": [
164164
"x = sample.int(100, 1)\n",
165165
"\n",
166-
"(x**4 + 2)*(2*x**2 + 3*x - 3) == 2*x**6 + 3*x**5 - 3*x**4 + 4*x**2 + 6*x - 6"
166+
"(x^4 + 2)*(2*x^2 + 3*x - 3) == 2*x^6 + 3*x^5 - 3*x^4 + 4*x^2 + 6*x - 6"
167167
]
168168
},
169169
{
@@ -203,7 +203,7 @@
203203
"source": [
204204
"x = sample.int(100, 1)\n",
205205
"\n",
206-
"(4*x + 6*x**2) / (2*x) == 2 + 3*x"
206+
"(4*x + 6*x^2) / (2*x) == 2 + 3*x"
207207
]
208208
},
209209
{
@@ -255,7 +255,7 @@
255255
"source": [
256256
"x = sample.int(100, 1)\n",
257257
"\n",
258-
"(x**2 + 2*x -3)/(x-2) == x + 4 + (5/(x-2))\n",
258+
"(x^2 + 2*x -3)/(x-2) == x + 4 + (5/(x-2))\n",
259259
" "
260260
]
261261
}

Module01/01-06-Factorization.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"x = sample.int(100, 1)\n",
3636
"y = sample.int(100, 1)\n",
3737
"\n",
38-
"(2*x*y**2)*(-3*x*y) == -6*x**2*y**3"
38+
"(2*x*y^2)*(-3*x*y) == -6*x^2*y^3"
3939
]
4040
},
4141
{
@@ -62,7 +62,7 @@
6262
"x = sample.int(100, 1)\n",
6363
"y = sample.int(100, 1)\n",
6464
"\n",
65-
"(x + 2)*(2*x**2 - 3*y + 2) == 2*x**3 + 4*x**2 - 3*x*y + 2*x - 6*y + 4"
65+
"(x + 2)*(2*x^2 - 3*y + 2) == 2*x^3 + 4*x^2 - 3*x*y + 2*x - 6*y + 4"
6666
]
6767
},
6868
{
@@ -78,7 +78,7 @@
7878
"|--------|--------|\n",
7979
"| 1 x 16 | 1 x 24 |\n",
8080
"| 2 x **8** | 2 x 12 |\n",
81-
"| | 3 x **8** |\n",
81+
"| - | 3 x **8** |\n",
8282
"| 4 x 4 | 4 x 6 |\n",
8383
"\n",
8484
"The highest value that is a multiple of both 16 and 24 is **8**, so 8 is the *Greatest Common Factor* (or GCF) of 16 and 24.\n",
@@ -124,8 +124,8 @@
124124
"x = sample.int(100, 1)\n",
125125
"y = sample.int(100, 1)\n",
126126
"\n",
127-
"print((3*x*y)*(5*x) == 15*x**2*y)\n",
128-
"print((3*x*y)*(3*y**2) == 9*x*y**3)"
127+
"print((3*x*y)*(5*x) == 15*x^2*y)\n",
128+
"print((3*x*y)*(3*y^2) == 9*x*y^3)"
129129
]
130130
},
131131
{
@@ -189,7 +189,7 @@
189189
"x = sample.int(100, 1)\n",
190190
"y = sample.int(100, 1)\n",
191191
"\n",
192-
"(15*x**2*y + 9*x*y**3) == (3*x*y*(5*x + 3*y**2))"
192+
"(15*x^2*y + 9*x*y^3) == (3*x*y*(5*x + 3*y^2))"
193193
]
194194
},
195195
{
@@ -248,7 +248,7 @@
248248
"source": [
249249
"x = sample.int(100, 1)\n",
250250
"\n",
251-
"(x**2 - 9) == (x - 3)*(x + 3)"
251+
"(x^2 - 9) == (x - 3)*(x + 3)"
252252
]
253253
},
254254
{
@@ -301,7 +301,7 @@
301301
"a = sample.int(100, 1)\n",
302302
"b = sample.int(100, 1)\n",
303303
"\n",
304-
"a**2 + b**2 + (2*a*b) == (a + b)**2"
304+
"a^2 + b^2 + (2*a*b) == (a + b^2"
305305
]
306306
}
307307
],

Module01/01-07-Quadratic Equations.ipynb

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"df = data.frame(x = seq(-9, 8))\n",
3030
"\n",
3131
"# Add a y column by applying the quadratic equation to x\n",
32-
"df$y = 2*df$x**2 + 2 *df$x - 4\n",
32+
"df$y = 2*df$x^2 + 2 *df$x - 4\n",
3333
"\n",
3434
"## Plot the parabola\n",
3535
"library(ggplot2)\n",
@@ -63,7 +63,7 @@
6363
"df = data.frame(x = seq(-8,11))\n",
6464
"\n",
6565
"# Add a y column by applying the quadratic equation to x\n",
66-
"df$y = -2*df$x**2 + 6*df$x + 7\n",
66+
"df$y = -2*df$x^2 + 6*df$x + 7\n",
6767
"\n",
6868
"## Plot the parabola\n",
6969
"library(ggplot2)\n",
@@ -107,15 +107,15 @@
107107
" vx = (-1*b)/(2*a)\n",
108108
" \n",
109109
" # get the y value when x is at the line of symmetry\n",
110-
" vy = a*vx**2 + b*vx + c\n",
110+
" vy = a*vx^2 + b*vx + c\n",
111111
"\n",
112112
" # Create a dataframe with an x column containing values from x-10 to x+10\n",
113113
" minx = as.integer(vx - 10)\n",
114114
" maxx = as.integer(vx + 10)\n",
115115
" df = data.frame(x = seq(minx, maxx))\n",
116116
" \n",
117117
" # Add a y column by applying the quadratic equation to x\n",
118-
" df$y = a*df$x**2 + b*df$x + c\n",
118+
" df$y = a*df$x^2 + b*df$x + c\n",
119119
"\n",
120120
" # get min and max y values\n",
121121
" miny = min(df$y)\n",
@@ -143,6 +143,7 @@
143143
"metadata": {},
144144
"source": [
145145
"## Parabola Intercepts\n",
146+
"\n",
146147
"Recall that linear equations create lines that intersect the **x** and **y** axis of a graph, and we call the points where these intersections occur *intercepts*. Now look at the graphs of the parabolas we've worked with so far. Note that these parabolas both have a y-intercept; a point where the line intersects the y axis of the graph (in other words, when x is 0). However, note that the parabolas have *two* x-intercepts; in other words there are two points at which the line crosses the x axis (and y is 0). Additionally, imagine a downward opening parabola with its vertex at -1, -1. This is perfectly possible, and the line would never have an x value greater than -1, so it would have *no* x-intercepts.\n",
147148
"\n",
148149
"Regardless of whether the parabola crosses the x axis or not, other than the vertex, for every ***y*** point in the parabola, there are *two* ***x*** points; one on the right (or positive) side of the axis of symmetry, and one of the left (or negative) side. The implications of this are what make quadratic equations so interesting. When we solve the equation for ***x***, there are *two* correct answers.\n",
@@ -191,15 +192,15 @@
191192
" vx = (-1*b)/(2*a)\n",
192193
" \n",
193194
" # get the y value when x is at the line of symmetry\n",
194-
" vy = a*vx**2 + b*vx + c\n",
195+
" vy = a*vx^2 + b*vx + c\n",
195196
"\n",
196197
" # Create a dataframe with an x column containing values from x-10 to x+10\n",
197198
" minx = as.integer(vx - 10)\n",
198199
" maxx = as.integer(vx + 10)\n",
199200
" df = data.frame(x = seq(minx, maxx))\n",
200201
" \n",
201202
" # Add a y column by applying the quadratic equation to x\n",
202-
" df$y = a*df$x**2 + b*df$x + c\n",
203+
" df$y = a*df$x^2 + b*df$x + c\n",
203204
"\n",
204205
" # get min and max y values\n",
205206
" miny = min(df$y)\n",
@@ -278,13 +279,13 @@
278279
"df = data.frame(x = seq(x1-10, x2+10))\n",
279280
"\n",
280281
"# Add a y column by applying the quadratic equation to x\n",
281-
"df$y = 3*df$x**2 - 12\n",
282+
"df$y = 3*df$x^2 - 12\n",
282283
"\n",
283284
"# Get x at the line of symmetry (halfway between x1 and x2)\n",
284285
"vx = (x1 + x2) / 2\n",
285286
"\n",
286287
"# Get y when x is at the line of symmetry\n",
287-
"vy = 3*vx**2 - 12\n",
288+
"vy = 3*vx^2 - 12\n",
288289
"\n",
289290
"# get min and max y values\n",
290291
"miny = min(df$y)\n",
@@ -372,13 +373,13 @@
372373
"df = data.frame(x = seq(x1-10, x2+10))\n",
373374
"\n",
374375
"# Add a y column by applying the quadratic equation to x\n",
375-
"df$y = ((df$x + 3)**2) - 16\n",
376+
"df$y = ((df$x + 3)^2) - 16\n",
376377
"\n",
377378
"# Get x at the line of symmetry (halfway between x1 and x2)\n",
378379
"vx = (x1 + x2) / 2\n",
379380
"\n",
380381
"# Get y when x is at the line of symmetry\n",
381-
"vy = ((vx + 3)**2) - 16\n",
382+
"vy = ((vx + 3)^2) - 16\n",
382383
"\n",
383384
"# get min and max y values\n",
384385
"miny = min(df$y)\n",
@@ -441,7 +442,7 @@
441442
"source": [
442443
"x = sample.int(100, 1)\n",
443444
"\n",
444-
"2*x**2 - 16*x + 2 == 2*(x - 4)**2 - 30"
445+
"2*x^2 - 16*x + 2 == 2*(x - 4)^2 - 30"
445446
]
446447
},
447448
{
@@ -482,14 +483,14 @@
482483
" df = data.frame(x = seq(h-10, h+10))\n",
483484
" \n",
484485
" # Add a y column by applying the quadratic equation to x\n",
485-
" df$y = (a*(df$x - h)**2) + k\n",
486+
" df$y = (a*(df$x - h)^2) + k\n",
486487
"\n",
487488
" # get min and max y values\n",
488489
" miny = min(df$y)\n",
489490
" maxy = max(df$y)\n",
490491
" \n",
491492
" # calculate y when x is 0 (h+-h)\n",
492-
" y = a*(0 - h)**2 + k\n",
493+
" y = a*(0 - h)^2 + k\n",
493494
" \n",
494495
" ## data frame for line of symmetry\n",
495496
" symmetry = data.frame(sx = c(h,h), sy = c(miny,maxy))\n",
@@ -627,7 +628,7 @@
627628
" print(paste('vy =', toString(a), '(', toString(vx), '^2) + ', \n",
628629
" toString(b), '(', toString(vx), ') + ', toString(c)))\n",
629630
"\n",
630-
" avx2 = a*vx**2\n",
631+
" avx2 = a*vx^2\n",
631632
" bvx = b*vx\n",
632633
" print(paste('vy =', toString(avx2), ' + ', toString(bvx), ' + ', toString(c)))\n",
633634
"\n",
@@ -642,7 +643,7 @@
642643
" print('CALCULATING -x AND +x FOR y=0')\n",
643644
" print('x = -b +- sqrt(b^2 - 4ac) / 2a')\n",
644645
" \n",
645-
" b2 = b**2\n",
646+
" b2 = b^2\n",
646647
" ac4 = 4*a*c\n",
647648
" print(paste('x = ', toString(nb), '+-sqrt(', toString(b2), \n",
648649
" ' - ', toString(ac4), ')/', toString(a2)))\n",
@@ -664,7 +665,7 @@
664665
" df = data.frame(x = seq(round(vx)-10, round(vx)+10))\n",
665666
" \n",
666667
" # Add a y column by applying the quadratic equation to x\n",
667-
" df$y = a*df$x**2 + b*df$x + c\n",
668+
" df$y = a*df$x^2 + b*df$x + c\n",
668669
"\n",
669670
" # get min and max y values\n",
670671
" miny = min(df$y)\n",

Module01/01-08-Functions.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"\n",
1818
"\\begin{equation}f(3) = 11\\end{equation}\n",
1919
"\n",
20-
"You've already seen a few examples of R functions, which are defined using the **def** keyword. However, the strict definition of an algebraic function is that it must return a single value. Here's an example of defining and using a R function that meets this criteria:"
20+
"You've already seen a few examples of R functions, which are defined using **function()**. However, the strict definition of an algebraic function is that it must return a single value. Here's an example of defining and using a R function that meets this criteria:"
2121
]
2222
},
2323
{
@@ -27,7 +27,7 @@
2727
"outputs": [],
2828
"source": [
2929
"# define a function to return x^2 + 2\n",
30-
"f = function(x){x**2 + 2}\n",
30+
"f = function(x){x^2 + 2}\n",
3131
"\n",
3232
"# call the function\n",
3333
"f(3)"
@@ -52,7 +52,7 @@
5252
"source": [
5353
"x = 4\n",
5454
"y = f(x) - 1\n",
55-
"cat(y)"
55+
"y"
5656
]
5757
},
5858
{
@@ -68,7 +68,7 @@
6868
"metadata": {},
6969
"outputs": [],
7070
"source": [
71-
"# Create an array of x values from -100 to 100\n",
71+
"# Create a data.frame of x values from -100 to 100\n",
7272
"df = data.frame(x = seq(-100, 100))\n",
7373
"df$y = f(df$x)\n",
7474
"\n",
@@ -324,7 +324,7 @@
324324
"metadata": {},
325325
"outputs": [],
326326
"source": [
327-
"p = function(x){x**2 + 1}\n",
327+
"p = function(x){x^2 + 1}\n",
328328
"\n",
329329
"# Create an array of x values from -100 to 100\n",
330330
"df6 = data.frame(x = seq(-100, 100))\n",

0 commit comments

Comments
 (0)