diff --git a/Project.toml b/Project.toml index 516f264..2d0aa20 100644 --- a/Project.toml +++ b/Project.toml @@ -3,6 +3,17 @@ uuid = "ce1ef771-b552-5ca6-80e4-7358b8c578e2" authors = ["Florian Oswald "] version = "0.1.0" +[deps] +ApproXD = "f0e97480-066f-5960-9ba5-e027352bc8af" +ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" +BasisMatrices = "08854c51-b66b-5062-a90d-8e7ae4547a49" +Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" +FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" +PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" + [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/q1.png b/q1.png new file mode 100644 index 0000000..5652ba3 Binary files /dev/null and b/q1.png differ diff --git a/q2.png b/q2.png new file mode 100644 index 0000000..3c745aa Binary files /dev/null and b/q2.png differ diff --git a/q3.png b/q3.png new file mode 100644 index 0000000..35c330b Binary files /dev/null and b/q3.png differ diff --git a/q4.png b/q4.png new file mode 100644 index 0000000..12a8ca1 Binary files /dev/null and b/q4.png differ diff --git a/q5.png b/q5.png new file mode 100644 index 0000000..0040e4d Binary files /dev/null and b/q5.png differ diff --git a/q6.png b/q6.png new file mode 100644 index 0000000..f23a048 Binary files /dev/null and b/q6.png differ diff --git a/q7.png b/q7.png new file mode 100644 index 0000000..59867dc Binary files /dev/null and b/q7.png differ diff --git a/src/HWfuncapp.jl b/src/HWfuncapp.jl index 732fe3f..fcb20f9 100644 --- a/src/HWfuncapp.jl +++ b/src/HWfuncapp.jl @@ -6,6 +6,7 @@ using FastGaussQuadrature # to get chebyshevnodes # you will see me often qualify code with `PyPlot.plot` or so. using PyPlot import ApproXD: getBasis, BSpline +using LinearAlgebra using Distributions using ApproxFun using Plots @@ -13,30 +14,98 @@ using Plots ChebyT(x,deg) = cos(acos(x)*deg) unitmap(x,lb,ub) = 2 .* (x .- lb) ./ (ub .- lb) .- 1 #[a,b] -> [-1,1] -function q1(n) +export q1, q2, q3, q4, q5, q6, q7, runall + +function q1(n=15) f(x) = x .+ 2x.^2 - exp.(-x) + n_new = 100 + + deg = n:-1:1 + points = range(-3, 3, length=n_new) + + node = 3 * cos.((2 .* deg .- 1) .* pi ./ (2 .* n)) + y = f(node) + cheb = zeros(n, n) + for i in 1:n + cheb[:, i] = ChebyT.(unitmap(node, -3, 3), i - 1) + end + c = cheb^-1 * y + + estim = zeros(n_new) + for i in 1:n + estim += c[i] * ChebyT.(unitmap(points, -3, 3), i - 1) + end + + subplot(122) + PyPlot.plot(points, f.(points), label="True function") + PyPlot.scatter(points, estim, color="red", s=2, label="approximation") + xlabel("x") + ylabel("y") + title("Chebyshev approximation") + legend() + subplot(121) + PyPlot.plot(points, f.(points) - estim) + title("Error") # without using PyPlot, just erase the `PyPlot.` part PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q1.png")) + + err = sum(abs.(f.(points) - estim)) return Dict(:error=>maximum(abs,err)) end function q2(b::Number) @assert b > 0 - # use ApproxFun.jl to do the same: + f(x) = x .+ 2x.^2 - exp.(-x) - Plots.savefig(p,joinpath(dirname(@__FILE__),"..","q2.png")) + precision = 100 + points = range(-3, 3, length=precision) + # use ApproxFun.jl to do the same: + x = Fun(f, Chebyshev(-b..b)) + estim = x.(points) + + subplot(122) + PyPlot.plot(points, f.(points), label="True function") + PyPlot.scatter(points, estim, color="red", s=2, label="approximation") + xlabel("x") + ylabel("y") + title("Chebyshev approximation") + legend() + subplot(121) + PyPlot.plot(points, f.(points) - estim) + title("Error") + + PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q2.png")) end function q3(b::Number) + x = Fun(identity, -b..b) + f = sin(x^2) + g = cos(x) + h = f - g + r = roots(h) + + p = Plots.plot(h, labels="h") + Plots.scatter!(r, h.(r), labels="roots.h") + Plots.savefig(joinpath(dirname(@__FILE__),"..","q3.png")) # p is your plot + g = cumsum(h) + integral = g(0) - g(-b) return (p,integral) end # optinal function q4() - + precision = 10000 + points = range(-1, stop = 1, length=precision) + fig = PyPlot.plot(points, ChebyT.(points, 0), label=0) + for i in 1:8 + fig = PyPlot.plot(points, ChebyT.(points, i), label=i) + end + title("Chebyshev basis") + legend() + PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q4.png")) return fig end @@ -56,7 +125,7 @@ mutable struct ChebyType function ChebyType(_nodes::Union{Vector,LinRange},_deg,_lb,_ub,_f::Function) n = length(_nodes) y = _f(_nodes) - _basis = Float64[ChebyT(unitmap(_nodes[i],_lb,_ub),j) for i=1:n,j=0:_deg] + _basis = Float64[ChebyT(unitmap(_nodes[i],_lb,_ub),j) for i=1:n,j=0:_deg - 1] _coefs = _basis \ y # type `?\` to find out more about the backslash operator. depending the args given, it performs a different operation # create a ChebyComparer with those values new(_f,_nodes,_basis,_coefs,_deg,_lb,_ub) @@ -67,8 +136,8 @@ end function predict(Ch::ChebyType,x_new) true_new = Ch.f(x_new) - basis_new = Float64[ChebyT(unitmap(x_new[i],Ch.lb,Ch.ub),j) for i=1:length(x_new),j=0:Ch.deg] - basis_nodes = Float64[ChebyT(unitmap(Ch.nodes[i],Ch.lb,Ch.ub),j) for i=1:length(Ch.nodes),j=0:Ch.deg] + basis_new = Float64[ChebyT(unitmap(x_new[i],Ch.lb,Ch.ub),j) for i=1:length(x_new),j=0:Ch.deg - 1] + basis_nodes = Float64[ChebyT(unitmap(Ch.nodes[i],Ch.lb,Ch.ub),j) for i=1:length(Ch.nodes),j=0:Ch.deg - 1] preds = basis_new * Ch.coefs preds_nodes = basis_nodes * Ch.coefs @@ -78,8 +147,40 @@ end function q5(deg=(5,9,15),lb=-1.0,ub=1.0) runge(x) = 1.0 ./ (1 .+ 25 .* x.^2) + f(x) = x .+ 2x.^2 - exp.(-x) + precision = 10000 + points = range(lb, ub, length=precision) + cheb_m = zeros(precision, length(deg)) + uni_m = zeros(precision, length(deg)) + + for (i, d) in enumerate(deg) + degse = d:-1:1 + node = 1/2 .* (ub .+ lb) .+ 1/2 .* (ub - lb) .* cos.((2 .* degse .- 1) .* pi ./ (2 .* d)) + uni = LinRange(lb, ub, d) + cheb = ChebyType(node, d, lb, ub, runge) + unic = ChebyType(uni, d, lb, ub, runge) + + pred_cheb = predict(cheb, points) + pred_uni = predict(unic, points) + + cheb_m[:, i] = pred_cheb["preds"] + uni_m[:, i] = pred_uni["preds"] + end - + subplot(121) + PyPlot.plot(points, runge.(points), label="True") + for (i, d) in enumerate(deg) + PyPlot.plot(points, cheb_m[:, i,], label=d) + end + title("Chebyshev nodes") + legend() + subplot(122) + PyPlot.plot(points, runge.(points), label="True") + for (i, d) in enumerate(deg) + PyPlot.plot(points, uni_m[:, i,], label=d) + end + title("Uniform nodes") + legend() PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q5.png")) end @@ -87,16 +188,66 @@ end function q6() - + f(x) = abs(x)^0.5 + precision = 63 + x = range(-1, 1, length=precision) + y = f.(x) # compare 2 knot vectors with runge's function + myknots = vcat(range(-1,stop = -0.1,length = 5), 0, 0, 0, range(0.1,stop = 1,length =5)) + bs = BSpline(13, 3, -5, 5) + bs2 = BSpline(myknots, 3) + B = Array(getBasis(collect(x), bs)) + B2 = Array(getBasis(collect(x), bs2)) + c = B \ y + c2 = B2 \ y + subplot(311) + PyPlot.plot(x, y, label="True function") + PyPlot.scatter(x, B * c, color="red", s=2, label="Approximation") + title("Uniform knot vector") + legend() + subplot(312) + PyPlot.plot(x, y, label="True function") + PyPlot.scatter(x, B2 * c2, color="red", s=2, label="Approximation") + title("Knot multiplicity x=0") + legend() + subplot(313) + PyPlot.plot(x, y - B * c, color="blue", label="Uniform") + PyPlot.plot(x, y - B2 * c2, color="red", label="Knot multiplicity") + title("Error plots") + legend() PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q6.png")) end function q7() - - + f(x) = abs(x)^0.5 + precision = 63 + x = range(-1, 1, length=precision) + myknots = vcat(range(-1,stop = -0.1,length = 5), 0, 0, 0, range(0.1,stop = 1,length =5)) + + y = f.(x) + bs = BSpline(13, 3, -1, 1) + bs2 = BSpline(myknots, 3) + B = Array(getBasis(collect(x), bs)) + B2 = Array(getBasis(collect(x), bs2)) + c = B \ y + c2 = B2 \ y + subplot(311) + PyPlot.plot(x, y, label="True function") + PyPlot.scatter(x, B * c, color="red", s=2, label="Approximation") + title("Uniform knot vector") + legend() + subplot(312) + PyPlot.plot(x, y, label="True function") + PyPlot.scatter(x, B2 * c2, color="red", s=2, label="Approximation") + title("Knot multiplicity x=0") + legend() + subplot(313) + PyPlot.plot(x, y - B * c, color="blue", label="Uniform") + PyPlot.plot(x, y - B2 * c2, color="red", label="Knot multiplicity") + title("Error plots") + legend() PyPlot.savefig(joinpath(dirname(@__FILE__),"..","q7.png")) end diff --git a/src/Manifest.toml b/src/Manifest.toml new file mode 100644 index 0000000..7ceea6f --- /dev/null +++ b/src/Manifest.toml @@ -0,0 +1,522 @@ +# This file is machine-generated - editing it directly is not advised + +[[AbstractFFTs]] +deps = ["Compat", "LinearAlgebra"] +git-tree-sha1 = "8d59c3b1463b5e0ad05a3698167f85fac90e184d" +uuid = "621f4979-c628-5d54-868e-fcf4e3e8185c" +version = "0.3.2" + +[[ApproxFun]] +deps = ["AbstractFFTs", "BandedMatrices", "BlockArrays", "BlockBandedMatrices", "Calculus", "DSP", "DomainSets", "DualNumbers", "FFTW", "FastGaussQuadrature", "FastTransforms", "FillArrays", "InfiniteArrays", "IntervalSets", "LazyArrays", "LinearAlgebra", "LowRankApprox", "Random", "RecipesBase", "SparseArrays", "SpecialFunctions", "StaticArrays", "Statistics", "Test", "ToeplitzMatrices"] +git-tree-sha1 = "2fbd592ab81eec53b7f256e771507a10ae38a3e6" +uuid = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" +version = "0.10.4" + +[[ArnoldiMethod]] +deps = ["DelimitedFiles", "LinearAlgebra", "Random", "SparseArrays", "StaticArrays", "Test"] +git-tree-sha1 = "2b6845cea546604fb4dca4e31414a6a59d39ddcd" +uuid = "ec485272-7323-5ecc-a04f-4719b315124d" +version = "0.0.4" + +[[Arpack]] +deps = ["BinaryProvider", "Libdl", "LinearAlgebra", "Random", "SparseArrays", "Test"] +git-tree-sha1 = "1ce1ce9984683f0b6a587d5bdbc688ecb480096f" +uuid = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97" +version = "0.3.0" + +[[BandedMatrices]] +deps = ["FillArrays", "LazyArrays", "LinearAlgebra", "MatrixFactorizations", "Random", "SparseArrays", "Test"] +git-tree-sha1 = "1249cc93e4a685e8f0aaf1aa858fdd636551c754" +uuid = "aae01518-5342-5314-be14-df237901396f" +version = "0.9.0" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[BasisMatrices]] +deps = ["Combinatorics", "LinearAlgebra", "QuantEcon", "SparseArrays", "Statistics", "Test"] +git-tree-sha1 = "f472e8faf48640daea2e0b446cb820252a4e2b06" +uuid = "08854c51-b66b-5062-a90d-8e7ae4547a49" +version = "0.6.0" + +[[BinDeps]] +deps = ["Compat", "Libdl", "SHA", "URIParser"] +git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" +uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" +version = "0.8.10" + +[[BinaryProvider]] +deps = ["Libdl", "Pkg", "SHA", "Test"] +git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" +uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" +version = "0.5.3" + +[[BlockArrays]] +deps = ["Base64", "LinearAlgebra", "SparseArrays", "Test"] +git-tree-sha1 = "68a477c2f2ddbbe518dc31a42aaf2df38bdfd93c" +uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" +version = "0.7.0" + +[[BlockBandedMatrices]] +deps = ["BandedMatrices", "BlockArrays", "Distributed", "FillArrays", "LazyArrays", "LinearAlgebra", "Pkg", "Profile", "Random", "SharedArrays", "SparseArrays", "Statistics", "Test"] +git-tree-sha1 = "51536cbbc652df93b85861139b6536c81096011d" +uuid = "ffab5731-97b5-5995-9138-79e8c1846df0" +version = "0.3.4" + +[[CMake]] +deps = ["BinDeps", "Libdl", "Test"] +git-tree-sha1 = "6e39bef3cbb8321e8a464b18a5c20d7cef813938" +uuid = "631607c0-34d2-5d66-819e-eb0f9aa2061a" +version = "1.1.1" + +[[CMakeWrapper]] +deps = ["BinDeps", "CMake", "Libdl", "Parameters", "Test"] +git-tree-sha1 = "2b43d451639984e3571951cc687b8509b0a86c6d" +uuid = "d5fb7624-851a-54ee-a528-d3f3bac0b4a0" +version = "0.2.2" + +[[CSTParser]] +deps = ["LibGit2", "Test", "Tokenize"] +git-tree-sha1 = "437c93bc191cd55957b3f8dee7794b6131997c56" +uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f" +version = "0.5.2" + +[[Calculus]] +deps = ["Compat"] +git-tree-sha1 = "f60954495a7afcee4136f78d1d60350abd37a409" +uuid = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" +version = "0.4.1" + +[[Combinatorics]] +deps = ["LinearAlgebra", "Polynomials", "Test"] +git-tree-sha1 = "50b3ae4d643dc27eaff69fb6be06ee094d5500c9" +uuid = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" +version = "0.7.0" + +[[CommonSubexpressions]] +deps = ["Test"] +git-tree-sha1 = "efdaf19ab11c7889334ca247ff4c9f7c322817b0" +uuid = "bbf7d656-a473-5ed7-a52c-81e309532950" +version = "0.2.0" + +[[Compat]] +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "84aa74986c5b9b898b0d1acaf3258741ee64754f" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "2.1.0" + +[[Conda]] +deps = ["Compat", "JSON", "VersionParsing"] +git-tree-sha1 = "b625d802587c2150c279a40a646fba63f9bd8187" +uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" +version = "1.2.0" + +[[DSP]] +deps = ["AbstractFFTs", "Compat", "FFTW", "LinearAlgebra", "Polynomials", "Random", "Reexport", "SpecialFunctions"] +git-tree-sha1 = "5ec38ebc4ddf6320ad50b826eb8fd7fb521993a5" +uuid = "717857b8-e6f2-59f4-9121-6e50c889abd2" +version = "0.5.2" + +[[DataStructures]] +deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"] +git-tree-sha1 = "ca971f03e146cf144a9e2f2ce59674f5bf0e8038" +uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +version = "0.15.0" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[DiffEqDiffTools]] +deps = ["LinearAlgebra", "Test"] +git-tree-sha1 = "30f82c63cb9d293513b360572e283c19577fcf82" +uuid = "01453d9d-ee7c-5054-8395-0335cb756afa" +version = "0.8.1" + +[[DiffResults]] +deps = ["Compat", "StaticArrays"] +git-tree-sha1 = "34a4a1e8be7bc99bc9c611b895b5baf37a80584c" +uuid = "163ba53b-c6d8-5494-b064-1a9d43ac40c5" +version = "0.0.4" + +[[DiffRules]] +deps = ["Random", "Test"] +git-tree-sha1 = "dc0869fb2f5b23466b32ea799bd82c76480167f7" +uuid = "b552c78f-8df3-52c6-915a-8e097449b14b" +version = "0.0.10" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[Distributions]] +deps = ["Distributed", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SpecialFunctions", "Statistics", "StatsBase", "StatsFuns", "Test"] +git-tree-sha1 = "dec0ebacfbc3a2126c614ab5e903c9ef063688d0" +uuid = "31c24e10-a181-5473-b8eb-7969acd0382f" +version = "0.17.0" + +[[DomainSets]] +deps = ["IntervalSets", "LinearAlgebra", "StaticArrays", "Statistics", "Test"] +git-tree-sha1 = "84beb94a9595c1a7a692880b424f82470a326976" +uuid = "5b8099bc-c8ec-5219-889f-1d9e522a28bf" +version = "0.0.1" + +[[DualNumbers]] +deps = ["Calculus", "LinearAlgebra", "NaNMath", "SpecialFunctions", "Test"] +git-tree-sha1 = "e178a6768dad879ff1abfc1c612406856bb06ce0" +uuid = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74" +version = "0.6.2" + +[[FFTW]] +deps = ["AbstractFFTs", "BinaryProvider", "Compat", "Conda", "Libdl", "LinearAlgebra", "Reexport", "Test"] +git-tree-sha1 = "29cda58afbf62f35b1a094882ad6c745a47b2eaa" +uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" +version = "0.2.4" + +[[FastGaussQuadrature]] +deps = ["Compat", "LinearAlgebra", "SpecialFunctions"] +git-tree-sha1 = "769ac4057ed875f433372e9a571a2cb86347d1be" +uuid = "442a2c76-b920-505d-bb47-c5924d526838" +version = "0.3.3" + +[[FastTransforms]] +deps = ["AbstractFFTs", "Compat", "DSP", "FFTW", "HierarchicalMatrices", "LinearAlgebra", "LowRankApprox", "ProgressMeter", "SpecialFunctions", "ToeplitzMatrices"] +git-tree-sha1 = "051b635520e679c8c72aa43a40d86e2c226bbb7f" +uuid = "057dd010-8810-581a-b7be-e3fc3b93f78c" +version = "0.4.2" + +[[FillArrays]] +deps = ["LinearAlgebra", "Random", "SparseArrays", "Test"] +git-tree-sha1 = "2def0123a4f3572234405b0e3d80bfe5d3e1a2a4" +uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" +version = "0.5.0" + +[[ForwardDiff]] +deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "InteractiveUtils", "LinearAlgebra", "NaNMath", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Test"] +git-tree-sha1 = "4c4d727f1b7e0092134fabfab6396b8945c1ea5b" +uuid = "f6369f11-7733-5829-9624-2563aa707210" +version = "0.10.3" + +[[HierarchicalMatrices]] +deps = ["Compat"] +git-tree-sha1 = "acfcaf1aa47d038f593f301ed3bdebc0129035bc" +uuid = "7c893195-952b-5c83-bb6e-be12f22eed51" +version = "0.1.4" + +[[InfiniteArrays]] +deps = ["DSP", "FillArrays", "LazyArrays", "LinearAlgebra", "SparseArrays", "Statistics", "Test"] +git-tree-sha1 = "ceb060a732135d83d75f4b4059374d9d35e27b03" +uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" +version = "0.0.3" + +[[Inflate]] +deps = ["Pkg", "Printf", "Random", "Test"] +git-tree-sha1 = "b7ec91c153cf8bff9aff58b39497925d133ef7fd" +uuid = "d25df0c9-e2be-5dd7-82c8-3ad0b3e990b9" +version = "0.1.1" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[IntervalSets]] +deps = ["Compat"] +git-tree-sha1 = "9dc556002f23740de13946e8c2e41798e09a9249" +uuid = "8197267c-284f-5f27-9208-e0e47529a953" +version = "0.3.1" + +[[JSON]] +deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] +git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.20.0" + +[[LazyArrays]] +deps = ["FillArrays", "LinearAlgebra", "MacroTools", "StaticArrays", "Test"] +git-tree-sha1 = "4439e840fe68cbcde806fcc625d05166227a56a5" +uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02" +version = "0.8.0" + +[[LibGit2]] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LightGraphs]] +deps = ["ArnoldiMethod", "Base64", "DataStructures", "DelimitedFiles", "Distributed", "Inflate", "LinearAlgebra", "Markdown", "Random", "SharedArrays", "SimpleTraits", "SparseArrays", "Statistics", "Test"] +git-tree-sha1 = "c7222c370d5cf6d4e08ae40bddd8c0db6852dfb1" +uuid = "093fc24a-ae57-5d10-9952-331d41423f4d" +version = "1.2.0" + +[[LineSearches]] +deps = ["LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "Printf", "Test"] +git-tree-sha1 = "54eb90e8dbe745d617c78dee1d6ae95c7f6f5779" +uuid = "d3d80556-e9d4-5f37-9878-2ab0fcc64255" +version = "7.0.1" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[LowRankApprox]] +deps = ["FFTW", "FillArrays", "LinearAlgebra", "Nullables", "Random", "SparseArrays", "Test"] +git-tree-sha1 = "dd7586356fe6bc41057ee5082487c90f6790b339" +uuid = "898213cb-b102-5a47-900c-97e73b919f73" +version = "0.2.2" + +[[MacroTools]] +deps = ["CSTParser", "Compat", "DataStructures", "Test"] +git-tree-sha1 = "daecd9e452f38297c686eba90dba2a6d5da52162" +uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" +version = "0.5.0" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MathProgBase]] +deps = ["Compat"] +git-tree-sha1 = "3bf2e534e635df810e5f4b4f1a8b6de9004a0d53" +uuid = "fdba3010-5040-5b88-9595-932c9decdf73" +version = "0.7.7" + +[[MatrixFactorizations]] +deps = ["LinearAlgebra", "Random", "Test"] +git-tree-sha1 = "cebc71d929a846dda61400f1cf3ba69c7e75fa63" +uuid = "a3b82374-2e81-5b9e-98ce-41277c0e4c87" +version = "0.0.4" + +[[Missings]] +deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] +git-tree-sha1 = "d1d2585677f2bd93a97cfeb8faa7a0de0f982042" +uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" +version = "0.4.0" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[NLSolversBase]] +deps = ["Calculus", "DiffEqDiffTools", "DiffResults", "Distributed", "ForwardDiff", "LinearAlgebra", "Random", "SparseArrays", "Test"] +git-tree-sha1 = "0c6f0e7f2178f78239cfb75310359eed10f2cacb" +uuid = "d41bc354-129a-5804-8e4c-c37616107c6c" +version = "7.3.1" + +[[NLopt]] +deps = ["BinaryProvider", "CMakeWrapper", "Libdl", "MathProgBase", "Test"] +git-tree-sha1 = "b46237debcacd4fed7bbeb31200667a75b90384f" +uuid = "76087f3c-5699-56af-9a33-bf431cd00edd" +version = "0.5.1" + +[[NaNMath]] +deps = ["Compat"] +git-tree-sha1 = "ce3b85e484a5d4c71dd5316215069311135fa9f2" +uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" +version = "0.3.2" + +[[Nullables]] +deps = ["Compat"] +git-tree-sha1 = "ae1a63457e14554df2159b0b028f48536125092d" +uuid = "4d1e1d77-625e-5b40-9113-a560ec7a8ecd" +version = "0.0.8" + +[[Optim]] +deps = ["Calculus", "DiffEqDiffTools", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "Random", "SparseArrays", "StatsBase", "Test"] +git-tree-sha1 = "a626e09c1f7f019b8f3a30a8172c7b82d2f4810b" +uuid = "429524aa-4258-5aef-a3af-852621145aeb" +version = "0.18.1" + +[[OrderedCollections]] +deps = ["Random", "Serialization", "Test"] +git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" +uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" +version = "1.0.2" + +[[PDMats]] +deps = ["Arpack", "LinearAlgebra", "SparseArrays", "SuiteSparse", "Test"] +git-tree-sha1 = "b6c91fc0ab970c0563cbbe69af18d741a49ce551" +uuid = "90014a1f-27ba-587c-ab20-58faa44d9150" +version = "0.9.6" + +[[Parameters]] +deps = ["Markdown", "OrderedCollections", "REPL", "Test"] +git-tree-sha1 = "70bdbfb2bceabb15345c0b54be4544813b3444e4" +uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a" +version = "0.10.3" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Polynomials]] +deps = ["LinearAlgebra", "SparseArrays", "Test"] +git-tree-sha1 = "62142bd65d3f8aeb2226ec64dd8493349147df94" +uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" +version = "0.5.2" + +[[PositiveFactorizations]] +deps = ["LinearAlgebra", "Test"] +git-tree-sha1 = "86ae7329c4b5c266acf5c7c524a972300d991e1c" +uuid = "85a6dd25-e78a-55b7-8502-1745935b8125" +version = "0.2.1" + +[[Primes]] +deps = ["Test"] +git-tree-sha1 = "ff1a2323cb468ec5f201838fcbe3c232266b1f95" +uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae" +version = "0.4.0" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[Profile]] +deps = ["Printf"] +uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" + +[[ProgressMeter]] +deps = ["Distributed", "Printf", "Random", "Test"] +git-tree-sha1 = "48058bc11607676e5bbc0b974af79106c6200787" +uuid = "92933f4c-e287-5a05-a399-4b506db050ca" +version = "0.9.0" + +[[QuadGK]] +deps = ["DataStructures", "LinearAlgebra", "Test"] +git-tree-sha1 = "3ce467a8e76c6030d4c3786e7d3a73442017cdc0" +uuid = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +version = "2.0.3" + +[[QuantEcon]] +deps = ["DSP", "Distributions", "FFTW", "LightGraphs", "LinearAlgebra", "Markdown", "NLopt", "Optim", "Pkg", "Primes", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsBase", "Test"] +git-tree-sha1 = "d1f545bef50bbd83b04abbaf3e226e04cde34b9c" +uuid = "fcd29c91-0bd7-5a09-975d-7ac3f643a60c" +version = "0.15.0" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[RecipesBase]] +deps = ["Random", "Test"] +git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" +uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" +version = "0.6.0" + +[[Reexport]] +deps = ["Pkg"] +git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" +uuid = "189a3867-3050-52da-a836-e630ba90ab69" +version = "0.2.0" + +[[Rmath]] +deps = ["BinaryProvider", "Libdl", "Random", "Statistics", "Test"] +git-tree-sha1 = "9a6c758cdf73036c3239b0afbea790def1dabff9" +uuid = "79098fc4-a85e-5d69-aa6a-4863f24498fa" +version = "0.5.0" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" + +[[SimpleTraits]] +deps = ["InteractiveUtils", "MacroTools", "Test"] +git-tree-sha1 = "c0a542b8d5e369b179ccd296b2ca987f6da5da0a" +uuid = "699a6c99-e7fa-54fc-8d76-47d257e15c1d" +version = "0.8.0" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SortingAlgorithms]] +deps = ["DataStructures", "Random", "Test"] +git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd" +uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" +version = "0.3.1" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[SpecialFunctions]] +deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] +git-tree-sha1 = "0b45dc2e45ed77f445617b99ff2adf0f5b0f23ea" +uuid = "276daf66-3868-5448-9aa4-cd146d93841b" +version = "0.7.2" + +[[StaticArrays]] +deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] +git-tree-sha1 = "3841b39ed5f047db1162627bf5f80a9cd3e39ae2" +uuid = "90137ffa-7385-5640-81b9-e52037218182" +version = "0.10.3" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[StatsBase]] +deps = ["DataStructures", "DelimitedFiles", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"] +git-tree-sha1 = "435707791dc85a67d98d671c1c3fcf1b20b00f94" +uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" +version = "0.29.0" + +[[StatsFuns]] +deps = ["Rmath", "SpecialFunctions", "Test"] +git-tree-sha1 = "b3a4e86aa13c732b8a8c0ba0c3d3264f55e6bb3e" +uuid = "4c63d2b9-4356-54db-8cca-17b64c39e42c" +version = "0.8.0" + +[[SuiteSparse]] +deps = ["Libdl", "LinearAlgebra", "SparseArrays"] +uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[ToeplitzMatrices]] +deps = ["Compat", "FFTW", "LinearAlgebra", "StatsBase"] +git-tree-sha1 = "5242fdbeafe1f2e0187935bb13a5c651d5626106" +uuid = "c751599d-da0a-543b-9d20-d0a503d91d24" +version = "0.5.0" + +[[Tokenize]] +deps = ["Printf", "Test"] +git-tree-sha1 = "3e83f60b74911d3042d3550884ca2776386a02b8" +uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" +version = "0.5.3" + +[[URIParser]] +deps = ["Test", "Unicode"] +git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" +uuid = "30578b45-9adc-5946-b283-645ec420af67" +version = "0.4.0" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" + +[[VersionParsing]] +deps = ["Compat"] +git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" +uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" +version = "1.1.3" diff --git a/src/Project.toml b/src/Project.toml new file mode 100644 index 0000000..111a4b0 --- /dev/null +++ b/src/Project.toml @@ -0,0 +1,4 @@ +[deps] +ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f" +BasisMatrices = "08854c51-b66b-5062-a90d-8e7ae4547a49" +SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" diff --git a/test/runtests.jl b/test/runtests.jl index 6453446..d7694f2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,8 +3,15 @@ using Test @testset "HWfuncapp.jl" begin # test that q1 with 15 nodes has an error smaller than 1e-9 - + @testset "test error" begin + err = q1() + @test err[:error] < 1e-9 + end # test that the integral of function h [-10,0] ≈ 1.46039789878568 + @testset "test integral" begin + integral = q3(10)[2] + @test integral ≈ 1.46039789878568 + end - @test false # by default fail + #@test false # by default fail end