diff --git a/.gitignore b/.gitignore index b413e92..ec02858 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ *.log *.out *.synctex.gz -*.toc \ No newline at end of file +*.toc +*.listing \ No newline at end of file diff --git a/Exercise 2/main.pdf b/Exercise 2/main.pdf index 38b3bce..db47b87 100644 Binary files a/Exercise 2/main.pdf and b/Exercise 2/main.pdf differ diff --git a/Exercise 2/main.tex b/Exercise 2/main.tex index 553adc2..5fa19a1 100644 --- a/Exercise 2/main.tex +++ b/Exercise 2/main.tex @@ -1,7 +1,7 @@ \documentclass{article} -\author{Øystein Tveit} -\title{MA0001 Øving 2} +\newcommand{\theTitle}{MA0001 Øving 2} +\newcommand{\theAuthor}{Øystein Tveit} \input{../lib/lib.tex} diff --git a/Exercise 3/main.pdf b/Exercise 3/main.pdf index 2be4ec9..3289649 100644 Binary files a/Exercise 3/main.pdf and b/Exercise 3/main.pdf differ diff --git a/Exercise 3/main.tex b/Exercise 3/main.tex index 04c012c..f28edea 100644 --- a/Exercise 3/main.tex +++ b/Exercise 3/main.tex @@ -1,5 +1,8 @@ \documentclass{article} +\newcommand{\theTitle}{MA0001 Øving 3} +\newcommand{\theAuthor}{Øystein Tveit} + \input{../lib/lib.tex} \begin{document} diff --git a/Exercise 4/main.pdf b/Exercise 4/main.pdf index a0e9afc..1ac1075 100644 Binary files a/Exercise 4/main.pdf and b/Exercise 4/main.pdf differ diff --git a/Exercise 4/main.tex b/Exercise 4/main.tex index f109b10..878377a 100644 --- a/Exercise 4/main.tex +++ b/Exercise 4/main.tex @@ -1,5 +1,8 @@ \documentclass{article} +\newcommand{\theTitle}{MA0001 Øving 4} +\newcommand{\theAuthor}{Øystein Tveit} + \input{../lib/lib.tex} \usepackage{amssymb} diff --git a/Exercise 5/main.pdf b/Exercise 5/main.pdf index 555ad5c..364292b 100644 Binary files a/Exercise 5/main.pdf and b/Exercise 5/main.pdf differ diff --git a/Exercise 5/main.tex b/Exercise 5/main.tex index c040d5a..003eefc 100644 --- a/Exercise 5/main.tex +++ b/Exercise 5/main.tex @@ -1,5 +1,8 @@ \documentclass{article} +\newcommand{\theTitle}{MA0001 Øving 5} +\newcommand{\theAuthor}{Øystein Tveit} + \input{../lib/lib.tex} \usepackage{amssymb} diff --git a/Exercise 6/main.pdf b/Exercise 6/main.pdf index 5ce50f0..8394373 100644 Binary files a/Exercise 6/main.pdf and b/Exercise 6/main.pdf differ diff --git a/Exercise 6/main.tex b/Exercise 6/main.tex index 169b468..65aaa6c 100644 --- a/Exercise 6/main.tex +++ b/Exercise 6/main.tex @@ -1,5 +1,8 @@ \documentclass{article} +\newcommand{\theTitle}{MA0001 Øving 6} +\newcommand{\theAuthor}{Øystein Tveit} + \input{../lib/lib.tex} \begin{document} diff --git a/Exercise 7/main.pdf b/Exercise 7/main.pdf new file mode 100644 index 0000000..b577585 Binary files /dev/null and b/Exercise 7/main.pdf differ diff --git a/Exercise 7/main.tex b/Exercise 7/main.tex new file mode 100644 index 0000000..d5d1ea7 --- /dev/null +++ b/Exercise 7/main.tex @@ -0,0 +1,46 @@ +\documentclass{article} + +\newcommand{\theTitle}{MA0001 Øving 7} +\newcommand{\theAuthor}{Øystein Tveit} + +\input{../lib/lib.tex} + +\usepackage{amssymb} + +\begin{document} + + \thispagestyle{plain} + \tittel + \tableofcontents + + \newpage + + \section{Forberedende oppgaver} + \begin{oppgaver} + + \oppg + \input{tasks/1.tex} + + \end{oppgaver} + + \newpage + + \section{Innleveringsoppgaver} + \begin{oppgaver} + \setoppg{1} + + \oppg + \input{tasks/2.tex} + + \oppg + \input{tasks/3.tex} + + \oppg + \input{tasks/4.tex} + + \oppg + \input{tasks/5.tex} + + \end{oppgaver} + +\end{document} \ No newline at end of file diff --git a/Exercise 7/tasks/1.tex b/Exercise 7/tasks/1.tex new file mode 100644 index 0000000..dd284e4 --- /dev/null +++ b/Exercise 7/tasks/1.tex @@ -0,0 +1,11 @@ +\begin{deloppgaver} + \delo + \[f'(x) = 3\] + + \delo + \[f^{-1}(x) = \frac{x}{3} - 1\] + + \delo + \[\frac{d}{dx} f^{-1}(x) = \frac{1}{3} \] + +\end{deloppgaver} \ No newline at end of file diff --git a/Exercise 7/tasks/2.tex b/Exercise 7/tasks/2.tex new file mode 100644 index 0000000..35146e5 --- /dev/null +++ b/Exercise 7/tasks/2.tex @@ -0,0 +1,12 @@ +\[ f(x) = x^2 \] + +\begin{align*} + \frac{d}{dx} f(x) &= \lim_{\Delta x \to 0} \frac{f(x+\Delta x) - f(x)}{\Delta x} \\[2ex] + &= \lim_{\Delta x \to 0} \frac{(x+\Delta x)^2 - x^2}{\Delta x} \\[2ex] + &= \lim_{\Delta x \to 0} \frac{x^2 + 2x \Delta x + {\Delta x}^2 - x^2}{\Delta x} \\[2ex] + &= \lim_{\Delta x \to 0} \frac{2x \Delta x + {\Delta x}^2}{\Delta x} \\[2ex] + &= \lim_{\Delta x \to 0} \frac{2x + \Delta x}{1} \\[2ex] + &= \lim_{\Delta x \to 0} \frac{2x + \Delta x}{1} \\[2ex] + &= 2x + 0 \\[2ex] + &= 2x \\[2ex] +\end{align*} \ No newline at end of file diff --git a/Exercise 7/tasks/3.tex b/Exercise 7/tasks/3.tex new file mode 100644 index 0000000..301721e --- /dev/null +++ b/Exercise 7/tasks/3.tex @@ -0,0 +1,6 @@ +\[ h(x) = -\frac{1}{4}x^4 + \frac{2}{3}x^3 + 2x^2 - \sqrt{2}x + \pi^e \] + +\begin{align*} + h'(x) &= 4 \cdot -\frac{1}{4}x^{4-1} + 3 \cdot \frac{2}{3}x^{3-1} + 2\cdot2x^{2-1} - 1 \cdot \sqrt{2}x^{1-1} + 0 \cdot \pi^e x^{0-1} \\ + &= -x^{3} + 2x^{2} + 4x - \sqrt{2} \\ +\end{align*} \ No newline at end of file diff --git a/Exercise 7/tasks/4.tex b/Exercise 7/tasks/4.tex new file mode 100644 index 0000000..1bea53c --- /dev/null +++ b/Exercise 7/tasks/4.tex @@ -0,0 +1,12 @@ +\begin{align*} + \left(x^{1/3}-x\right) \cdot \left(x^{2/3}+x^2\right) + &= x^{1/3} \cdot x^{2/3} + x^{1/3} \cdot x^2 - x\cdot x^{2/3} - x \cdot x^{2} \\ + &= x + x^{7/3} - x^{5/3} - x^3 \\ +\end{align*} + + +\begin{align*} + \frac{d}{dx} \left( x + x^{7/3} - x^{5/3} - x^3 \right) + &= 1 + \frac{7}{3}x^{4/3} - \frac{5}{3}x^{2/3} - 3x^2 \\ + &= - 3x^2 - \frac{5}{3}x^{2/3} + \frac{7}{3}x^{4/3} + 1 +\end{align*} \ No newline at end of file diff --git a/Exercise 7/tasks/5.tex b/Exercise 7/tasks/5.tex new file mode 100644 index 0000000..963f61e --- /dev/null +++ b/Exercise 7/tasks/5.tex @@ -0,0 +1,14 @@ +\[ f(x): \mathbb{R} \to \mathbb{R} = \begin{cases} + \sqrt{x},\qquad &x \ge 0 \\ + x, &x < 0 +\end{cases} \] + +Ettersom \[\sqrt{0} = 0\] og \[\lim_{x\to 0}x = 0\] er funksjonen kontinuerlig. + +Den deriverte av den første delen av funksjonen blir +\begin{align*} + \frac{d}{dx} \sqrt{x} &= \frac{1}{2} x^{-\frac{1}{2}} \\[2ex] + &= \frac{1}{2\sqrt{x}} +\end{align*} + +Ved $x=0$ blir \[\frac{1}{2\sqrt{x}} = \frac{1}{0}\] som er udefinert, og dermed er ikke den funksjonen deriverbar for denne $x$-verdien \ No newline at end of file diff --git a/Exercise 8/main.pdf b/Exercise 8/main.pdf new file mode 100644 index 0000000..bfb4765 Binary files /dev/null and b/Exercise 8/main.pdf differ diff --git a/Exercise 8/main.tex b/Exercise 8/main.tex new file mode 100644 index 0000000..bdd86d6 --- /dev/null +++ b/Exercise 8/main.tex @@ -0,0 +1,47 @@ +\documentclass{article} + +\newcommand{\theTitle}{Øystein Tveit} +\newcommand{\theAuthor}{MA0001 Øving 8} + +\input{../lib/lib.tex} +\input{../lib/lst.tex} + +\begin{document} + + + \thispagestyle{plain} + \tittel + \tableofcontents + + \newpage + + \section{Forberedende oppgaver} + \begin{oppgaver} + + \oppg + \input{tasks/1.tex} + + \end{oppgaver} + + \newpage + + \section{Innleveringsoppgaver} + \begin{oppgaver} + + \setoppg{1} + + \oppg + \input{tasks/2.tex} + + \oppg + \input{tasks/3.tex} + + \oppg + \input{tasks/4.tex} + + \oppg + \input{tasks/5.tex} + + \end{oppgaver} + +\end{document} \ No newline at end of file diff --git a/Exercise 8/scripts/4.py b/Exercise 8/scripts/4.py new file mode 100644 index 0000000..32b8f63 --- /dev/null +++ b/Exercise 8/scripts/4.py @@ -0,0 +1,19 @@ +from math import e + +def f(x): return e ** x - 2 +def df(x): return e ** x + +def Newton(a, f, df): + return a - f(a)/df(a) + +def main(): + i = 0 + a = [5] + while True: + a.append(Newton(a[i], f, df)) + if abs(a[i] - a[i-1]) < 0.001: + print(f'Iterasjoner: {i-1}, a: {a[i-1]}') + break + i += 1 + +main() \ No newline at end of file diff --git a/Exercise 8/tasks/1.tex b/Exercise 8/tasks/1.tex new file mode 100644 index 0000000..50eecda --- /dev/null +++ b/Exercise 8/tasks/1.tex @@ -0,0 +1,10 @@ + +\[f(x) = \frac{1}{2}x^3 -7x +22\] + +\[f'(x) = \frac{3}{2}x^2 -7\] + +\[f''(x) = 3x \] + +\[f'''(x) = 3 \] + +\[f^{(100)} = 0\] \ No newline at end of file diff --git a/Exercise 8/tasks/2.tex b/Exercise 8/tasks/2.tex new file mode 100644 index 0000000..6117586 --- /dev/null +++ b/Exercise 8/tasks/2.tex @@ -0,0 +1,53 @@ +\begin{enumerate}[label=\arabic*.] + \item \[ f(x) = ln\left(\frac{1}{x^2}\right) \] + + La $u = \frac{1}{x^2}$ + + Jeg bruker kjerneregelen: + + \begin{align*} + \frac{dy}{dx} &= \frac{dy}{du} \cdot \frac{du}{dx} \\ + &= \frac{d}{du} ln(u) \cdot \frac{d}{dx} \frac{1}{x^2} \\ + &= \frac{1}{u} -2 \frac{1}{x^3} \\ + &= \frac{1}{\frac{1}{x^2}} -2 \frac{1}{x^3} \\ + &= x^2 -2 \frac{1}{x^3} + \end{align*} + + + + \item \[g(x) = \frac{1 + \sin x}{1 + e^x + x^2}\] + + Jeg bruker kvotientregelen: + + $u = 1 + \sin x$ + + $v = 1 + e^x + x^2$ + + \[ \frac{d}{dx}\left(\frac{u}{v}\right) = \frac{ \frac{d}{dx}(u) \cdot v - u \cdot \frac{d}{dx}(v)}{v^2} \] + + \begin{align*} + \frac{d}{dx} u &= \frac{d}{dx} 1 + \sin x \\ + &= \cos x + \end{align*} + + \begin{align*} + \frac{d}{dx} v &= \frac{d}{dx} 1 + e^x + x^2 \\ + &= e^x + 2x + \end{align*} + + \begin{align*} + \frac{dg}{dx} &= \frac{(\cos x)(1+e^x+x^2) - (1+\sin x)(e^x + 2x)}{\left(1 + e^x + x^2\right)^2} + \end{align*} + + \item \[h(x) = \sqrt{1 + \sqrt{x}}\] + + $u = 1 + \sqrt{x}$ + + \begin{align*} + \frac{dy}{dx} &= \frac{dy}{dv} \cdot \frac{du}{dx} \\ + &= \frac{d}{du} \sqrt{u} \cdot \frac{d}{dx} \left( 1 + \sqrt{x} \right) \\ + &= \frac{1}{2\sqrt{u}} \cdot \frac{1}{2\sqrt{x}} \\ + &= \frac{1}{2\sqrt{1+\sqrt{x}}} \cdot \frac{1}{2\sqrt{x}} \\ + &= \frac{1}{4\sqrt{1+\sqrt{x}} \sqrt{x}} + \end{align*} +\end{enumerate} \ No newline at end of file diff --git a/Exercise 8/tasks/3.tex b/Exercise 8/tasks/3.tex new file mode 100644 index 0000000..bd1820f --- /dev/null +++ b/Exercise 8/tasks/3.tex @@ -0,0 +1,41 @@ +\[f(t) = \frac{t^2 -1}{t+1} + 6t^{1/3} + \sqrt{\sin t} + 4^t\] + +Jeg deriverer funksjonen ledd for ledd + +Ledd 1: + +\begin{align*} + \frac{d}{dt} \frac{t^2-1}{t+1} &= \frac{d}{dt}\frac{(t+1)(t-1)}{t+1} \\ + &= \frac{d}{dt} t-1 \\ + &= 1 +\end{align*} + +Ledd 2: + +\begin{align*} + \frac{d}{dt} 6t^{1/3} &= \frac{1}{3} \cdot 6t^{(1/3 - 1)} \\ + &= 2t^{-2/3}\\ + &= \frac{2}{\sqrt[3]{t^2}} +\end{align*} + +Ledd 3: + +\[ \frac{d}{dt} \sqrt{\sin t} \] + +$u = \sin t$ + +\begin{align*} + \frac{dy}{dt} &= \frac{dy}{du} \cdot \frac{du}{dt} \\ + &= \frac{d}{du} \sqrt{u} \cdot \frac{d}{dt} \sin t \\ + &= \frac{1}{2\sqrt{u}} \cdot \cos t \\ + &= \frac{\cos t}{2\sqrt{\sin t}} +\end{align*} + +Ledd 4: + +\begin{align*} + \frac{d}{dt} 4^t = 4^t ln(t) \\ +\end{align*} + +\[\frac{df}{dx} = 1 + \frac{2}{\sqrt[3]{t^2}} + \frac{\cos t}{2\sqrt{\sin t}} + 4^t ln(t)\] + \ No newline at end of file diff --git a/Exercise 8/tasks/4.tex b/Exercise 8/tasks/4.tex new file mode 100644 index 0000000..fdfa0a7 --- /dev/null +++ b/Exercise 8/tasks/4.tex @@ -0,0 +1,7 @@ + +Her har jeg brukt python for å løse oppgaven. + +\pythonBlock{./scripts/4.py} + +Output: +\fbox{Iterasjoner: 7, a: 0.6932882713164431} \ No newline at end of file diff --git a/Exercise 8/tasks/5.tex b/Exercise 8/tasks/5.tex new file mode 100644 index 0000000..9f725e5 --- /dev/null +++ b/Exercise 8/tasks/5.tex @@ -0,0 +1,18 @@ +\[f(y) = a^y \] +\[f'(y) = a^y \ln a\] +\[f^{-1}(y) = \log_{a} y\] + +\begin{align*} + \frac{d}{dy}f^{-1}(y) &= \frac{1}{f' \circ f^{-1}(y)} \\[2ex] + &= \frac{1}{a^{\log_{a} y} \ln a} \\[2ex] + &= \frac{1}{y \ln a} \\ +\end{align*} + +Gitt at vi vet at $\frac{d}{dx} ln(x) = \frac{1}{x}$, så kan vi også løse det på følgende måte + +\begin{align*} + \frac{d}{dy} \log_{a} y &= \frac{d}{dy} \frac{\ln y}{\ln a} \\[2ex] + &= \frac{1}{\ln a} \cdot \frac{d}{dy} \ln y \\[2ex] + &= \frac{1}{\ln a} \cdot \frac{1}{y} \\[2ex] + &= \frac{1}{y \ln a} +\end{align*} \ No newline at end of file diff --git a/lib/lib.tex b/lib/lib.tex index 398ceb3..734eb95 100644 --- a/lib/lib.tex +++ b/lib/lib.tex @@ -11,22 +11,22 @@ \definecolor{ntnublue}{RGB}{0,80,158} -\input{../lib/geometry.tex} \input{../lib/header.tex} +\input{../lib/geometry.tex} \input{../lib/math.tex} \usetikzlibrary{angles, quotes} \hypersetup{ - colorlinks=true, - linkcolor=blue, - filecolor=magenta, - urlcolor=blue, -} - -\pgfplotsset{compat=newest} - -\author{Øystein Tveit} -\title{MA0001 Øving 6} + colorlinks=true, + linkcolor=blue, + filecolor=magenta, + urlcolor=blue, + } + + \pgfplotsset{compat=newest} + + \author{\theAuthor} + \title{\theTitle} \input{../lib/titling.tex} diff --git a/lib/lst.tex b/lib/lst.tex new file mode 100644 index 0000000..d81af2c --- /dev/null +++ b/lib/lst.tex @@ -0,0 +1,41 @@ +\usepackage{listings} + +\definecolor{background}{RGB}{39, 40, 34} +\definecolor{string}{RGB}{230, 219, 116} +\definecolor{comment}{RGB}{117, 113, 94} +\definecolor{normal}{RGB}{248, 248, 242} +\definecolor{identifier}{RGB}{166, 226, 46} + +\lstdefinestyle{monokaiPython}{ + frame=none, + language=python, % choose the language of the code + numbers=left, % where to put the line-numbers + stepnumber=1, % the step between two line-numbers. + numbersep=5pt, % how far the line-numbers are from the code + numberstyle=\color{white}\ttfamily, + backgroundcolor=\color{background}, % choose the background color. You must add \usepackage{color} + showspaces=false, % show spaces adding particular underscores + showstringspaces=false, % underline spaces within strings + showtabs=false, % show tabs within strings adding particular underscores + tabsize=2, % sets default tabsize to 2 spaces + captionpos=b, % sets the caption-position to bottom + breaklines=true, % sets automatic line breaking + breakatwhitespace=true, % sets if automatic breaks should only happen at whitespace + title=\color{white}\lstname, % show the filename of files included with \lstinputlisting; + basicstyle=\color{normal}\ttfamily, % sets font style for the code + keywordstyle=\color{magenta}\ttfamily, % sets color for keywords + stringstyle=\color{string}\ttfamily, % sets color for strings + commentstyle=\color{comment}\ttfamily, % sets color for comments + emph={format_string, eff_ana_bf, permute, eff_ana_btr}, + emphstyle=\color{identifier}\ttfamily +} + +\usepackage{framed} +\definecolor{shadecolor}{named}{background} + +\newcommand{\pythonBlock}[1] +{ + \begin{shaded} + \lstinputlisting[style=monokaiPython]{#1} + \end{shaded} +} \ No newline at end of file