Skip to content

Commit 254bd88

Browse files
committed
update module 2 and add tags
1 parent 98f6450 commit 254bd88

9 files changed

+569
-569
lines changed

src/data_science/discrete_and_continuous.jl

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.14
2+
# v0.19.25
33

44
#> [frontmatter]
55
#> chapter = 2
@@ -11,7 +11,7 @@
1111
#> layout = "layout.jlhtml"
1212
#> youtube_id = "H6Dcx3YeTkE"
1313
#> description = ""
14-
#> tags = ["lecture", "module2"]
14+
#> tags = ["lecture", "module2", "track_math", "discrete", "continuous"]
1515

1616
using Markdown
1717
using InteractiveUtils
@@ -89,31 +89,6 @@ md"""
8989
### Heard in the hallways: I only like discrete math. I only like continuous math.
9090
"""
9191

92-
# ╔═╡ 173b44ea-918c-11eb-116b-0bbaeffc3fe2
93-
md"""
94-
It is not unusual for students (and professors) to gravitate towards the discrete or the continuous. We wish to point out, that the discrete and the continuous are so closely related, that it is worthwhile to be comfortable with both. Up until fairly recently, much of computer science was often associated with discrete mathematics, while computational science and engineering was associated with physical systems, hence continuous mathematics.
95-
96-
$(blue("That is blurring these days:")) The popularity of machine learning has brought continuous optimization ideas such as gradient descent into the world of computer science and the impact of the physical world on us all (e.g. climate change, pandemics) is motivating applications in computer science. The newfound popularity of Data science and statistics is also mixing the discrete with the continuous.
97-
98-
99-
"""
100-
101-
# ╔═╡ a3f005a8-9617-11eb-1503-75c31ec54f70
102-
md"""
103-
$(blue("Continuous math often lets you replace complicated large systems
104-
with lots of details with a simpler abstraction that is easier to work with."))
105-
"""
106-
107-
# ╔═╡ 870cdf5f-f896-4060-9548-5d9c1749d100
108-
md"""
109-
$(blue("The combination of continuous and discrete is often more useful than either one alone."))
110-
"""
111-
112-
# ╔═╡ d9dfe7c5-9211-4707-bb33-a3ff258e10f4
113-
md"""
114-
$(blue("Machine Learning, Pandemics, climate change, etc. show how critical continuous math is these days."))
115-
"""
116-
11792
# ╔═╡ 5c536430-9188-11eb-229c-e7feba62d257
11893
md"""
11994
### Indexing and Function Evaluation
@@ -166,6 +141,9 @@ md"""
166141
n = $(@bind sides Slider(3:100, show_value=true, default=6))
167142
"""
168143

144+
# ╔═╡ f20da096-9712-11eb-2a67-cd33f6ab8750
145+
area(s) = (s/2) * sin(2π/s)
146+
169147
# ╔═╡ 02784976-9566-11eb-125c-a7f1f1bafd6b
170148
begin
171149
θ = (0:.01:1)*2π
@@ -180,9 +158,6 @@ begin
180158
title!("Area = ($sides/2)sin(2π/$sides) ≈ $(area(sides)/π ) π")
181159
end
182160

183-
# ╔═╡ f20da096-9712-11eb-2a67-cd33f6ab8750
184-
area(s) = (s/2) * sin(2π/s)
185-
186161
# ╔═╡ 6fd93018-c33b-4682-91c3-7a20a41d9b03
187162
area0 = area.( 2 .^ (2:10) ) # Area of polygons with # sides = [4, 8, ..., 1024]
188163

@@ -211,9 +186,6 @@ end
211186
# ╔═╡ bcfd1585-8161-43a2-8b19-ed654df2e0e1
212187
colorgoodbad(string(float(π)) , string(22/7))
213188

214-
# ╔═╡ d2d1366b-9b6d-4e54-a0c4-7087f5f063c4
215-
pyramid( [area0,area1], horizontal = true)
216-
217189
# ╔═╡ a76ac67b-27b9-4e2b-9fca-61480dca5264
218190
area2 = [16/15 * area1[i+1] .- 1/15 * area1[i] for i = 1:length(area1)-1 ]
219191

@@ -222,9 +194,6 @@ md"""
222194
Another carefully chosen convolution: [-1/15,16/15], do you see the pattern?
223195
"""
224196

225-
# ╔═╡ 6577e546-8f0b-413a-a8bb-b9c12803199d
226-
pyramid([area0,area1,area2], horizontal = true)
227-
228197
# ╔═╡ 5273fe09-fe38-4c88-b84a-51af17cff906
229198
big(π)
230199

@@ -234,15 +203,6 @@ area3 = [64/63 * area2[i+1] .- 1/63 * area2[i] for i = 1:length(area2)-1 ]
234203
# ╔═╡ 626242ea-544c-49fc-9884-c70dd6800902
235204
area4 = [128/127 * area3[i+1] .- 1/127 * area3[i] for i = 1:length(area3)-1 ]
236205

237-
# ╔═╡ 893a56b0-f5d0-4f8d-ba15-1048180a7e53
238-
pyramid([pp.(area0), pp.(area1), pp.(area2), pp.(area3), pp.(area4)], horizontal = true)
239-
240-
# ╔═╡ fa3a8baf-d86d-45c3-b4ba-85198bd0677d
241-
string(area1b[end])
242-
243-
# ╔═╡ 8bcd29e2-41db-4969-9932-3cc56edfdc18
244-
colorgoodbad( (@sprintf "%.30f" big(π)) , (@sprintf "%.30f" big(area1b[end])))
245-
246206
# ╔═╡ dbccc2d5-c2af-48c4-8726-a95c09da78ae
247207
md"""
248208
Why does this work?
@@ -285,6 +245,12 @@ begin
285245
colorgoodbad( (@sprintf "%.80f" big(π)) , (@sprintf "%.80f" big(area1b[end])))
286246
end
287247

248+
# ╔═╡ fa3a8baf-d86d-45c3-b4ba-85198bd0677d
249+
string(area1b[end])
250+
251+
# ╔═╡ 8bcd29e2-41db-4969-9932-3cc56edfdc18
252+
colorgoodbad( (@sprintf "%.30f" big(π)) , (@sprintf "%.30f" big(area1b[end])))
253+
288254
# ╔═╡ 453f2585-157d-490a-9d1c-0b02939d0a11
289255
begin
290256
area2b = [16//15 * area1b[i+1] .- 1//15 * area1b[i] for i = 1:length(area1b)-1 ]
@@ -509,9 +475,34 @@ end
509475

510476
# ╔═╡ 0e6cab25-70f8-46ab-a5ab-8542e232274e
511477
function blue(s::String)
512-
HTML("<span style='color: hsl(200deg, 60%, 50%);'> $(s) </span>")
478+
@htl("<span style='color: hsl(200deg, 60%, 50%);'> $(s) </span>")
513479
end
514480

481+
# ╔═╡ 173b44ea-918c-11eb-116b-0bbaeffc3fe2
482+
md"""
483+
It is not unusual for students (and professors) to gravitate towards the discrete or the continuous. We wish to point out, that the discrete and the continuous are so closely related, that it is worthwhile to be comfortable with both. Up until fairly recently, much of computer science was often associated with discrete mathematics, while computational science and engineering was associated with physical systems, hence continuous mathematics.
484+
485+
$(blue("That is blurring these days:")) The popularity of machine learning has brought continuous optimization ideas such as gradient descent into the world of computer science and the impact of the physical world on us all (e.g. climate change, pandemics) is motivating applications in computer science. The newfound popularity of Data science and statistics is also mixing the discrete with the continuous.
486+
487+
488+
"""
489+
490+
# ╔═╡ a3f005a8-9617-11eb-1503-75c31ec54f70
491+
md"""
492+
$(blue("Continuous math often lets you replace complicated large systems
493+
with lots of details with a simpler abstraction that is easier to work with."))
494+
"""
495+
496+
# ╔═╡ 870cdf5f-f896-4060-9548-5d9c1749d100
497+
md"""
498+
$(blue("The combination of continuous and discrete is often more useful than either one alone."))
499+
"""
500+
501+
# ╔═╡ d9dfe7c5-9211-4707-bb33-a3ff258e10f4
502+
md"""
503+
$(blue("Machine Learning, Pandemics, climate change, etc. show how critical continuous math is these days."))
504+
"""
505+
515506
# ╔═╡ 7edb7c63-c71e-455b-bb78-ddd50475e271
516507
blue("asdf")
517508

@@ -563,9 +554,18 @@ function pyramid(rows::Vector{<:Vector};
563554
""")
564555
end
565556

557+
# ╔═╡ d2d1366b-9b6d-4e54-a0c4-7087f5f063c4
558+
pyramid( [area0,area1], horizontal = true)
559+
560+
# ╔═╡ 6577e546-8f0b-413a-a8bb-b9c12803199d
561+
pyramid([area0,area1,area2], horizontal = true)
562+
566563
# ╔═╡ 43d20d56-d56a-47a8-893e-f726c1a99651
567564
pp(x) = colorgoodbad( string(float(π)) , (@sprintf "%.15f" x) )
568565

566+
# ╔═╡ 893a56b0-f5d0-4f8d-ba15-1048180a7e53
567+
pyramid([pp.(area0), pp.(area1), pp.(area2), pp.(area3), pp.(area4)], horizontal = true)
568+
569569
# ╔═╡ 00000000-0000-0000-0000-000000000001
570570
PLUTO_PROJECT_TOML_CONTENTS = """
571571
[deps]
@@ -590,9 +590,9 @@ SpecialFunctions = "~2.1.7"
590590
PLUTO_MANIFEST_TOML_CONTENTS = """
591591
# This file is machine-generated - editing it directly is not advised
592592
593-
julia_version = "1.8.0"
593+
julia_version = "1.8.5"
594594
manifest_format = "2.0"
595-
project_hash = "7b0816359398430656803f7159cb23845053f1da"
595+
project_hash = "7eb898389f6ce55b399a8264a9d23a1650734390"
596596
597597
[[deps.AbstractPlutoDingetjes]]
598598
deps = ["Pkg"]
@@ -629,7 +629,7 @@ uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
629629
version = "1.0.8+0"
630630
631631
[[deps.Cairo_jll]]
632-
deps = ["Artifacts", "Bzip2_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
632+
deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
633633
git-tree-sha1 = "4b859a208b2397a7a623a03449e4636bdb17bcf2"
634634
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
635635
version = "1.16.1+1"
@@ -679,7 +679,7 @@ version = "3.46.0"
679679
[[deps.CompilerSupportLibraries_jll]]
680680
deps = ["Artifacts", "Libdl"]
681681
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
682-
version = "0.5.2+0"
682+
version = "1.0.1+0"
683683
684684
[[deps.Compose]]
685685
deps = ["Base64", "Colors", "DataStructures", "Dates", "IterTools", "JSON", "LinearAlgebra", "Measures", "Printf", "Random", "Requires", "Statistics", "UUIDs"]
@@ -832,9 +832,9 @@ version = "0.21.0+0"
832832
833833
[[deps.Glib_jll]]
834834
deps = ["Artifacts", "Gettext_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Libiconv_jll", "Libmount_jll", "PCRE2_jll", "Pkg", "Zlib_jll"]
835-
git-tree-sha1 = "fb83fbe02fe57f2c068013aa94bcdf6760d3a7a7"
835+
git-tree-sha1 = "d3b3624125c1474292d0d8ed0f65554ac37ddb23"
836836
uuid = "7746bdde-850d-59dc-9ae8-88ece973131d"
837-
version = "2.74.0+1"
837+
version = "2.74.0+2"
838838
839839
[[deps.GraphPlot]]
840840
deps = ["ArnoldiMethod", "ColorTypes", "Colors", "Compose", "DelimitedFiles", "Graphs", "LinearAlgebra", "Random", "SparseArrays"]
@@ -1019,9 +1019,9 @@ version = "1.42.0+0"
10191019
10201020
[[deps.Libiconv_jll]]
10211021
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
1022-
git-tree-sha1 = "42b62845d70a619f063a7da093d995ec8e15e778"
1022+
git-tree-sha1 = "c7cb1f5d892775ba13767a87c7ada0b980ea0a71"
10231023
uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531"
1024-
version = "1.16.1+1"
1024+
version = "1.16.1+2"
10251025
10261026
[[deps.Libmount_jll]]
10271027
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
@@ -1205,9 +1205,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
12051205
12061206
[[deps.Qt5Base_jll]]
12071207
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Fontconfig_jll", "Glib_jll", "JLLWrappers", "Libdl", "Libglvnd_jll", "OpenSSL_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libxcb_jll", "Xorg_xcb_util_image_jll", "Xorg_xcb_util_keysyms_jll", "Xorg_xcb_util_renderutil_jll", "Xorg_xcb_util_wm_jll", "Zlib_jll", "xkbcommon_jll"]
1208-
git-tree-sha1 = "c6c0f690d0cc7caddb74cef7aa847b824a16b256"
1208+
git-tree-sha1 = "0c03844e2231e12fda4d0086fd7cbe4098ee8dc5"
12091209
uuid = "ea2cea3b-5b76-57ae-a6ef-0a8af62496e1"
1210-
version = "5.15.3+1"
1210+
version = "5.15.3+2"
12111211
12121212
[[deps.REPL]]
12131213
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
@@ -1352,7 +1352,7 @@ version = "1.10.0"
13521352
[[deps.Tar]]
13531353
deps = ["ArgTools", "SHA"]
13541354
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
1355-
version = "1.10.0"
1355+
version = "1.10.1"
13561356
13571357
[[deps.TensorCore]]
13581358
deps = ["LinearAlgebra"]
@@ -1618,8 +1618,8 @@ version = "1.4.1+0"
16181618
"""
16191619

16201620
# ╔═╡ Cell order:
1621+
# ╟─01506de2-918a-11eb-2a4d-c554a6e54631
16211622
# ╠═d155ea12-9628-11eb-347f-7754a33fd403
1622-
# ╠═01506de2-918a-11eb-2a4d-c554a6e54631
16231623
# ╟─877deb2c-702b-457b-a54b-f27c277928d4
16241624
# ╟─ee349b52-9189-11eb-2b86-b5dc15ebe432
16251625
# ╟─43e39a6c-918a-11eb-2408-93563b4fb8c1

0 commit comments

Comments
 (0)