1.MATH347 Homework 0

Topic: TeXmacs and Julia basics
Post date: May 15, 2024
Due date: May 16, 2024

1.1.Background

This homework is meant to familiarize yourself with basic operations within TeXmacs, a public-domain scientific editing platform. The TeXmacs website provides several tutorials. The key features of TeXmacs that motivate adoption of the platform for this course are:

1.2.Theoretical questions

1.2.1.Text editing in TeXmacs

Problem

Write an itemized list of ingredients in your favorite dessert recipe. (Menu->Insert->Itemize)

Answer

1.2.2.Inline mathematics

Problem

The fundamental theorem of calculus states abf(x)dx=F(b)-F(a) for F'(x)=f(x). Apply this result for a=0, b=π, f(x)=sinx, F(x)=-cosx. Write your answer inline.

Answer

1.2.3.Displayed mathematics

Problem

A matrix is a row of column vectors, 𝑨=[ 𝒂1 𝒂2 𝒂n ]m×n, which can be expressed in terms of vector components as

𝑨=[ a11 a12 a1n a21 a22 a2n am1 am2 amn ].

Look up the definition of a Hilbert matrix 𝑯 and write in the above forms, both as a row of column vectors, and as components.

Answer

1.2.4.Julia session - working with numbers

Problem

Insert a Julia session and produce a table of the squares and cubes of the first ten natural numbers.

Answer

1.2.5.Julia session - working with column vectors

Problem

Insert a Julia session and define the vectors

𝒖=[ 1 2 3 ],𝒗=[ -1 0 1 ],𝒘=[ 0 -1 0 ].

Answer

1.2.6.Julia session - working with row vectors

Problem

Insert a Julia session and define the vectors

𝒂=[ 1 2 3 ],𝒃=[ -1 0 1 ],𝒄=[ 0 -1 0 ].

Answer

1.2.7.Julia session - assembling column vectors into a matrix

Problem

Insert a Julia session and define the matrix 𝑿=[ 𝒖 𝒗 𝒘 ].

Answer

1.2.8.Julia session - assembling row vectors into a matrix

Problem

Insert a Julia session and define the matrix

𝒀=[ 𝒂 𝒃 3𝒄 ]

Answer

1.2.9.Julia session - componentwise definition of a matrix

Problem

Insert a Julia session and display the Hilbert matrix 𝑯4×4.

Answer

1.2.10.Julia session - constructing plots

Problem

Insert a Julia session to plot the function f(x)=sin(cos(x))+cos(sin(x)).

Answer

1.3.Data Science Application

Carry out linear regression, i.e., fitting a line to data.

1.3.1.Generate synthetic data

Problem

The following generates data by random perturbation of points on a line y=c0+c1x.

m=20; x=(0:m-1)/m; c0=-1; c1=1; yex=c0 .+ c1*x;
y=yex .+ 0.1*(rand(m,1) .- 0.5);
clf(); plot(x,yex,"k",x,y,"r.");
cd(homedir()*"/courses/MATH347DS/homework/hw00");
savefig("H00Fig01.eps");

Repeat for different values of m,c0,c1.

Figure 1. Perturbation of points on a line.

Answer

1.3.2.Form the normal system

Problem

Define matrices 𝑿=[ 𝟏 𝒙 ], 𝑵=𝑿T𝑿, and vector 𝒃=𝑿T𝒚

Answer

1.3.3.Solve the least square problem

Problem

Solve the system 𝑵𝒄=𝒃 by use of the Octave backslash operator c=N\b. Display the coefficient vector 𝒄, and compare to the values you chose in Question 3.1. Also compute 𝒚=𝑿𝒄, using ytilde as a notation.

Answer

1.3.4.Plot the result

Problem

Plot the original line, perturbed points and linear regression of the perturbed points.

Answer

Submission instructions. Save your work, and also export to PDF (menu File->Export->Pdf). In Canvas submit the files: