Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Videoforklaring (19:00)

Del 1 (099:47)Del 2 (099:13)
Widget Connector
urlhttps://www.youtube.com/watch?v=zsCSVsX8Sk0
Widget Connector
urlhttps://www.youtube.com/watch?v=cLzbyoWHbxs

...

Expand
titlekvadratrot.m
Code Block
titlekvadratrot.m
function retur = kvadratrot(tall)
    x = 1;
    er_over_feilgrense = true;
    i = 1;
    while er_over_feilgrense
       ny_x = x + (tall - x^2)/(2*x);
       fprintf('Iterasjon #%d: x_%d = %.10f, x_%d = %.10f\n', i, i-1, x, i, ny_x);
       relativ_endring = abs(ny_x - x)/x;
       er_over_feilgrense = relativ_endring >= 1e-9;
       x = ny_x;
       i = i + 1;
    end
    retur = x;
end 

Videoforklaring (

...

15:

...

46)

Del 1 (mm4:ss00)Del 2 (mm9:ss12)Del 3 (mm2:ss)34)
Widget Connector
urlhttps://www.youtube.com/watch?v=1VBnsEaz-lg
Widget Connector
urlhttps://www.youtube.com/watch?v=lC3Jy8uVECM
Widget Connector
urlhttps://www.youtube.com/watch?v=IE42ZNiVcMc
   

Løsningsforslag

Expand
titleHvis du har prøvd selv, trykk her for å se svaret...
Code Block
titlekvadratrot.m
function retur = kvadratrot(tall)
    x = 1;
    er_over_feilgrense = true;
    i = 1;
    N = 4;
    retur = zeros(1, N);
    retur(1) = x;
    while er_over_feilgrense
       ny_x = x + (tall - x^2)/(2*x);
       relativ_endring = abs(ny_x - x)/x;
       er_over_feilgrense = relativ_endring >= 1e-9;
       x = ny_x;
       i = i + 1;
       if i > N
           N = 2*N;
           retur(N) = 0;
       end
       retur(i) = x;
    end
    retur = retur(1:i);
end 

Oppgave 5.2.4: Tittel

 

Utdelt kode

Videoforklaring (mm:ss)

Løsningsforslag

Expand
titleHvis du har prøvd selv, trykk her for å se svaret...

 

Oppgave 5.2.5: Tittel

 

Utdelt kode

Videoforklaring (mm:ss)

Løsningsforslag

Expand
titleHvis du har prøvd selv, trykk her for å se svaret...

 

Oppgave 5.2.6: Tittel

 

Utdelt kode

Videoforklaring (mm:ss)

Løsningsforslag

Expand
titleHvis du har prøvd selv, trykk her for å se svaret...

 

...