Skip to content

Instantly share code, notes, and snippets.

@lazywei
Forked from dcernst/HWTemplate.tex
Last active December 23, 2015 08:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywei/6606677 to your computer and use it in GitHub Desktop.
Save lazywei/6606677 to your computer and use it in GitHub Desktop.
% --------------------------------------------------------------
% This is all preamble stuff that you don't have to worry about.
% Head down to where it says "Start here"
% --------------------------------------------------------------
\documentclass[12pt]{article}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\setromanfont{Apple LiSung Light}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
% ------ For pasting codes ------
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=MATLAB,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
% -----------------------------------
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newenvironment{theorem}[2][Theorem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{lemma}[2][Lemma]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{exercise}[2][Exercise]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{problem}[2][Problem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{corollary}[2][Corollary]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\begin{document}
% --------------------------------------------------------------
% Start here
% --------------------------------------------------------------
\title{Homework 01}
\author{Bert Chang B00201037\\ %replace with your name
Introduction to Computational Mathematics} %if necessary, replace with your course title
\maketitle
\begin{enumerate}
\item
\begin{enumerate}
\item
With the following code, it shows that the error decreases rapidly. As soon as \(n\) exceeds about \(14\), the error stop decreasing. I think this is the so called Gibbs phenomenon.
\begin{lstlisting}
function cheb_interpolant
f = chebfun('exp(x)');
y = [];
for n=[1:100]
p_n = chebfun('exp(x)', n);
y(n) = norm(f - p_n, inf);
end
semilogy(y)
end
\end{lstlisting}
\includegraphics[scale=.5]{cheb_interpolant.eps}
\item
Using the same above code with a little bit changes,
\begin{lstlisting}
f = chebfun('1/(1+25*x^2)', 'vectorize');
p_n = chebfun('1/(1+25*x^2)', n, 'vectorize');
\end{lstlisting}
and also alter \(n\) from \(100\) to \(300\).
Then we get this plotting,\\
\includegraphics[scale=.5]{cheb_interpolant2.eps}
\end{enumerate}
\item
\begin{enumerate}
\item
blah
\end{enumerate}
\end{enumerate}
% --------------------------------------------------------------
% You don't have to mess with anything below this line.
% --------------------------------------------------------------
\end{document}
% --------------------------------------------------------------
% This is all preamble stuff that you don't have to worry about.
% Head down to where it says "Start here"
% --------------------------------------------------------------
\documentclass[12pt]{article}
\usepackage{fontspec,xltxtra,xunicode}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\setromanfont{Apple LiSung Light}
\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt
% ------ For pasting codes ------
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=Haskell,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
% -----------------------------------
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newenvironment{theorem}[2][Theorem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{lemma}[2][Lemma]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{exercise}[2][Exercise]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{problem}[2][Problem]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{corollary}[2][Corollary]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\begin{document}
% --------------------------------------------------------------
% Start here
% --------------------------------------------------------------
\title{Exercises 01}
\author{Bert Chang\\ %replace with your name
Programming Language} %if necessary, replace with your course title
\maketitle
\begin{enumerate}
\item
\begin{lstlisting}
areaOfCircle :: Double -> Double
areaOfCircle r = pi' * r * r
where pi' = 22 / 7
\end{lstlisting}
\end{enumerate}
% --------------------------------------------------------------
% You don't have to mess with anything below this line.
% --------------------------------------------------------------
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment