Skip to content

Commit 8801808

Browse files
committed
link
1 parent 4adf65f commit 8801808

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

notebooks/week3/optimization1.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,9 @@ md"""
244244
"""
245245

246246
# ╔═╡ 34b7e91e-d67f-4554-b985-b9100adda733
247-
begin
248-
# long form taking a vector x
249-
function rosen₁(x)
250-
(1-x[1])^2 + 5*(x[2] - x[1]^2)^2
251-
end
252-
# short form taking a vector x
253-
rosen₂(x) = (1-x[1])^2 + 5*(x[2] - x[1]^2)^2
247+
# long form taking a vector x
248+
function rosen₁(x)
249+
(1-x[1])^2 + 5*(x[2] - x[1]^2)^2
254250
end
255251

256252
# ╔═╡ 4d2a5726-2704-4b63-b334-df5175278b18
@@ -259,6 +255,10 @@ begin
259255
result = optimize(rosen₁, zeros(2), NelderMead())
260256
end
261257

258+
# ╔═╡ 3270f9e3-e232-4752-949f-12f984581b19
259+
# short form taking a vector x
260+
rosen₂(x) = (1-x[1])^2 + 5*(x[2] - x[1]^2)^2
261+
262262
# ╔═╡ 2dbb5b13-790a-4ab7-95b1-b833c4cb027a
263263
rosen₁([1.1,0.4]) == rosen₂([1.1,0.4])
264264

@@ -287,6 +287,9 @@ begin
287287
rosen₄(x,y) = (1-x[1])^2 + 5*(x[2] - x[1]^2)^2
288288
end
289289

290+
# ╔═╡ 2eae1d35-df83-415f-87a5-1a5e0d1d649e
291+
rosen₄([1,1])
292+
290293
# ╔═╡ 7172d082-e6d2-419b-8bb6-75e30f1b4dfe
291294
md"""
292295
ok fine, but it's often useful to keep data in a vector. Can we have the readibility of the `x,y` formulation, with the vector input?
@@ -415,7 +418,7 @@ let
415418
c = 2.2
416419
∂u∂c = (u(c + h) - u(c)) / h # definition from above!
417420

418-
Dict(:finite_diff => ∂u∂c, :truth_wiktor => c^-2)
421+
Dict(:finite_diff => ∂u∂c, :truth_Paolo => c^-2)
419422
end
420423

421424
# ╔═╡ 645ef857-aff9-4dee-bfd6-72fe9d542375
@@ -2264,10 +2267,12 @@ version = "1.4.1+1"
22642267
# ╟─3af8c139-2e6c-4830-9b67-96f78356f521
22652268
# ╟─dd9bfbb1-aecf-458f-9a05-a93ff78fd741
22662269
# ╠═34b7e91e-d67f-4554-b985-b9100adda733
2270+
# ╠═3270f9e3-e232-4752-949f-12f984581b19
22672271
# ╠═2dbb5b13-790a-4ab7-95b1-b833c4cb027a
22682272
# ╟─f51233c4-ec66-4517-9109-5309601d1d87
22692273
# ╟─1d698018-8b77-490d-ad3a-6c7001aa99ab
22702274
# ╠═3729833f-80d4-4948-8d81-750008c8f16d
2275+
# ╠═2eae1d35-df83-415f-87a5-1a5e0d1d649e
22712276
# ╟─7172d082-e6d2-419b-8bb6-75e30f1b4dfe
22722277
# ╠═e7841458-f641-48cf-8667-1e5b38cbd9f6
22732278
# ╠═abbc5a52-a02c-4f5b-bd1e-af5596455762

notebooks/week4/optimization2.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,16 @@ md"""
253253
* But it's robust (will find global optimizer for large enough $N$)
254254
"""
255255

256+
# ╔═╡ adb4ee25-44cb-4294-b410-f357e26336e1
257+
collect(range(0, 3, length= 100))
258+
256259
# ╔═╡ 4a0dc0c1-ce50-425b-84ca-657c93b10966
257260
begin
258261
prob = UnconstrainedProblems.examples["Rosenbrock"]
259262
ro = prob.f
260263
g! = prob.g!
261264
h! = prob.h!
262-
grid = collect(-1.0:0.11:3); # grid spacing is important!
265+
grid = collect(-1.0:0.01:3); # grid spacing is important!
263266
grid2D = [[i;j] for i in grid,j in grid];
264267
val2D = map(ro,grid2D);
265268
r = findmin(val2D);
@@ -2017,6 +2020,7 @@ version = "1.4.1+0"
20172020
# ╠═20664b8a-59d7-4d80-9926-7a982f72b276
20182021
# ╟─625e38ee-04c1-4792-bf3e-8689bdb4df3b
20192022
# ╟─f7fb3b3c-7c74-45eb-b1fb-c26170056d74
2023+
# ╠═adb4ee25-44cb-4294-b410-f357e26336e1
20202024
# ╠═4a0dc0c1-ce50-425b-84ca-657c93b10966
20212025
# ╟─7a8a9f51-49bc-4b6d-b68d-20f06dd7e350
20222026
# ╟─a6f1e909-9b87-42c7-b47a-d7190ba245bf

website/lecture3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Topic | Notebook
159159
:-----: | :--------:
160160
Intro to Macros | [click for notebook](https://floswald.github.io/julia-bootcamp/10-intro-to-macros.html)
161161
Intro to Differential Equations | [click for notebook](https://floswald.github.io/julia-bootcamp/08-popgrowth.html)
162-
Plotting | [click for notebook](https://floswald.github.io/julia-bootcamp/06-plotting.html)
162+
Plotting with Plots.jl | [click for notebook](https://floswald.github.io/julia-bootcamp/06-plotting.html)
163163
Interactive | [click for notebook](https://floswald.github.io/julia-bootcamp/07-interactive.html)
164164
165165

website/lecture4.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
Topic | Notebook
1212
:-----: | :--------:
1313
Unconstrained Optimization Algorithms | [download notebook or insert URL into pluto browser](https://raw.githubusercontent.com/floswald/NumericalMethods/refs/heads/master/notebooks/week4/optimization2.jl)
14-
Constraints and Linear Programming | [download notebook](https://raw.githubusercontent.com/floswald/NumericalMethods/refs/heads/master/notebooks/week4/optimization3.jl)
14+
Constraints and Linear Programming | [download notebook](https://raw.githubusercontent.com/floswald/NumericalMethods/refs/heads/master/notebooks/week5/optimization3.jl)

0 commit comments

Comments
 (0)