All examples. Øyvind Ryan
|
|
|
- Kurt Didrik Aase
- 9 år siden
- Visninger:
Transkript
1 All examples Øyvind Ryan 19. februar 2013
2 Example 0.1. Vi skal tegne grafen til f (x, y) = x 3 4y 2 over rektangelet x [ 3,3], y [ 5,5]. Vi lager først en oppdeling av de to intervallene vi er interessert i, ved å skrive r=-3:0.1:3; s=-5:0.1:5; (husk semikolon etter kommandoene, ellers vil du få lange tallremser som output!) Her har vi valgt å dele opp begge intervallene i skritt med lengde 0.1, men du kan godt velge en finere eller grovere oppdeling. Det kan være lurt å prøve en skikkelig grov oppdeling (f.eks. skrittlengde 0.5) en gang slik at du virkelig ser hvordan MATLAB tegner grafer. Neste skritt er å lage et rutenett av oppdelingene våre. Dette gjør vi med kommandoen >> [x,y]=meshgrid(r,s);} Vi kan nå definere funksjonen: >> z=x.^3-4*y.^2; (husk å bruke.-versjonene av de algebraiske operasjonene!) Dermed er vi klare til selve plottingen som utføres av kommandoen >> mesh(x,y,z) Grafen kommer opp i et eget figurvindu akkurat som for todimensjonale figurer, og ser ut som et fiskegarn med knuter i plottepunktene. Ved å gå inn på menyen i grafvinduet, kan du dreie flaten i rommet (aktiver musa ved å klikke på et ikon som symboliserer dreiing). Dette er ofte nødvendig for å få et godt inntrykk av hvordan grafen ser ut! Bruker du kommandoen surf(x,y,z) istedenfor mesh(x,y,z), vil MATLAB tegne grafen med fargelegging av hvert ruteelement. Det er ofte klargjørende når grafen varierer mye. Vil du se nivåkurvene istedenfor grafen, bytter du ut med kommandoen >> contour(x,y,z) Når du bruker contour på denne måten, velger MATLAB selv hvilke nivåkurver den skal tegne. MATLAB er ikke alltid flink til å finne de mest interessante nivåkurvene, og det kan også tenkes at vi er interessert i helt konkrete nivåer, som programmet umulig kan gjette på. Derfor hender det at du må hjelpe til ved å angi konkrete nivåer: Dersom vektoren v = (v 1, v 2,..., v n ) er lagt inn, vil kommandoen 2
3 >> contour(x,y,z,v) tvinge MATLAB til å tegne nivåkurvene med verdier v 1, v 2,..., v n. Vil du bare regulere antall nivåkurver, men ikke spesifisere verdiene, kan du bruke denne kommandoen >> contour(x,y,z,n) som får MATLAB til å tegne opp n nivåkurver. Med kommandoen clabel får du MATLAB til å skrive nivået til nivåkurvene på grafen. Prøv >> clabel(contour(x,y,z,12)) MATLAB vil normalt tegne nivåkurvene i forskjellige farger. Dette er nyttig på skjermen, men kan være mindre praktisk dersom du ønsker å lime figuren inn i et svart-hvitt dokument. Skriver du >> contour(x,y,z,8, k ) får du 8 nivåkurver tegnet i svart ( k er symbolet for svart farge). Ønsker du at MATLAB skal tegne nivåkurvene og grafen i samme plot, bruker du kommandoen >> meshc(x,y,z) Det finnes mange andre kommandoer du også kan bruke (og mange flere måter å modifisere kommandoene ovenfor på!). Skriv >> help graph3d for å få en oversikt. Example 0.2. Vi skal lage en fremstilling av vektorfeltet F(x, y) = x y i + x sin(x y) j over mengden 5 x 5, 3 y 3. Vi starter med å lage rutenettet. Vi bør ikke lage oppdelingen for fin, for da blir det vanskelig å se vektorene. Vi velger en rutelengde på 0.5: x=-5:0.5:5; y=-3:0.5:3; Vi lager så et rutenett av x og y. >> [x,y]=meshgrid(x,y); 3
4 Nå kan vi legge inn vektorfeltet: u=x.*y; v=x.*sin(x.*y); Dermed er vi klare til å lage figuren >> quiver(x,y,u,v) MATLAB svarer med figur 3 (se ovenfor). Example 0.3. La oss bruke MATLAB til å finne en strømningslinje for vektorfeltet i eksempel 1. Vi må først legge inn x, y, u og v på samme måte som ovenfor. I dette tilfellet kan det imidlertid være lurt å bruke et rutenett som er mindre grovt, så vi starter med sekvensen x=-5:0.05:5; y=-3:0.05:3; [x,y]=meshgrid(x,y); u=x.*y; v=x.*sin(x.*y); For å lage strømningslinjen som starter i punktet (1, 1) skriver vi nå >> streamline(x,y,u,v,1,-1) Hvis du taster inn den siste kommandoen på nytt med et annet startpunkt, f.eks. >> streamline(x,y,u,v,0.5,1) tegner MATLAB en ny strømningslinje i det samme figurvinduet. Det er også instruktivt å tegne inn vektorfeltet og strømningslinjene i samme figur (prøv!). Example 0.4. Vi skal bruke MATLAB til å tegne den parametriserte flaten Vi taster da: u=-5:.1:5; v=-5:.1:5; [U,V]=meshgrid(u,v); x=u+v; y=u-v; z=u.*v; surf(x,y,z) r(u, v) = (u + v)i + (u v)j + uv k, der 5 u, v 5 4
5 og MATLAB tegner flaten. Example 0.5. La oss også bruke MATLAB til å tegne en kuleflate med radius 3 og sentrum i origo. For å slippe for lange variabelnavn, bruker vi u for den variabelen som i kulekoordinater vanligvis heter φ og v for den som vanligvis heter θ. Kommandoen linspace(a,b,n) gir oss en vektor med n komponenter som begynner med a og ender med b. u=linspace(0,pi,100); v=linspace(0,2*pi,200); [U,V]=meshgrid(u,v); x=3*sin(u).*cos(v); y=3*sin(u).*sin(v); z=3*cos(u); surf(x,y,z) axis( equal ) Husk kommandoen >> axis( equal ) som gir samme målestokk langs alle akser uten den ser kulen ut som en ellipsoide. Example 0.6. Et dyreslag har en levealder på fire år. Det første året er dyrene unger, det andre året er de ungdommer, det tredje året er de voksne og det fjerde året er de eldre. Av ungene overlever 50% til året etter, av ungdommene overlever 80% til året etter og av de voksne overlever 20% til året etter. En ungdom gir i gjennomsnitt opphav til 0.5 unger som blir født året etter, en voksen gir i gjennomsnitt opphav til 2 unger som blir født året etter, og et eldre dyr gir i gjennomsnitt opphav til 0.1 unge som blir født året etter. Vi antar at vi starter med 200 dyr i hver aldersklasse, og ønsker å finne ut hvordan stammen utvikler seg. La x n, y n, z n og u n være henholdsvis antall unger, ungdommer, voksne og eldre i år n. Da er x n+1 = 0.5y n + 2z n + 0.1u n y n+1 = 0.5x n z n+1 = 0.8y n u n+1 = 0.2z n I tillegg vet vi at x 1 = y 1 = z 1 = u 1 = 200. Det er flere måter å angripe dette problemet på. La oss først se hva som skjer når vi bruker MATLAB til å regne ut utviklingen de 50 første årene. Vi lager m- filen function [x,y,z,u]=dyrestamme(a,b,c,d,n) 5
6 x(:,1)=[a;b;c;d] for n=1:n x(:,n+1)=[ ; ; ; ]*x(:,n); end Den neste kommandosekvensen får MATLAB til å plotte ut følgene i samme figur: [x,y,z,u]=dyrestamme(200,200,200,200,49); plot(x) hold on plot(y) plot(z) plot(u) Resultatet er figuren nedenfor der den øverste kurven gir antall unger, den nest øverste antall ungdommer, den tredje øverste antall voksne og den nederste antall eldre. Disse kurvene er ikke så lette å tolke. Det ser ut som de etter noen innledende svingninger går over i jevn vekst, og at fordelingen mellom de forskjellige aldersgruppene nærmer seg en likevekt. Men hvor kommer svingningene fra, hvor rask er veksten, og hvordan finner vi likevektsfordelingen mellom aldersgruppene?. La oss kjøre programmet en gang til med startverdier x 1 = 400, y 1 = 300, z 1 = 100, u 1 = 0. Resultatet ser du på figuren nedenfor, og i hovedtrekk ligner 6
7 det forbløffende på det vi fikk i stad; etter noen innledende svingninger går kurvene over i jevn vekst, og forholdet mellom aldersgruppene ligner på det vi fikk ovenfor. Vi skal nå se hvordan vi kan bruke egenverdier og egenvektorer til å forklare disse resultatene. Det første vi observerer, er at dersom vi innfører vektorene x n y n r n = z n u n så kan ligningssystemet ovenfor skrives der A er matrisen A = r n+1 = Ar n Bruker vi denne formelen gjentatte ganger, får vi r n = A n 1 r 1 Legg merke til at siden vi kaller begynnelsesbestanden r 1 og ikke r 0, må A oppphøyes i n 1 og ikke n. Matematisk sett hadde det vært greiere å begynne med r 0 7
8 slik vi gjorde i forrige eksempel, men MATLAB begynner alltid nummereringer på 1, og vi har derfor valgt å holde oss til det siden vi MATLAB bruker såpass mye i dette eksemplet. La oss benytte MATLAB til å finne egenverdiene og egenvektorene til A: >> A=[ ]; >> [u,v]=eig(a) u = Columns 1 through i i i i i i Column v = Columns 1 through i i Column
9 Vi har altså egenverdiene λ 1 = , λ 2 = i, λ 3 = i, λ 4 = 0.01 med tilhørende egenvektorer (vi bytter fortegn på den første av dem for å slippe minuser): v 1 = v 3 = , v 2 = i i i i i i, v 4 = Vi ser at de komplekse egenverdiene og egenvektorene er konjugerte av hverandre slik setning sier. Vi ser også at egenverdiene er ordnet i avtagende rekkefølge: λ 1 > λ 2 = λ 3 > λ 4. Siden egenverdiene er forskjellige, vet vi at v 1, v 2, v 3, v 4 danner en basis. Vi kan derfor skrive starttilstanden r 1 = som en lineærkombinasjon r 1 = 200 = c 1v 1 + c 2 v 2 + c 3 v 3 + c 4 v Vi skal bruke MATLAB til å finne koeffisientene c 1,c 2,c 3,c 4, men la oss først se hva som skjer når vi bruker A n 1 på ligningen ovenfor. Vi får r n = A n 1 r 1 = c 1 A n 1 v 1 + c 2 A n 1 v 2 + c 3 A n 1 v 3 + c 4 A n 1 v 4 = c 1 λ n 1 1 v 1 + c 2 λ n 1 2 v 2 + c 3 λ n 1 3 v 3 + c 4 λ n 1 4 v 4 Vi setter den største egenverdien λ1 n 1 utenfor en parentes ( ( ) n 1 ( ) n 1 ( ) n 1 ) r n = λ1 n 1 λ2 λ3 λ4 c 1 v 1 + c 2 v 2 + c 3 v 3 + c 4 v 4 λ 1 λ 1 λ 1 9
10 ( Siden λ 1 har størst tallverdi av egenverdiene, vil alle faktorene λ2 ( λ4 λ 1 ) n 1 gå mot null når n går mot uendelig. Det betyr at Definerer vi kan vi derfor skrive ( ( ) n 1 ( λ2 λ3 lim c 2 v 2 + c 3 n λ 1 λ 1 ) n 1 v 3 + c 4 ( λ4 λ 1 ) n 1 v 4 ) = 0 ( ) n 1 ( ) n 1 ( ) n 1 λ2 λ3 λ4 σ(n) = c 2 v 2 + c 3 v 3 + c 4 v 4, λ 1 λ 1 λ 1 r n = λ n 1 ( 1 c1 v 1 + σ(n) ) λ 1 ) n 1, ( λ3 λ 1 ) n 1, der σ(n) 0 når n. Skriver vi ut komponentene og setter in λ 1 = , får vi x n y n z n = n 1( ) c σ(n) u n Dette betyr at når n blir stor, er veksten bestemt av den største egenverdien λ 1 = , og fordelingen mellom komponentene er bestemt av den tilhørende egenvektoren v 1. Som du ser, minner disse resultatene om det vi fikk i Eksempel 1, men vi har fått med en vekstfaktor i tillegg. La oss nå finne konstantene c 1, c 2, c 3 og c 4. Dersom vi velger den opprinnelige begynnelsestilstanden r 1 = får vi ligningen = c 1 +c c i i i i i i + c
11 Innfører vi matrisen i i D = i i i i kan vi bruke MATLAB til å finne vektoren c 1 c 2 c = c 3 c 4 ved å taste >> c=d\r1 Vi får c 1 = , c 2 = i, c 3 = i, c 4 = Legg merke til at koeffisientene c 2 og c 3 til de komplekse egenverdiene er konjugerte. Vi har ennå ikke forklart hvor svingningene i figuren kommer fra. Det viser seg at de kommer fra de komplekse egenverdiene. Skriver vi den komplekse egenverdien λ 2 på polarform λ 2 = re iθ, ser vi at λ n 1 2 = r n 1 e i (n 1)θ = r n 1( ) cos((n 1)θ) + i sin((n 1)θ) Cosinus- og sinus-leddene får uttrykket til å svinge, men i dette tilfellet vil svingningene dø ut etter hvert fordi r < 1 og r n 1 0 når n. Example 0.7. To dyreslag, et byttedyr og et rovdyr, lever i det samme området. Dersom det ett år er x n byttedyr og y n rovdyr i området, tenker man seg at antall dyr året etter er gitt ved x n+1 = ax n bx n y n y n+1 = c y n+1 + dx n y n der a,b,c,d er positive tall. Legg merke til logikken; kryssleddene x n y n representerer møter mellom byttedyr og rovdyr, og slike møter reduserer veksten av byttedyr, men bidrar til vekst i rovdyrbestanden. Hvis vi innfører funksjonen F : R 2 R 2 ved ( xn og lar x n = y n ( x F y ) ( ax bx y = c y + dx y ), ser vi at systemet ovenfor kan skrives som x n+1 = F(x n ). 11 )
12 Det er ikke lett å gjette hvordan et system av denne typen vil utvikle seg i tiden, så la oss bruke MATLAB som hjelpemiddel til å se på et spesielt tilfelle. Vi velger a = 1.01,b = ,c = 0.98,d = Følgende m-fil regner ut utviklingen når vi starter med m byttedyr og k rovdyr og gjennomfører N iterasjoner. Vær oppmerksom på at det er en liten forskyvning i nummereringen av leddene i følgen; i teoretisk arbeid får vi ofte penest uttrykk om vi begynner iterasjonen med punkt nummer 0 (altså x 0 som ovenfor), men i programmet nedenfor har vi tatt hensyn til MATLABs forkjærlighet for å la startpunktet være nummer 1 (og ikke nummer 0). function [x,y]=byttedyr(m,k,n) x=[m]; %med disse linjene forteller vi y=[k]; %MATLAB at iterasjonen starter i punktet (m,k) for n=1:n % starter løkken som utfører iterasjonene x(n+1)=1.01*x(n)-3*10^(-5)*x(n)*y(n); y(n+1)=0.98*y(n)+10^(-5)*x(n)*y(n); end %avslutter for-løkken Dersom vi ønsker å se grafisk på utviklingen når vi starter med 1000 byttedyr og hundre rovdyr, kan vi gi kommandoene [x,y]=byttedyr(1000,100,1000); plot(x) hold on plot(y, r ) Vi får dette resultatet: Figur 1: Utviklingen av byttedyr (øverst) og rovdyr (nederst). 12
13 Vi ser at bestandene følger et bølgemønster med klare topper og bunner. Logikken er ikke så vanskelig å forstå; til å begynne med er det relativt få rovdyr, og byttedyrbestanden vokser. Dette fører til gode betingelser for rovdyrbestanden som også begynner å vokse kraftig. Til slutt gjør rovdyrene så kraftig innhogg at byttedyrbestanden begynner å avta. Etter hvert fører dette til dårligere forhold for rovdyrene, og rovdyrbestanden begynner også å avta. Dette gir etter hvert bedre forhold for byttedyrene som begynner å ta seg opp igjen osv. Example 0.8. Definer en avbildning F : R 3 R 3 ved F (x, y, z) = x 8 y 2 + z x 4 + z x 2 + y 2 1 Her er Jacobi-matrisen F(x, y, z) = Gradienten til F 1 er den første linjen i matrisen, altså F 1 (x, y, z) = 1 8 i 1 2 j k Tilsvarende er gradientene til F 2 og F 3 gitt av de neste linjene i matrisen F 2 (x, y, z) = 1 4 i k og F 3 (x, y, z) = 1 2 i j Uansett hvilke punkter vi evaluerer gradientene i, har vi dermed Dermed er F F F 3 2 = ( ) 1 2 ( = ( ) 1 2 ( ) 1 2 ( ) 1 2 ( ) 1 2 ( ) ) = = F F F 3 2 = 64 = 8 < 1 13
14 og F er altså en kontraksjon og har et entydig fikspunkt. For å finne (en tilnærmet verdi for) fikspunktet, starter vi en iterasjon. Følgende MATLAB-program fikspunkt.m starter med punktet x 0 = (a,b,c) og gjennomfører N iterasjoner. Vær oppmerksom på den vanlige forskyvningen i nummereringen av punktene; i MATLAB-programmet lar vi startpunktet være (x 1, y 1, z 1 ). Husk også at vi kan gjøre programmet mer effektivt ved å gi x, y og z riktig lengde fra starten av (se bemerkningen etter eksempel 1 i seksjon 5.4). function x=fikspunkt(a,b,c,n) x=[a;b;c]; % forteller MATLAB at iterasjonen starter i (a,b,c) for n=1:n % starter for-løkken som utfører iterasjonene x(:,n+1)=[1/8-1/2+1/4; 1/4 0 1/4; 1/2 1 0]*x(:,n)+[1;2;-1]; end % avslutter for-løkken For å regne ut de første 10 verdiene med startpunkt x 0 = (0,0,0), gir vi nå kommandoen >> fikspunkt(0,0,0,9) Output er: x 0 = x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = y 0 = y 1 = y 2 = y 3 = y 4 = y 5 = y 6 = y 7 = y 8 = y 9 = z 0 = z 1 = z 2 = z 3 = z 4 = z 5 = z 6 = z 7 = z 8 = z 9 = Vi ser at følgen x n ser ut til å stabilisere seg rundt (0.2,2.4,1.5), men at det fortsatt er ganske store fluktuasjoner. Vi gir derfor kommandoen >> fikspunkt(0,0,0,19) for også å få de neste ti verdiene. De er: x 10 = x 11 = x 12 = x 13 = x 14 = x 15 = x 16 = x 17 = x 18 = x 19 = y 10 = y 11 = y 12 = y 13 = y 14 = y 15 = y 16 = y 17 = y 18 = y 19 = z 10 = z 11 = z 12 = z 13 = z 14 = z 15 = z 16 = z 17 = z 18 = z 19 = Nå ser vi en tydelig konvergens mot et fikspunkt med (tilnærmet) verdi (0.1905, , ). Programmet fikspunkt.m er ganske primitivt; Blant annet må vi på forhånd bestemme hvor mange iterasjoner vi ønsker. Programmet er også avhengig av funksjon og dimensjon. En implementasjon som er uavhengig av disse tingene, og som i tillegg avbryter iterasjonen når man har fått en viss nøyaktighet, eller har kjørt et visst antall iterasjoner, er vist under: 14
15 function x=fikspunkt(f,x0) % Iterasjonene starter i x0 x=x0; epsilon= ; N=30; n=0; while norm(f(x)-x) > epsilon & n<=n x=f(x); n=n+1; end Leggmerke til at funksjonen returnerer kun siste iterasjon, den kaster bort de forrige iterasjonene. I mange tilfeller er dette greit, siden vi ofte bare er interessert i hva iterasjonene konvergerer mot. Definerer vi nå en anonym funksjon for funksjonen over så kan vi finne fikspunktet ved hjelp av følgende kode: fikspunkt(@(x)[x(1)/8-x(2)/2+x(3)/4+1;... x(1)/4+x(3)/4+2;... x(1)/2+x(2)-1],... [0;0;0]); Legg merke til de tre punktumene på slutten av hver linje, som brukes for å fortelle MATLAB at et uttrykk fortsetter på neste linje. Vi vil anvende dette flere ganger senere i boka, spesielt når en funksjon tar mange parametre, hver med lange navn eller uttrykk. Bruk av punktum på denne måten kan gjøre koden mer leselig, og forhindrer unøvendlig lange linjer. Splitter vi opp koden over flere linjer uten bruk av punktum vil MATLAB gi oss en feilmelding. Vi innledet med å si at dette er et ganske dårlig eksempel. Grunnen er at vi kunne ha funnet fikspunktet direkte ved å løse ligningssystemet F(x, y, z) = (x, y, z) ved regning. Dette er et lineært ligningssystem som er lett å løse med metodene i forrige kapittel. Metoden ovenfor har imidlertid også sine fordeler; vi har vist at fikspunktet er tiltrekkende (dvs. at iterasjoner av F alltid konvergerer). Det viser seg også at når man får store lineære ligningssystemer med tusenvis av ligninger og ukjente, så er det ofte raskere å løse dem ved en eller annen form for iterasjon enn ved radoperasjoner. Example 0.9. Vi skal bruke Newtons metode til å finne en løsning av ligningssystemet x 2 y + 1 = 0 e x + y = 0 15
16 Sagt på en annen måte skal vi finne et nullpunkt for funksjonen ( x 2 ) y + 1 F(x, y) = e x + y Denne funksjonen har Jacobi-determinant ( F 2x y x 2 ) (x, y) = e x 1 Lar vi x 0 = ( x0 y 0 ) ( x1, x 1 = y 1 ) ( x2, x 2 = y 2 ),... være en følge som fremkommer når vi bruker Newtons metode på F, ser vi at iterasjonsformelen x n+1 = x n F (x n ) 1 F(x n ) kan skrives ( xn+1 y n+1 ) ( xn = y n ) ( 2xn y n xn 2 e x n 1 ) 1 ( x 2 n y n + 1 e x n + y n ) For å regne ut punktene i følgen skriver vi et lite MATLAB-program. Legg ( ) xn merke til at variablen u alltid inneholder det siste punktet x n = vi har regnet ut, mens variablene x og y lagrer hele listen av x- og y-koordinater. Legg også merke til at vi bruker kommandoen A\v istedenfor A 1 v for å spare regnearbeid (dette er mer effektivt enn å tvinge MATLAB til å regne ut A 1 ). function x=newtonfler(a,b,n) x=zeros(2,n); % sørger for at x har "riktig" lengde x(:,1)=[a;b]; % setter koordinatene til startpunktet for n=1:n A=[2*x(1,n)*x(2,n) x(1,n)^2;exp(x(1,n)) 1]; %setter A lik Jacobi-matrisen v=[x(1,n)^2*x(2,n)+1;exp(x(1,n))+x(2,n)]; %setter v lik funksjonsverdien x(:,n+1)=x(:,n)-a\v; % Utfører iterasjonen end For å kjøre programmet med startpunkt ( 0.7, 2.5), gir vi kommandoen >> [x,y]=newtonfler(-.7,-2.5,20); Vi kan få ut x- og y-verdiene ved å skrive henholdsvis >> x og >> y. Tabellen nedenfor viser de første verdiene: y n 16
17 x 0 = x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = x 10 = y 0 = y 1 = y 2 = y 3 = y 4 = y 5 = y 6 = y 7 = y 8 = y 9 = y 10 = Følgen ser altså ut til å konvergere mot et nullpunkt med koordinater tilnærmet lik (0.7035, ) (de neste tallene i utskriften bekrefter dette inntrykket). For å få bedre oversikt hvordan følgen oppfører seg, kan vi plotte den med kommandoen >> plot(x,y). Figur 1: Konvergens av Newtons metode Resultatet ser du i figur 1. Legg merke til at de siste skrittene er så små at du ikke kan se dem på figuren. Example Vi skal tegne grafen til f (x, y) = x 3 4y 2 over rektangelet x [ 3,3], y [ 5,5]. Vi lager først en oppdeling av de to intervallene vi er interessert i, ved å skrive r=-3:0.1:3; s=-5:0.1:5; (husk semikolon etter kommandoene, ellers vil du få lange tallremser som output!) Her har vi valgt å dele opp begge intervallene i skritt med lengde 0.1, men du kan godt velge en finere eller grovere oppdeling. Det kan være lurt å prøve en skikkelig grov oppdeling (f.eks. skrittlengde 0.5) en gang slik at du virkelig ser hvordan MATLAB tegner grafer. Neste skritt er å lage et rutenett av oppdelingene våre. Dette gjør vi med kommandoen >> [x,y]=meshgrid(r,s);} Vi kan nå definere funksjonen: >> z=x.^3-4*y.^2; 17
18 (husk å bruke.-versjonene av de algebraiske operasjonene!) Dermed er vi klare til selve plottingen som utføres av kommandoen >> mesh(x,y,z) Grafen kommer opp i et eget figurvindu akkurat som for todimensjonale figurer, og ser ut som et fiskegarn med knuter i plottepunktene. Ved å gå inn på menyen i grafvinduet, kan du dreie flaten i rommet (aktiver musa ved å klikke på et ikon som symboliserer dreiing). Dette er ofte nødvendig for å få et godt inntrykk av hvordan grafen ser ut! Bruker du kommandoen surf(x,y,z) istedenfor mesh(x,y,z), vil MATLAB tegne grafen med fargelegging av hvert ruteelement. Det er ofte klargjørende når grafen varierer mye. Vil du se nivåkurvene istedenfor grafen, bytter du ut med kommandoen >> contour(x,y,z) Når du bruker contour på denne måten, velger MATLAB selv hvilke nivåkurver den skal tegne. MATLAB er ikke alltid flink til å finne de mest interessante nivåkurvene, og det kan også tenkes at vi er interessert i helt konkrete nivåer, som programmet umulig kan gjette på. Derfor hender det at du må hjelpe til ved å angi konkrete nivåer: Dersom vektoren v = (v 1, v 2,..., v n ) er lagt inn, vil kommandoen >> contour(x,y,z,v) tvinge MATLAB til å tegne nivåkurvene med verdier v 1, v 2,..., v n. Vil du bare regulere antall nivåkurver, men ikke spesifisere verdiene, kan du bruke denne kommandoen >> contour(x,y,z,n) som får MATLAB til å tegne opp n nivåkurver. Med kommandoen clabel får du MATLAB til å skrive nivået til nivåkurvene på grafen. Prøv >> clabel(contour(x,y,z,12)) MATLAB vil normalt tegne nivåkurvene i forskjellige farger. Dette er nyttig på skjermen, men kan være mindre praktisk dersom du ønsker å lime figuren inn i et svart-hvitt dokument. Skriver du >> contour(x,y,z,8, k ) får du 8 nivåkurver tegnet i svart ( k er symbolet for svart farge). Ønsker du at MATLAB skal tegne nivåkurvene og grafen i samme plot, bruker du kommandoen 18
19 >> meshc(x,y,z) Det finnes mange andre kommandoer du også kan bruke (og mange flere måter å modifisere kommandoene ovenfor på!). Skriv >> help graph3d for å få en oversikt. Example Vi skal løse ligningssystemet Den utvidede matrisen er B = 2x y + 3z + u + v = 2 3x + y z + 2u v = 3 x 2y + 4z + u + 2v = og putter vi denne inn i MATLAB og bruker rref, får vi >> B=[ ]; >> C=rref(B) C = Den reduserte trappeformen er altså C = Vi ser at pivotsøylene er søyle 1, 2 og 4, og at de frie variablene er z (som korresponderer til søyle 3) og v (som korresponderer til søyle 5). Vi kan derfor velge z 19
20 og v fritt og løse for de andre variablene. Det er lettest å gjøre dette hvis vi først skriver opp ligningssystemet til C : x + 0.4z = 0.5 y 2.2z v = 0.5 u = 2.5 Vi ser at løsningene er gitt ved x = z y = z + v z = z u = 2.5 der z og v kan velges fritt. v = v Example Instead of converting 3761 to base 8 let us convert it to base 16. We find that 3761//16 = 235 with remainder 1. In the next step we find 235//16 = 14 with remainder 11. Finally we have 14//16 = 0 with remainder 14. Displayed in a table this becomes Recall that in the hexadecimal system the letters a f usually denote the values We have therefore found that the number 3761 is written eb1 16 in the hexadecimal numeral system. Example Let us continue to use the decimal number 3761 as an example, but now we want to convert it to binary form. If we perform the divisions and record the results as before we find 20
21 In other words we have 3761 = This example illustrates an important property of the binary numeral system: Computations are simple, but long and tedious. This means that this numeral system is not so good for humans as we tend to get bored and make sloppy mistakes. For computers, however, this is perfect as computers do not make mistakes and work extremely fast. Example Let us convert the hexadecimal number 3c5 16 to binary. We have 5 16 = , c 16 = , 3 16 = , which means that 3c5 16 = where we have omitted the two leading zeros. Example Let us convert the number x = 0.3a8 16 to binary. From table?? we find 3 16 = , a 16 = , 8 16 = , which means that 0.3a8 16 = = Example To convert the binary number to hexadecimal form we note from table?? that = c 16, = 9 16, = 6 16, =
22 Note that the last group of binary digits was not complete so we added three zeros. From this we conclude that = 0.c Example Let us find the representation of x = 6 in two s complement from (??) when n = 4. In this case x = 6 so x = = 10. The binary representation of the decimal number 10 is 1010 and this is the representation of 6 in two s complement. Example Let us consider a concrete example of how the UTF-8 code of a code point is determined. The ASCII characters are not so interesting since for these characters the UTF-8 code agrees with the code point. The Norwegian character i smorechalleng ing.i f wechecktheunicodechar t s, 1 we f indthat thi schar acterhasth 197. This is in the range which is covered by rule 2 in fact??. To determine the UTF-8 encoding we must find the binary representation of the code point. This is easy to deduce from the hexadecimal representation. The least significant numeral (5 in our case) determines the four least significant bits and the most significant numeral (c) determines the four most significant bits. Since 5 = and c 16 = , the code point in binary is c 5 {}}{{}}{ , where we have added three 0s to the left to get the eleven bits referred to by rule 2. We then distribute the eleven bits as in (??) and obtain the two bytes , In hexadecimal this corresponds to the two values c3 and 85 so the UTF-8 encoding of i sthet wo bytenumber c Example On a typical calculator we compute x = 2, then y = x 2, and finally z = y 2, i.e., the result should be z = ( 2 ) 2 2, which of course is 0. The result reported by the calculator is z = This is a simple example of round-off error. 1 The Latin 1 supplement can be found at 22
23 Example 0.20 (Examples of truncation). The number truncated to 4 digits is , while truncated to 2 digits is 120, and truncated to 4 digits is Example 0.21 (Examples of rounding). The number rounded to 4 digits is The result of rounding to 2 digits is 130, while rounded to 4 digits is Example 0.22 (Standard case). Suppose that a = and b = We convert the numbers to normal form and obtain a = , b = We add the two significands = so the correct answer is The last step is to convert this to normal form. In exact arithmetic this would yield the result However, this is not in normal form since the significand has five digits. We therefore perform rounding, , and get the final result Example 0.23 (One large and one small number). If a = and b = we convert the largest number to normal form = The smaller number b is then written in the same form (same exponent) = The significand in this second number must be rounded to four digits, and the result of this is The addition therefore becomes = Example 0.24 (Subtraction of two similar numbers I). Consider next a case where a = and b = have opposite signs. We first rewrite the numbers in normal form a = , b =
24 We then add the significands, which really amounts to a subtraction, = Finally, we write the number in normal form and obtain a + b = = (1) Example 0.25 (Subtraction of two similar numbers II). Suppose that a = 10/7 and b = Conversion to normal form yields Adding the significands yield 10 7 a = , b = = When this is converted to normal form, the result is while the true result rounded to four correct digits is (2) Example Consider the two numbers a = and b = which in normalised form are a = , b = To multiply the numbers, we multiply the significands and add the exponents, before we normalise the result at the end, if necessary. In our example we obtain a b = The significand in the result must be rounded to four digits and yields the floatingpoint number , i.e., the number
25 Example We use the same numbers as in example 0.25, but now we perform the division a/b. We have a b = = , i.e., we divide the significands and subtract the exponents. The division yields / We round this to four digits and obtain the result a b = Example Suppose we are going to evaluate the expression 1 x x (3) for a large number like x = The problem here is the fact that x and x are almost equal when x is large, x = 10 8 = , x Even with 64-bit floating-point numbers the square root will therefore be computed as 10 8, so the denominator in (3) will be computed as 0, and we get division by 0. This is a consequence of floating-point arithmetic since the two terms in the denominator are not really equal. A simple trick helps us out of this problem. Note that 1 x x = ( x x) ( x x)( x x) = x x x x 2 = x x. This alternative expression can be evaluated for large values of x without any problems with cancellation. The result for x = 10 8 is where all the digits are correct. x x Example For most values of x, the expression 1 cos 2 x sin 2 x (4) 25
26 can be computed without problems. However, for x = π/4 the denominator is 0, so we get division by 0 since cos x and sin x are equal for this value of x. This means that when x is close to π/4 we will get cancellation. This can be avoided by noting that cos 2 x sin 2 x = cos2x, so the expression (4) is equivalent to 1 cos2x. This can be evaluated without problems for all values of x for which the denominator is nonzero, as long as we do not get overflow. Example Consider the equation x n x n x n = 0, x 0 = 1, x 1 = 0. (5) Since the two roots of the characteristic equation r 2 2r /3 1/3 = 0 are r 1 = 1 and r 2 = 1/3, the general solution of the difference equation is ( x n = C + D 3) 1 n. The initial conditions yield the equations C + D = 1, C D/3 = 0, which has the solution C = 1/4 and D = 3/4. The solution of (5) is therefore x n = 1 4( 1 + ( 1) n 3 1 n). We observe that x n tends to 1/4 as n tends to infinity. If we simulate equation (5) on a computer, the next term is computed by the formula x n+2 = (2x n+1 + x n )/3. The division by 3 means that floating-point numbers are required to evaluate this expression. If we simulate the difference equation, we obtain the four approximate values x 10 = , x 15 = , x 20 = , x 30 = , (throughout this section we will use x n to denote a computed version of x n ), which agree with the exact solution to 12 digits. In other words, numerical simulation in this case works very well and produces essentially the same result as the exact formula, even if floating-point numbers are used in the calculations. 26
27 Example We consider the difference equation x n x n+1 + 2x n = 10, x 0 = 2, x 1 = 8/3. (6) The two roots of the characteristic equation are r 1 = 1/3 and r 2 = 6, so the general solution of the homogenous equation is x h n = C 3 n + D6 n. To find a particular solution we try a solution x p n = A which has the same form as the right-hand side. We insert this in the difference equation and find A = 3, so the general solution is x n = x h n + xp n = 3 +C 3 n + D6 n. (7) If we enforce the initial conditions, we end up with the system of equations 2 = x 0 = 3 +C + D, 8/3 = x 1 = 3 +C /3 + 6D. This may be rewritten as C + D = 1, C + 18D = 1. which has the solution C = 1 and D = 0. The final solution is therefore (8) (9) x n = 3 3 n, (10) which tends to 3 when n tends to infinity. Let us simulate the equation (6) on the computer. As in the previous example we have to divide by 3 so we have to use floating-point numbers. Some early terms in the computed sequence are x 5 = , x 10 = , x 15 = These values appear to approach 3 as they should. However, some later values are x 20 = , x 30 = , x 40 = , and at least the last two of these are obviously completely wrong! 27 (11)
28 Example We consider the third-order difference equation x n x n x n x n = 10 2 n, x 0 = 2, x 1 = 17 3, x 2 = The coefficients have been chosen so that the roots of the characteristic equation are r 1 = 1/3, r 2 = 1 and r 3 = 4. To find a particular solution we try with x p n = A2 n. If this is inserted in the equation we find A = 3, so the general solution is x n = 3 2 n + B3 n +C + D4 n. (12) The initial conditions force B = 0, C = 1 and D = 0, so the exact solution is x n = n. (13) The discussion above shows that this is bound to lead to problems. Because of round-off errors, the coefficients B and D will not be exactly 0 when the equation is simulated. Instead we will have x n = 3 2 n + ɛ 1 3 n + (1 + ɛ 2 ) + ɛ 3 4 n Even if ɛ 3 is small, the term ɛ 3 4 n will dominate when n becomes large. This is confirmed if we do the simulations. The computed value x 100 is approximately , while the exact value is , rounded to two digits. Example Suppose we have the text x = DBACDBD. We note that the frequencies of the four symbols are f (A) = 1, f (B) = 2, f (C ) = 1 and f (D) = 3. We assign the shortest codes to the most frequent symbols, c(d) = 0, c(b) = 1, c(c ) = 01, c(a) = 10. If we replace the symbols in x by their codes we obtain the compressed text z = , altogether 9 bits, instead of the 56 bits (7 bytes) required by a standard text representation. However, we now have a major problem, how can we decode and find the original text from this compressed version? Do the first two bits represent the two symbols D and B or is it the symbol C? One way to get round this problem is to have a special code that we can use to separate the symbols. But this is not a good solution as this would take up additional storage space. Example Consider the same four-symbol text x = DBACDBD as in example We now use the codes c(d) = 1, c(b) = 01, c(c ) = 001, c(a) = 000. (14) 28
29 We can then store the text as z = , (15) altogether 13 bits, while a standard encoding with one byte per character would require 56 bits. Note also that we can easily decipher the code since the codes have the prefix property. The first bit is 1 which must correspond to a D since this is the only character with a code that starts with a 1. The next bit is 0 and since this is the start of several codes we read one more bit. The only character with a code that start with 01 is B so this must be the next character. The next bit is 0 which does not uniquely identify a character so we read one more bit. The code 00 does not identify a character either, but with one more bit we obtain the code 000 which corresponds to the character A. We can obviously continue in this way and decipher the complete compressed text. Example In figure?? the tree in figure?? has been turned into a Huffman tree. The tree has been constructed from the text CCDACBDC with the alphabet {A,B,C,D} and frequencies f (A) = 1, f (B) = 1, f (C ) = 4 and f (D) = 2. It is easy to see that the weights have the properties required for a Huffman tree, and by following the edges we see that the Huffman codes are given by c(c ) = 0, c(d) = 10, c(a) = 110 and c(b) = 111. Note in particular that the root of the tree has weight equal to the length of the text. Example Let us try out algorithm?? on the text then the hen began to eat. This text consists of 25 characters, including the five spaces. We first determine the frequencies of the different characters by counting. We find the collection of one-node trees 4 t 3 h 5 e 3 n 1 b 1 g 2 a 1 o 5 where the last character denotes the space character. Since b and g are two characters with the lowest frequency, we combine them into a tree, 4 t 3 h 5 e 3 n 2 2 a 1 o b g The two trees with the lowest weights are now the character o and the tree we 29
30 formed in the last step. If we combine these we obtain 4 t 3 h 5 e 3 n b g o 2 a 5 Now we have several choices. We choose to combine a and h, 4 t h a 5 e 3 n b g o 5 At the next step we combine the two trees with weight 3, 4 t h a 5 e b g o n 5 Next we combine the t and the e, t e h a b g o n 5 30
31 We now have two trees with weight 5 that must be combined t e n 3 2 h a b g 1 o Again we combine the two trees with the smallest weights, h a n t e 2 1 o 1 1 b g By combining these two trees we obtain the final Huffman tree in figure 1. From this we can read off the Huffman codes as c(h) = 000, c(a) = 001, c( ) = 01, c(b) = 10000, c(g ) = 10001, c(o) = 1001, c(n) = 101, c(t) = 110, c(e) = 111. so we see that the Huffman coding of the text then the hen began to eat is The spaces and the new line have been added to make the code easier to read; on a computer these will not be present. 31
32 h a n t e 2 1 o 1 1 b g Figur 1: The Huffman tree for the text then the hen began to eat. The original text consists of 25 characters including the spaces. Encoding this with standard eight-bit encodings like ISO Latin or UTF-8 would require 400 bits. Since there are only nine symbols we could use a shorter fixed width encoding for this particular text. This would require five bits per symbol and would reduce the total length to 125 bits. In contrast the Huffman encoding only requires 75 bits. Example Let us return to example 0.36 and compute the entropy in this particular case. From the frequencies we obtain the probabilities c(t) = 4/25, c(h) = 3/25, c(e) = 1/5, c(n) = 3/25, c(b) = 1/25, c(g ) = 1/25, c(a) = 2/25, c(o) = 1/25, c( ) = 1/5. We can then compute the entropy to be H If we had a compression algorithm that could compress the text down to this number of bits per symbol, we could represent our 25-symbol text with 74 bits. This is only one bit less than what we obtained in example 0.36, so Huffman coding is very close to the best we can do for this particular text. Example Suppose that we have a two-symbol alphabet A = {0,1} with the probabilities p(0) = 0.9 and p(1) = 0.1. Huffman coding will then just use the obvious codes c(0) = 0 and c(1) = 1, so the average number of bits per symbol is 32
33 1, i.e., there will be no compression at all. If we compute the entropy we obtain H = 0.9log log So while Huffman coding gives no compression, there may be coding methods that will reduce the file size to less than half the original size. Example 0.39 (Determining an arithmetic code). We consider the two-symbol text As for Huffman coding we first need to determine the probabilities of the two symbols which we find to be p(0) = 0.8 and p(1) = 0.2. The idea is to allocate different parts of the interval [0,1) to the different symbols, and let the length of the subinterval be proportional to the probability of the symbol. In our case we allocate the interval [0,0.8) to 0 and the interval [0.8,1) to 1. Since our text starts with 0, we know that the floating-point number which is going to represent our text must lie in the interval [0,0.8), see the first line in figure??. We then split the two subintervals according to the two probabilities again. If the final floating point number ends up in the interval [0,0.64), the text starts with 00, if it lies in [0.64,0.8), the text starts with 01, if it lies in [0.8,0.96), the text starts with 10, and if the number ends up in [0.96,1) the text starts with 11. This is illustrated in the second line of figure??. Our text starts with 00, so the arithmetic code we are seeking must lie in the interval [0,0.64). At the next level we split each of the four sub-intervals in two again, as shown in the third line in figure??. Since the third symbol in our text is 1, the arithmetic code must lie in the interval [0.512,0.64). We next split this interval in the two subintervals [0.512,0.6144) and [0.6144,0.64). Since the fourth symbol is 0, we select the first interval. This interval is then split into [0.512, ) and [ ,0.6144). The final symbol of our text is 0, so the arithmetic code must lie in the interval [0.512, ). We know that the arithmetic code of our text must lie in the half-open interval [0.512, ), but it does not matter which of the numbers in the interval we use. The code is going to be handled by a computer so it must be represented in the binary numeral system, with a finite number of bits. We know that any number of this kind must be on the form i /2 k where k is a positive integer and i is an integer in the range 0 i < 2 k. Such numbers are called dyadic numbers. We obviously want the code to be as short as possible, so we are looking for the dyadic number with the smallest denominator that lies in the interval [0.512, ). In our simple example it is easy to see that this number is 9/16 = In binary this number is , so the arithmetic code for the text is Example Suppose we have the text x = {ACBBC AAB AA} and we want to encode it with arithmetic coding. We first note that the probabilities are given 33
34 by p(a) = 0.5, p(b) = 0.3, p(c ) = 0.2, so the cumulative probabilities are F (A) = 0.5, F (B) = 0.8 and F (C ) = 1.0. This means that the interval [0,1) is split into the three subintervals [0,0.5), [0.5,0.8), [0.8,1). The first symbol is A, so the first subinterval is [a 1,b 1 ) = [0,0.5). The second symbol is C so we must find the part of [a 1,b 1 ) that corresponds to C. The mapping from [0,1) to [0,0.5) is given by g 2 (z) = 0.5z so [0.8,1] is mapped to [a 2,b 2 ) = [ g 2 (0.8), g 2 (1) ) = [0.4,0.5). The third symbol is B which corresponds to the interval [0.5,0.8). We map [0,1) to the interval [a 2,b 2 ) with the function g 3 (z) = a 2 + z(b 2 a 2 ) = z so [0.5,0.8) is mapped to [a 3,b 3 ) = [ g 3 (0.5), g 3 (0.8) ) = [0.45,0.48). Let us now write down the rest of the computations more schematically in a table, g 4 (z) = z, x 4 = B, [a 4,b 4 ) = [ g 4 (0.5), g 4 (0.8) ) = [0.465,0.474), g 5 (z) = z, x 5 = C, [a 5,b 5 ) = [ g 5 (0.8), g 5 (1) ) = [0.4722,0.474), g 6 (z) = z, x 6 = A, [a 6,b 6 ) = [ g 6 (0), g 6 (0.5) ) = [0.4722,0.4731), g 7 (z) = z, x 7 = A, [a 7,b 7 ) = [ g 7 (0), g 7 (0.5) ) = [0.4722, ), g 8 (z) = z, x 8 = B, [a 8,b 8 ) = [ g 8 (0.5), g 8 (0.8) ) = [ , ), g 9 (z) = z, x 9 = A, g 10 (z) = z, x 10 = A, The midpoint M of this final interval is [a 9,b 9 ) = [ g 9 (0), g 9 (0.5) ) = [ , ), [a 10,b 10 ) = [ g 10 (0), g 10 (0.5) ) = [ , ). M = = , and the arithmetic code is M rounded to log 2 ( p(a) 5 p(b) 3 p(c ) 2) + 1 = 16 bits. The arithmetic code is therefore the number C (x) = = , 34
35 but we just store the 16 bits In this example the arithmetic code therefore uses 1.6 bits per symbol. In comparison the entropy is 1.49 bits per symbol. Example 0.41 (Decoding of an arithmetic code). Suppose we are given the arithmetic code 1001 from example 0.39 together with the probabilities p(0) = 0.8 and p(1) = 0.2. We also assume that the length of the code is known, the probabilities, and how the probabilities were mapped into the interval [0, 1]; this is the typical output of a program for arithmetic coding. Since we are going to do this manually, we start by converting the number to decimal; if we were to program arithmetic coding we would do everything in binary arithmetic. The arithmetic code 1001 corresponds to the binary number which is the decimal number z 1 = Since this number lies in the interval [0,0.8) we know that the first symbol is x 1 = 0. We now map the interval [0,0.8) and the code back to the interval [0,1) with the function We find that the code becomes h 1 (y) = y/0.8. z 2 = h 1 (z 1 ) = z 1 /0.8 = relative to the new interval. This number lies in the interval [0,0.8) so the second symbol is x 2 = 0. Once again we map the current interval and arithmetic code back to [0,1) with the function h 2 and obtain z 3 = h 2 (z 2 ) = z 2 /0.8 = This number lies in the interval [0.8,1), so our third symbol must be a x 3 = 1. At the next step we must map the interval [0.8,1) to [0,1). From observation?? we see that this is done by the function h 3 (y) = (y 0.8)/0.2. This means that the code is mapped to z 4 = h 3 (z 3 ) = (z 3 0.8)/0.2 = This brings us back to the interval [0,0.8), so the fourth symbol is x 4 = 0. This time we map back to [0,1) with the function h 4 (y) = y/0.8 and obtain z 5 = h 4 (z 4 ) = /0.8 = Since we remain in the interval [0,0.8) the fifth and last symbol is x 5 = 0, so the original text was
36 Example Let us test a naive compression strategy based on the above idea. The plots in figure?? illustrate the principle. A signal is shown in (a) and its DCT in (b). In (d) all values of the DCT with absolute value smaller than 0.02 have been set to zero. The signal can then be reconstructed with the inverse DCT of theorem??; the result of this is shown in (c). The two signals in (a) and (b) visually look almost the same even though the signal in (c) can be represented with less than 25 % of the information present in (a). We test this compression strategy on a data set that consists of points. We compute the DCT and set all values smaller than a suitable tolerance to 0. With a tolerance of 0.04, a total of values are set to zero. When we then reconstruct the sound with the inverse DCT, we obtain a signal that differs at most from the original signal. We can store the signal by storing a gzip ed version of the DCT-values (as 32-bit floating-point numbers) of the perturbed signal. This gives a file with bytes, which is 88 % of the gzip ed version of the original data. Example Suppose we want to find the zero 2 with error less than by solving the equation f (x) = x 2 2. We have f (1) = 1 and f (2) = 2, so we can use the Bisection method, starting with the interval [1,2]. To get the error to be smaller than 10 10, we know that N should be larger than ln(b a) lnɛ ln2 1 = 10ln10 ln Since N needs to be an integer this shows that N = 33 is guaranteed to make the error smaller than If we run algorithm?? we find m 0 = , m 1 = , m 2 = ,. m 33 = We have with eleven correct digits, and the actual error in m 33 is approximately Example Let us see if the predictions above happen in practice. We test the Secant method on the function f (x) = x 2 2 and attempt to compute the zero 36
37 c = We start with x 0 = 2 and x 1 = 1.5 and obtain x , e , x , e , x , e , x , e , x , e This confirms the claim in observation??. Example The equation is f (x) = x 2 2 which has the solution c = If we run Newton s method with the initial value x 0 = 1.7, we find x , e , x , e , x , e , x , e , x , e We see that although we only use one starting value, which is further from the root than the best of the two starting values used with the Secant method, we still end up with a smaller error than with the Secant method after five iterations. Example As mentioned in the beginning of this chapter, it may be that the position of an object is known only at isolated instances in time. Assume that we have a file with GPS data. In the file we are looking at, the positions are stored in terms of elevation, latitude, and longitude. Essentially these are what we call spherical coordinates. From the spherical coordinates one can easily compute cartesian coordinates, and also coordinates in a system where the three axes point towards east, north and upwards, respectively, as in a 2D and 3D map. Accompanying time instances are also stored in the file. Since the derivative of the position with respect to time is the speed, with the time instances one can approximate the speed by taking the absolute value of the Newton difference quotient. The position is, however, given in terms of the three coordinates. If we call the corresponding samples x n, y n, z n, and we apply Newton s difference quotient to each of these at all time instances, we get vectors v x,n, v y,n, v z,n, representing approximations to the speed in different directions. The speed vector at time instace n is the vector (v x,n, v y,n, v z,n ), and we define the speed at time instance n as (v x,n, v y,n, v z,n ) = vx,n 2 + v 2 y,n + vz,n. 2 37
38 North 500 Up East (a) The x axis points east, the y-axis points north East (b) The x axis points east, the y-axis points upwards x 10 4 (c) Time plotted againts speed Figur 2: Experiments with GPS data in a file Let us test this on some actual GPS data. In Figure 2(a)) we have plotted the GPS data in a coordinate system where the axes represent the east and north directions. In this system we can t see the elevation information in the data. In (b) we have plotted the data in a system where the axis represent the east and upward directions instead. Finally, in (c) we have also plotted the speed using the approximation we obtain from Newton s difference quotient. When visualized together with geographical data, such as colour indicating sea, forest, or habitated areas, this gives very useful information. Example Assume that we read samples from a digital sound file, and compute the Newton difference quotient for all samples in the file. The x-axis now represents time, and h is the sampling period (the difference in time betwe- 38
39 en two time samples). We can consider the set of all Newton difference quotients as samples in another sound, and we can listen to it. When we do this we hear a sound where the bass has been reduced. To see why, in chapter?? we argued that we could reduce the bass in sound by using a row in Pascals triangle with alternating sign, and (1,1) is the first row in Pascals triangle. But f (a + h) f (a) = h(f (a + h) f (a))/h, so that the Newton difference quotient is equivalent to the procedure for reducing bass, up to multiplication with a constant. In summary, when we differentiate a sound we reduce the bass in the sound. Example Let us test the approximation (??) for the function f (x) = sin x at a = 0.5 (using 64-bit floating-point numbers). In this case we know that the exact derivative is f (x) = cos x so f (a) with 10 correct digits. This makes it is easy to check the accuracy of the numerical method. We try with a few values of h and find ( )/ h f (a + h) f (a) h E(f ; a,h) where E(f ; a,h) = f (a) ( f (a+h) f (a) )/ h. We observe that the approximation improves with decreasing h, as expected. More precisely, when h is reduced by a factor of 10, the error is reduced by the same factor. Example Let us check that the error formula (??) agrees with the numerical values in example We have f (x) = sin x, so the right-hand side in (??) becomes E(sin;0.5,h) = h 2 sinξ h, where ξ h (0.5,0.5 + h). We do not know the exact value of ξ h, but for the values of h in question, we know that sin x is monotone on this interval. For h = 0.1 we therefore have that the error must lie in the interval [0.05sin0.5, 0.05sin0.6] = [ , ], and we see that the right end point of the interval is the maximum value of the right-hand side in (??). When h is reduced by a factor of 10, the number h/2 is reduced by the same factor, while ξ h is restricted to an interval whose width is also reduced by a factor 39
40 of 10. As h becomes even smaller, the number ξ h will approach 0.5 so sinξ h will approach the lower value sin For h = 10 n, the error will therefore tend to 10 n sin n, which is in close agreement with the numbers computed in example Example Recall that we estimated the derivative of f (x) = sin x at a = 0.5 and that the correct value with ten digits is f (0.5) If we check values of h for 10 7 and smaller we find ( )/ h f (a + h) f (a) h E(f ; a,h) This shows very clearly that something quite dramatic happens. Ultimately, when we come to h = 10 17, the derivative is computed as zero. Example We test the approximation (??) with the same values of h as in examples 0.48 and Recall that f (0.5) with 10 correct digits. The results are ( )/ h f (a + h) f (a h) (2h) E(f ; a,h) If we compare with examples 0.48 and 0.50, the errors are generally smaller for the same value of h. In particular we note that when h is reduced by a factor of 40
41 10, the error is reduced by a factor of 100, at least as long as h is not too small. However, when h becomes smaller than about 10 6, the error starts to increase. It therefore seems like the truncation error is smaller than for the original method based on Newton s quotient, but as before, the round-off error makes it impossible to get accurate results for small values of h. The optimal value of h seems to be h 10 6, which is larger than for the first method, but the error is then about 10 12, which is smaller than the best we could do with the asymmetric Newton s quotient. Example Let us try the midpoint rule on an example. As usual, it is wise to test on an example where we know the answer, so we can easily check the quality of the method. We choose the integral 1 0 cos x dx = sin where the exact answer is easy to compute by traditional, symbolic methods. To test the method, we split the interval into 2 k subintervals, for k = 1, 2,..., 10, i.e., we halve the step length each time. The result is By error, we here mean h I mid (h) Error f (x)dx I mid (h). Note that each time the step length is halved, the error seems to be reduced by a factor of 4. Example We test the trapezoidal rule on the same example as the midpoint rule, 1 0 cos x dx = sin
42 As in example 0.52 we split the interval into 2 k subintervals, for k = 1, 2,..., 10. The resulting approximations are where the error is defined by h I trap (h) Error f (x)dx I trap (h). We note that each time the step length is halved, the error is reduced by a factor of 4, just as for the midpoint rule. But we also note that even though we now use two function values in each subinterval to estimate the integral, the error is actually twice as big as it was for the midpoint rule. Example Let us test Simpson s rule on the same example as the midpoint rule and the trapezoidal rule, 1 0 cos x dx = sin As in example 0.52, we split the interval into 2 k subintervals, for k = 1, 2,..., 10. The result is h I Simp (h) Error
43 where the error is defined by 1 0 f (x)dx I Simp (h). When we compare this table with examples 0.52 and 0.53, we note that the error is now much smaller. We also note that each time the step length is halved, the error is reduced by a factor of 16. In other words, by introducing one more function evaluation in each subinterval, we have obtained a method with much better accuracy. This will be quite evident when we analyse the error below. Example We consider the differential equation x = t 3 2x, x(0) = (16) Suppose we want to compute an approximation to the solution at the points t 1 = 0.1, t 2 = 0.2,..., t 10 = 1, i.e., the points t k = kh for k = 1, 2,..., 10, with h = 0.1. We start with the initial point (t 0, x 0 ) = (0,0.25) and note that x 0 = x (0) = 0 3 2x(0) = 0.5. The tangent T 0 (t) to the solution at t = 0 is therefore given by T 0 (t) = x(0) + t x (0) = t. To advance the approximate solution to t = 0.1, we just follow this tangent, x(0.1) x 1 = T 0 (0.1) = = 0.2. At (t 1, x 1 ) = (0.1,0.2) the derivative is x 1 = f (t 1, x 1 ) = t 3 1 2x 1 = = 0.399, so the tangent at t 1 is T 1 (t) = x 1 + (t t 1 )x 1 = x 1 + (t t 1 )f (t 1, x 1 ) = 0.2 (t 0.1) The approximation at t 2 is therefore x(0.2) x 2 = T 1 (0.2) = x 1 + h f (t 1, x 1 ) = = If we continue in the same way, we find (we only print the first 4 decimals) x 3 = , x 4 = , x 5 = , x 6 = , x 7 = , x 8 = , x 9 = , x 10 = This is illustrated in figure?? where the computed points are connected by straight line segments. 43
44 Example Let us consider the differential equation x = f (t, x) = F 1 (t, x) = t 1, x(0) = 1, (17) 1 + x which we want to solve on the interval [0,1]. To illustrate the method, we choose a large step length h = 0.5 and attempt to find an approximate numerical solution at x = 0.5 and x = 1 using a quadratic Taylor method. From (20) we obtain x (t) = F 2 (t, x) = 1 + x (t) ( 1 + x(t) ) 2. (18) To compute an approximation to x(h) we use the quadratic Taylor polynomial x(h) x 1 = x(0) + hx (0) + h2 2 x (0). The differential equation (20) and (21) give us the values which leads to the approximation x(0) = x 0 = 1, x (0) = x 0 = 0 1/2 = 1/2, x (0) = x 0 = 1 1/8 = 7/8, x(h) x 1 = x 0 + hx 0 + h2 2 x 0 = 1 h 2 + 7h2 16 = To prepare for the next step we need to determine approximations to x (h) and x (h) as well. From the differential equation (20) and (21) we find x (h) x 1 = F 1(t 1, x 1 ) = t 1 1/(1 + x 1 ) = , x (h) x 1 = F 2(t 1, x 1 ) = 1 + x 1 /(1 + x 1) 2 = , rounded to eight digits. From this we can compute the approximation x(1) = x(2h) x 2 = x 1 + hx 1 + h2 2 x 1 = The result is shown in figure??a. 44
45 Example 0.57 (Euler s method for a system). We consider the equations in example??, x = f (t, x), x(a) = x 0, where f (t, x) = ( f 1 (t, x 1, x 2, x 3 ), f 2 (t, x 1, x 2, x 3 ), f 3 (t, x 1, x 2, x 3 ) ) = (x 1 x 2 + cos x 3,2 t 2 + x 2 3 x 2,sin t x 1 + x 2 ). Euler s method is easily generalised to vector equations as x k+1 = x k + h f (t k, x k ), k = 0, 1,..., n 1. (19) If we write out the three components explicitly, this becomes x1 k+1 = x1 k + h f 1(t k, x1 k, xk 2, xk 3 ) = xk 1 + h( x1 k xk 2 + cos ) xk 3, x2 k+1 = x2 k + h f 2(t k, x1 k, xk 2, xk 3 ) = xk 2 + h( 2 t 2 k + (xk 3 )2 x2 k ), x3 k+1 = x3 k + h f 3(t k, x1 k, xk 2, xk 3 ) = xk 3 + h( sin t k x1 k + ) xk 2, (20) for k = 0, 1,..., n 1, with the starting values (a, x1 0, x0 2, x0 3 ) given by the initial condition. Although they look rather complicated, these formulas can be programmed quite easily. The trick is to make use of the vector notation in (22), since it nicely hides the details in (23). Example 0.58 (System of higher order equations). Consider the system of differential equations given by x = t + x + y, x(0) = 1, x (0) = 2, y = x y + x, y(0) = 1, y (0) = 1, y (0) = 2. We introduce the new functions x 1 = x, x 2 = x, y 1 = y, y 2 = y, and y 3 = y. Then the above system can be written as x 1 = x 2, x 1 (0) = 1, x 2 = t + x 2 + y 2, x 2 (0) = 2, y 1 = y 2, y 1 (0) = 1, y 2 = y 3, y 2 (0) = 1, y 3 = x 2y 3 + x 1, y 3 (0) = 2. Example Look at the following code snippet: 45
46 boolean test1 = true; boolean test2 = false; if test1{ System.out.println("This code is executed."); } if test2{ System.out.println("This code isn t executed."); } Here the explicitly declared Boolean variables test1 and test2 are used by if. Since test1 is true, the first if checks out, and the code between { and } is executed. Since test2 is false, the second if fails, and the code isn t executed. Example The first two ifs check out, and are executed, the third fails: int smallnumber = 13; if (smallnumber > 5){ System.out.println("Greater than 5"); } if (smallnumber > 10){ System.out.println("Greater than 10"); } if (smallnumber > 15){ System.out.println("Greater than 15"); } 46
Examples plotting. Øyvind Ryan
Examples plotting Øyvind Ryan 19. februar 2013 Example 0.1. Vi skal tegne grafen til f (x, y) = x 3 4y 2 over rektangelet x [ 3,3], y [ 5,5]. Vi lager først en oppdeling av de to intervallene vi er interessert
Examples MAT1110. Øyvind Ryan
Examples MAT1110 Øyvind Ryan 19. februar 2013 Example 0.1. Vi skal tegne grafen til f (x, y) = x 3 4y 2 over rektangelet x [ 3,3], y [ 5,5]. Vi lager først en oppdeling av de to intervallene vi er interessert
Slope-Intercept Formula
LESSON 7 Slope Intercept Formula LESSON 7 Slope-Intercept Formula Here are two new words that describe lines slope and intercept. The slope is given by m (a mountain has slope and starts with m), and intercept
Mathematics 114Q Integration Practice Problems SOLUTIONS. = 1 8 (x2 +5x) 8 + C. [u = x 2 +5x] = 1 11 (3 x)11 + C. [u =3 x] = 2 (7x + 9)3/2
Mathematics 4Q Name: SOLUTIONS. (x + 5)(x +5x) 7 8 (x +5x) 8 + C [u x +5x]. (3 x) (3 x) + C [u 3 x] 3. 7x +9 (7x + 9)3/ [u 7x + 9] 4. x 3 ( + x 4 ) /3 3 8 ( + x4 ) /3 + C [u + x 4 ] 5. e 5x+ 5 e5x+ + C
Neural Network. Sensors Sorter
CSC 302 1.5 Neural Networks Simple Neural Nets for Pattern Recognition 1 Apple-Banana Sorter Neural Network Sensors Sorter Apples Bananas 2 Prototype Vectors Measurement vector p = [shape, texture, weight]
Trigonometric Substitution
Trigonometric Substitution Alvin Lin Calculus II: August 06 - December 06 Trigonometric Substitution sin 4 (x) cos (x) dx When you have a product of sin and cos of different powers, you have three different
Unit Relational Algebra 1 1. Relational Algebra 1. Unit 3.3
Relational Algebra 1 Unit 3.3 Unit 3.3 - Relational Algebra 1 1 Relational Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics which underpin SQL
UNIVERSITETET I OSLO
UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Eksamen i MAT2400 Analyse 1. Eksamensdag: Onsdag 15. juni 2011. Tid for eksamen: 09.00 13.00 Oppgavesettet er på 6 sider. Vedlegg: Tillatte
MA2501 Numerical methods
MA250 Numerical methods Solutions to problem set Problem a) The function f (x) = x 3 3x + satisfies the following relations f (0) = > 0, f () = < 0 and there must consequently be at least one zero for
Dynamic Programming Longest Common Subsequence. Class 27
Dynamic Programming Longest Common Subsequence Class 27 Protein a protein is a complex molecule composed of long single-strand chains of amino acid molecules there are 20 amino acids that make up proteins
Hvor mye praktisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye)
INF247 Er du? Er du? - Annet Ph.D. Student Hvor mye teoretisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye) Hvor mye praktisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen,
Universitetet i Bergen Det matematisk-naturvitenskapelige fakultet Eksamen i emnet Mat131 - Differensiallikningar I Onsdag 25. mai 2016, kl.
1 MAT131 Bokmål Universitetet i Bergen Det matematisk-naturvitenskapelige fakultet Eksamen i emnet Mat131 - Differensiallikningar I Onsdag 25. mai 2016, kl. 09-14 Oppgavesettet er 4 oppgaver fordelt på
UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS
UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS Postponed exam: ECON420 Mathematics 2: Calculus and linear algebra Date of exam: Tuesday, June 8, 203 Time for exam: 09:00 a.m. 2:00 noon The problem set covers
TMA4329 Intro til vitensk. beregn. V2017
Norges teknisk naturvitenskapelige universitet Institutt for Matematiske Fag TMA439 Intro til vitensk. beregn. V17 ving 4 [S]T. Sauer, Numerical Analysis, Second International Edition, Pearson, 14 Teorioppgaver
Moving Objects. We need to move our objects in 3D space.
Transformations Moving Objects We need to move our objects in 3D space. Moving Objects We need to move our objects in 3D space. An object/model (box, car, building, character,... ) is defined in one position
Exercise 1: Phase Splitter DC Operation
Exercise 1: DC Operation When you have completed this exercise, you will be able to measure dc operating voltages and currents by using a typical transistor phase splitter circuit. You will verify your
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Exam: ECON320/420 Mathematics 2: Calculus and Linear Algebra Eksamen i: ECON320/420 Matematikk 2: Matematisk analyse og lineær algebra Date of exam: Friday, May
Call function of two parameters
Call function of two parameters APPLYUSER USER x fµ 1 x 2 eµ x 1 x 2 distinct e 1 0 0 v 1 1 1 e 2 1 1 v 2 2 2 2 e x 1 v 1 x 2 v 2 v APPLY f e 1 e 2 0 v 2 0 µ Evaluating function application The math demands
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON30/40 Matematikk : Matematisk analyse og lineær algebra Exam: ECON30/40 Mathematics : Calculus and Linear Algebra Eksamensdag: Tirsdag 0. desember
UNIVERSITETET I OSLO
UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Eksamen i INF 3230 Formell modellering og analyse av kommuniserende systemer Eksamensdag: 4. juni 2010 Tid for eksamen: 9.00 12.00 Oppgavesettet
Oppgave 1a Definer følgende begreper: Nøkkel, supernøkkel og funksjonell avhengighet.
TDT445 Øving 4 Oppgave a Definer følgende begreper: Nøkkel, supernøkkel og funksjonell avhengighet. Nøkkel: Supernøkkel: Funksjonell avhengighet: Data i en database som kan unikt identifisere (et sett
Databases 1. Extended Relational Algebra
Databases 1 Extended Relational Algebra Relational Algebra What is an Algebra? Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators ---
SVM and Complementary Slackness
SVM and Complementary Slackness David Rosenberg New York University February 21, 2017 David Rosenberg (New York University) DS-GA 1003 February 21, 2017 1 / 20 SVM Review: Primal and Dual Formulations
Eksamensoppgave i TMA4320 Introduksjon til vitenskapelige beregninger
Institutt for matematiske fag Eksamensoppgave i TMA432 Introduksjon til vitenskapelige beregninger Faglig kontakt under eksamen: Anton Evgrafov Tlf: 453 163 Eksamensdato: 8. august 217 Eksamenstid (fra
Speed Racer Theme. Theme Music: Cartoon: Charles Schultz / Jef Mallett Peanuts / Frazz. September 9, 2011 Physics 131 Prof. E. F.
September 9, 2011 Physics 131 Prof. E. F. Redish Theme Music: Speed Racer Theme Cartoon: Charles Schultz / Jef Mallett Peanuts / Frazz 1 Reading questions Are the lines on the spatial graphs representing
FYSMEK1110 Eksamensverksted 23. Mai :15-18:00 Oppgave 1 (maks. 45 minutt)
FYSMEK1110 Eksamensverksted 23. Mai 2018 14:15-18:00 Oppgave 1 (maks. 45 minutt) Page 1 of 9 Svar, eksempler, diskusjon og gode råd fra studenter (30 min) Hva får dere poeng for? Gode råd fra forelesere
5 E Lesson: Solving Monohybrid Punnett Squares with Coding
5 E Lesson: Solving Monohybrid Punnett Squares with Coding Genetics Fill in the Brown colour Blank Options Hair texture A field of biology that studies heredity, or the passing of traits from parents to
Den som gjør godt, er av Gud (Multilingual Edition)
Den som gjør godt, er av Gud (Multilingual Edition) Arne Jordly Click here if your download doesn"t start automatically Den som gjør godt, er av Gud (Multilingual Edition) Arne Jordly Den som gjør godt,
Physical origin of the Gouy phase shift by Simin Feng, Herbert G. Winful Opt. Lett. 26, (2001)
by Simin Feng, Herbert G. Winful Opt. Lett. 26, 485-487 (2001) http://smos.sogang.ac.r April 18, 2014 Introduction What is the Gouy phase shift? For Gaussian beam or TEM 00 mode, ( w 0 r 2 E(r, z) = E
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON20/420 Matematikk 2: Matematisk analyse og lineær algebra Exam: ECON20/420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Fredag 2. mai
Endelig ikke-røyker for Kvinner! (Norwegian Edition)
Endelig ikke-røyker for Kvinner! (Norwegian Edition) Allen Carr Click here if your download doesn"t start automatically Endelig ikke-røyker for Kvinner! (Norwegian Edition) Allen Carr Endelig ikke-røyker
Han Ola of Han Per: A Norwegian-American Comic Strip/En Norsk-amerikansk tegneserie (Skrifter. Serie B, LXIX)
Han Ola of Han Per: A Norwegian-American Comic Strip/En Norsk-amerikansk tegneserie (Skrifter. Serie B, LXIX) Peter J. Rosendahl Click here if your download doesn"t start automatically Han Ola of Han Per:
Graphs similar to strongly regular graphs
Joint work with Martin Ma aj 5th June 2014 Degree/diameter problem Denition The degree/diameter problem is the problem of nding the largest possible graph with given diameter d and given maximum degree
Gir vi de resterende 2 oppgavene til én prosess vil alle sitte å vente på de to potensielt tidskrevende prosessene.
Figure over viser 5 arbeidsoppgaver som hver tar 0 miutter å utføre av e arbeider. (E oppgave ka ku utføres av é arbeider.) Hver pil i figure betyr at oppgave som blir pekt på ikke ka starte før oppgave
Gradient. Masahiro Yamamoto. last update on February 29, 2012 (1) (2) (3) (4) (5)
Gradient Masahiro Yamamoto last update on February 9, 0 definition of grad The gradient of the scalar function φr) is defined by gradφ = φr) = i φ x + j φ y + k φ ) φ= φ=0 ) ) 3) 4) 5) uphill contour downhill
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Utsatt ksamen i: ECON3120/4120 Matematikk 2: Matematisk analyse og lineær algebra Postponed exam: ECON3120/4120 Mathematics 2: Calculus and linear algebra Eksamensdag:
Ma Flerdimensjonal Analyse Øving 1
Ma1203 - Flerdimensjonal Analyse Øving 1 Øistein Søvik Brukernavn: Oistes 23.01.2012 Oppgaver 10.1 6. Show that the triangle with verticies (1, 2, 3), (4, 0, 5) and (3, 6, 4) has a right angle. z y x Utifra
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON3120/4120 Matematikk 2: Matematisk analyse og lineær algebra Exam: ECON3120/4120 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Tirsdag
SAS FANS NYTT & NYTTIG FRA VERKTØYKASSA TIL SAS 4. MARS 2014, MIKKEL SØRHEIM
SAS FANS NYTT & NYTTIG FRA VERKTØYKASSA TIL SAS 4. MARS 2014, MIKKEL SØRHEIM 2 TEMA 1 MULTIPROSESSERING MED DATASTEGET Multiprosessering har lenge vært et tema i SAS Stadig ny funksjonalitet er med på
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON320/420 Matematikk 2: Matematisk analyse og lineær algebra Exam: ECON320/420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Mandag 8. desember
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Utsatt eksamen i: ECON420 Matematikk 2: Matematisk analyse og lineær algebra Postponed exam: ECON420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Mandag
KROPPEN LEDER STRØM. Sett en finger på hvert av kontaktpunktene på modellen. Da får du et lydsignal.
KROPPEN LEDER STRØM Sett en finger på hvert av kontaktpunktene på modellen. Da får du et lydsignal. Hva forteller dette signalet? Gå flere sammen. Ta hverandre i hendene, og la de to ytterste personene
ECON3120/4120 Mathematics 2, spring 2004 Problem solutions for the seminar on 5 May Old exam problems
Department of Economics May 004 Arne Strøm ECON0/40 Mathematics, spring 004 Problem solutions for the seminar on 5 May 004 (For practical reasons (read laziness, most of the solutions this time are in
Emneevaluering GEOV272 V17
Emneevaluering GEOV272 V17 Studentenes evaluering av kurset Svarprosent: 36 % (5 av 14 studenter) Hvilket semester er du på? Hva er ditt kjønn? Er du...? Er du...? - Annet PhD Candidate Samsvaret mellom
Hvordan føre reiseregninger i Unit4 Business World Forfatter:
Hvordan føre reiseregninger i Unit4 Business World Forfatter: [email protected] Denne e-guiden beskriver hvordan du registrerer en reiseregning med ulike typer utlegg. 1. Introduksjon 2. Åpne vinduet
Dagens tema: Eksempel Klisjéer (mønstre) Tommelfingerregler
UNIVERSITETET I OSLO INF1300 Introduksjon til databaser Dagens tema: Eksempel Klisjéer (mønstre) Tommelfingerregler Institutt for informatikk Dumitru Roman 1 Eksempel (1) 1. The system shall give an overview
Exam in Quantum Mechanics (phys201), 2010, Allowed: Calculator, standard formula book and up to 5 pages of own handwritten notes.
Exam in Quantum Mechanics (phys01), 010, There are 3 problems, 1 3. Each problem has several sub problems. The number of points for each subproblem is marked. Allowed: Calculator, standard formula book
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON3120/4120 Mathematics 2: Calculus an linear algebra Exam: ECON3120/4120 Mathematics 2: Calculus an linear algebra Eksamensag: Tirsag 3. juni 2008
0:7 0:2 0:1 0:3 0:5 0:2 0:1 0:4 0:5 P = 0:56 0:28 0:16 0:38 0:39 0:23
UTKAST ENGLISH VERSION EKSAMEN I: MOT100A STOKASTISKE PROSESSER VARIGHET: 4 TIMER DATO: 16. februar 2006 TILLATTE HJELPEMIDLER: Kalkulator; Tabeller og formler i statistikk (Tapir forlag): Rottman: Matematisk
Stationary Phase Monte Carlo Methods
Stationary Phase Monte Carlo Methods Daniel Doro Ferrante G. S. Guralnik, J. D. Doll and D. Sabo HET Physics Dept, Brown University, USA. [email protected] www.het.brown.edu Introduction: Motivations
Perpetuum (im)mobile
Perpetuum (im)mobile Sett hjulet i bevegelse og se hva som skjer! Hva tror du er hensikten med armene som slår ut når hjulet snurrer mot høyre? Hva tror du ordet Perpetuum mobile betyr? Modell 170, Rev.
Solutions #12 ( M. y 3 + cos(x) ) dx + ( sin(y) + z 2) dy + xdz = 3π 4. The surface M is parametrized by σ : [0, 1] [0, 2π] R 3 with.
Solutions #1 1. a Show that the path γ : [, π] R 3 defined by γt : cost ı sint j sint k lies on the surface z xy. b valuate y 3 cosx dx siny z dy xdz where is the closed curve parametrized by γ. Solution.
TFY4170 Fysikk 2 Justin Wells
TFY4170 Fysikk 2 Justin Wells Forelesning 5: Wave Physics Interference, Diffraction, Young s double slit, many slits. Mansfield & O Sullivan: 12.6, 12.7, 19.4,19.5 Waves! Wave phenomena! Wave equation
Hvor mye teoretisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye)
INF234 Er du? Er du? - Annet Hvor mye teoretisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye) Hvor mye praktisk kunnskap har du tilegnet deg på dette emnet? (1 = ingen, 5 = mye) Hvor
Start MATLAB. Start NUnet Applications Statistical and Computational packages MATLAB Release 13 MATLAB 6.5
Start MATLAB Start NUnet Applications Statistical and Computational packages MATLAB Release 13 MATLAB 6.5 Prompt >> will appear in the command window Today: MATLAB overview In-class HW: Chapter 1, Problems
MAT1110: Obligatorisk oppgave 2, V Løsningsforslag
MAT1110: Obligatorisk oppgave 2, V-2015 Oppgave 1: a) Vi har Av 1 = ( 4 6 6 1 Løsningsforslag ) ( 3 2 ) = ( 24 16 ) = 8v 1, så v 1 er en egenvektor med egenverdi 8. Tilsvarende er ( ) ( ) ( ) 4 6 2 10
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON320/420 Matematikk 2: Matematisk analyse og lineær algebra Exam: ECON320/420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Onsdag 6. desember
Oppgave 1. ( xφ) φ x t, hvis t er substituerbar for x i φ.
Oppgave 1 Beviskalklen i læreboka inneholder sluttningsregelen QR: {ψ φ}, ψ ( xφ). En betingelse for å anvende regelen er at det ikke finnes frie forekomste av x i ψ. Videre så inneholder beviskalklen
UNIVERSITETET I OSLO
UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Eksamen i: KJB 492 Bioinformatikk Eksamensdag: Fredag 14. desember 2001 Tid for eksamen: Kl.: 9.00 13.00 Oppgavesettet er på 7 sider. Vedlegg:
Fasit til utvalgte oppgaver MAT1110, uka 28/4-2/5
Fasit til utvalgte oppgaver MAT1110, uka 8/4-/5 Tom Lindstrøm ([email protected]) 5..5 a) Alle punktene i B har avstand til origo større enn 1, så d(0, B) må være minst 1. Ved å velge punkter på x-aksen
Information search for the research protocol in IIC/IID
Information search for the research protocol in IIC/IID 1 Medical Library, 2013 Library services for students working with the research protocol and thesis (hovedoppgaven) Open library courses: http://www.ntnu.no/ub/fagside/medisin/medbiblkurs
GEO231 Teorier om migrasjon og utvikling
U N I V E R S I T E T E T I B E R G E N Institutt for geografi Emnerapport høsten 2013: GEO231 Teorier om migrasjon og utvikling Innhold: 1. Informasjon om emnet 2. Statistikk 3. Egenevaluering 4. Studentevaluering
Du må håndtere disse hendelsene ved å implementere funksjonene init(), changeh(), changev() og escape(), som beskrevet nedenfor.
6-13 July 2013 Brisbane, Australia Norwegian 1.0 Brisbane har blitt tatt over av store, muterte wombater, og du må lede folket i sikkerhet. Veiene i Brisbane danner et stort rutenett. Det finnes R horisontale
UNIVERSITETET I OSLO
UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Eksamen i INF 3230 Formell modellering og analyse av kommuniserende systemer Eksamensdag: 4. april 2008 Tid for eksamen: 9.00 12.00 Oppgavesettet
Norsk (English below): Guide til anbefalt måte å printe gjennom plotter (Akropolis)
Norsk (English below): Guide til anbefalt måte å printe gjennom plotter (Akropolis) 1. Gå til print i dokumentet deres (Det anbefales å bruke InDesign til forberedning for print) 2. Velg deretter print
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON1910 Poverty and distribution in developing countries Exam: ECON1910 Poverty and distribution in developing countries Eksamensdag: 1. juni 2011 Sensur
IN2010: Algoritmer og Datastrukturer Series 2
Universitetet i Oslo Institutt for Informatikk S.M. Storleer, S. Kittilsen IN2010: Algoritmer og Datastrukturer Series 2 Tema: Grafteori 1 Publisert: 02. 09. 2019 Utvalgte løsningsforslag Oppgave 1 (Fra
Andrew Gendreau, Olga Rosenbaum, Anthony Taylor, Kenneth Wong, Karl Dusen
Andrew Gendreau, Olga Rosenbaum, Anthony Taylor, Kenneth Wong, Karl Dusen The Process Goal Definition Data Collection Data Preprocessing EDA Choice of Variables Choice of Method(s) Performance Evaluation
TMA4240 Statistikk 2014
Norges teknisk-naturvitenskapelige universitet Institutt for matematiske fag Øving nummer 6, blokk I Løsningsskisse Oppgave 1 Fremgangsmetode: P X 1 < 6.8 Denne kan finnes ved å sette opp integralet over
Obligatorisk oppgave 1
Obligatorisk oppgave 1 a) Oppgaveteksten oppgir et vektorfelt f(x, y) F x, y = g x, y der f og g er oppgitt ved f x, y = x 3 3xy 1 og g x, y = y 3 + 3x y. Vi kan med dette regne ut Jacobimatrisen F x,
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Eksamen i: ECON320/420 Matematikk 2: Matematisk analyse og lineær algebra Exam: ECON320/420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Tirsdag 7. juni
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
1 UNIVERSITETET I OSLO ØKONOMISK INSTITUTT BOKMÅL Utsatt eksamen i: ECON2915 Vekst og næringsstruktur Eksamensdag: 07.12.2012 Tid for eksamen: kl. 09:00-12:00 Oppgavesettet er på 5 sider Tillatte hjelpemidler:
Kneser hypergraphs. May 21th, CERMICS, Optimisation et Systèmes
Kneser hypergraphs Frédéric Meunier May 21th, 2015 CERMICS, Optimisation et Systèmes Kneser hypergraphs m, l, r three integers s.t. m rl. Kneser hypergraph KG r (m, l): V (KG r (m, l)) = ( [m]) l { E(KG
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSIEE I OSLO ØKONOMISK INSIU Eksamen i: ECON320/420 Mathematics 2: Calculus and Linear Algebra Exam: ECON320/420 Mathematics 2: Calculus and Linear Algebra Eksamensdag:. desember 207 Sensur kunngjøres:
EKSAMENSOPPGAVE I FAG TKP 4105
EKSAMENSOPPGAVE I FAG TKP 4105 Faglig kontakt under eksamen: Sigurd Skogestad Tlf: 913 71669 (May-Britt Hägg Tlf: 930 80834) Eksamensdato: 08.12.11 Eksamenstid: 09:00 13:00 7,5 studiepoeng Tillatte hjelpemidler:
UNIVERSITETET I OSLO
UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Eksamen i INF 3230/4230 Formell modellering og analyse av kommuniserende systemer Eksamensdag: 24. mars 2006 Tid for eksamen: 13.30 16.30
Instructions for the base (B)-treatment and the elicitation (E)-treatment of the experiment
Appendix Instructions for the base (B)-treatment and the elicitation (E)-treatment of the experiment We here provide the instructions given to the participants at the beginning of the session and throughout
Eksamensoppgave i TMA4320 Introduksjon til vitenskapelige beregninger
Institutt for matematiske fag Eksamensoppgave i TMA4320 Introduksjon til vitenskapelige beregninger Faglig kontakt under eksamen: Anton Evgrafov Tlf: 4503 0163 Eksamensdato: 30. mai 2017 Eksamenstid (fra
Matematikk Øvingsoppgaver i numerikk leksjon 1. Løsningsforslag
Matematikk 1000 Øvingsoppgaver i numerikk leksjon 1 Løsningsforslag Oppgave 2 Litt aritmetikk a) Her har vi skrevet ut det som kommer opp i kommandovinduet når vi utfører operasjonene. > 2+2 4 > 3-2 1
Appendix B, not for publication, with screenshots for Fairness and family background
Appendix B, not for publication, with screenshots for Fairness and family background Ingvild Almås Alexander W. Cappelen Kjell G. Salvanes Erik Ø. Sørensen Bertil Tungodden This document shows screenshots
IN 211 Programmeringsspråk. Dokumentasjon. Hvorfor skrive dokumentasjon? For hvem? «Lesbar programmering» Ark 1 av 11
Dokumentasjon Hvorfor skrive dokumentasjon? For hvem? «Lesbar programmering» Ark 1 av 11 Forelesning 8.11.1999 Dokumentasjon Med hvert skikkelig program bør det komme følgende dokumentasjon: innføring
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT
UNIVERSITETET I OSLO ØKONOMISK INSTITUTT Utsatt eksamen i: ECON420 Matematikk 2: Matematisk analyse og lineær algebra Postponed exam: ECON420 Mathematics 2: Calculus and Linear Algebra Eksamensdag: Mandag
FIRST LEGO League. Härnösand 2012
FIRST LEGO League Härnösand 2012 Presentasjon av laget IES Dragons Vi kommer fra Härnosänd Snittalderen på våre deltakere er 11 år Laget består av 4 jenter og 4 gutter. Vi representerer IES i Sundsvall
HONSEL process monitoring
6 DMSD has stood for process monitoring in fastening technology for more than 25 years. HONSEL re- rivet processing back in 990. DMSD 2G has been continuously improved and optimised since this time. All
Newtons fargeskive. Regnbuens farger blir til hvitt. Sett skiva i rask rotasjon ved hjelp av sveiva.
Newtons fargeskive Regnbuens farger blir til hvitt. Sett skiva i rask rotasjon ved hjelp av sveiva. Se hva som skjer med fargene. Hvitt lys består av en blanding av alle farger. Når fargeskiva roterer
1. Finn egenverdiene og egenvektorene til matrisen A = 2 1 A =
Fasit MAT102 juni 2017 Oppgave 1 1. Finn egenverdiene og egenvektorene til matrisen ( ) 1 2 A = 2 1 Løsning: Egenverdiene er røttene til det karakteristiske polynom gitt ved determinanten av matrisen (
GYRO MED SYKKELHJUL. Forsøk å tippe og vri på hjulet. Hva kjenner du? Hvorfor oppfører hjulet seg slik, og hva er egentlig en gyro?
GYRO MED SYKKELHJUL Hold i håndtaket på hjulet. Sett fart på hjulet og hold det opp. Det er lettest om du sjølv holder i håndtakene og får en venn til å snurre hjulet rundt. Forsøk å tippe og vri på hjulet.
C13 Kokstad. Svar på spørsmål til kvalifikasjonsfasen. Answers to question in the pre-qualification phase For English: See page 4 and forward
C13 Kokstad Svar på spørsmål til kvalifikasjonsfasen Answers to question in the pre-qualification phase For English: See page 4 and forward Norsk Innhold 1. Innledning... 2 2. Spørsmål mottatt per 28.11.12...
Vekeplan 4. Trinn. Måndag Tysdag Onsdag Torsdag Fredag AB CD AB CD AB CD AB CD AB CD. Norsk Matte Symjing Ute Norsk Matte M&H Norsk
Vekeplan 4. Trinn Veke 39 40 Namn: Måndag Tysdag Onsdag Torsdag Fredag AB CD AB CD AB CD AB CD AB CD Norsk Engelsk M& Mitt val Engelsk Matte Norsk Matte felles Engelsk M& Mitt val Engelsk Norsk M& Matte
Kartleggingsskjema / Survey
Kartleggingsskjema / Survey 1. Informasjon om opphold i Norge / Information on resident permit in Norway Hvilken oppholdstillatelse har du i Norge? / What residence permit do you have in Norway? YES No
PATIENCE TÅLMODIGHET. Is the ability to wait for something. Det trenger vi når vi må vente på noe
CARING OMSORG Is when we show that we care about others by our actions or our words Det er når vi viser at vi bryr oss om andre med det vi sier eller gjør PATIENCE TÅLMODIGHET Is the ability to wait for
stjerneponcho for voksne star poncho for grown ups
stjerneponcho for voksne star poncho for grown ups www.pickles.no / shop.pickles.no NORSK Størrelser XS (S) M (L) Garn Pickles Pure Alpaca 300 (350) 400 (400) g hovedfarge 100 (100) 150 (150) g hver av
