• Non ci sono risultati.

ˆ Solution for Ex 1. On the script Esercizio1 write: 1

N/A
N/A
Protected

Academic year: 2021

Condividi "ˆ Solution for Ex 1. On the script Esercizio1 write: 1"

Copied!
2
0
0

Testo completo

(1)

ˆ Solution for Ex 1. On the script Esercizio1 write:

1

clear all

2

close all

3

% the first function

4

f=@ (x) (1+x.^2) ;

5

a=0; b=1;

6

sol=quad(f,0,1); %true solution

7

m = 5;

8

[x,w]= SimpsonComposto(m,a,b) ;

9

S_CS=sum(w.*f(x));

10

disp('Error for Simpson')

11

abs(S_CS

sol)

12

x2 = linspace(0,1,11);

13

m = 10;

14

I=TrapezioComposto(f,a,b,x2,m);

15

disp('Error for trapezio')

16

abs(I

sol)

17 18

% the second function

19

f=@ (x) (1/8+2*x) ;

20

a=0; b=1;

21

sol=quad(f,0,1); %true solution

22

m=5;

23

[x,w]= SimpsonComposto(m,a,b) ;

24

S_CS=sum(w.*f(x));

25

disp('Error for Simpson')

26

abs(S_CS

sol)

27

x2 = linspace(0,1,11);

28

m = 10;

29

I=TrapezioComposto(f,a,b,x2,m);

30

disp('Error for trapezio')

31

abs(I

sol)

1

(2)

ˆ Solution for Ex 2. Write the function 1

function [L, U] = LUnoPiv(A)

2

% LU factorization without pivoting

3

n = size(A,1); % size of A

4

L = eye(n); % initialize

5

for k = 1:n

1

6

for i = k+1:n

7

% multipliers for gaussian elimination

8

L(i,k) = A(i,k)/A(k,k);

9

for j = k:n

10

% construct A

11

A(i,j) = A(i,j)

L(i,k)*A(k,j);

12

end

13

end

14

end

15

U = A;

2

Riferimenti

Documenti correlati

[r]

[r]

[r]

In particolare : (a) un’architettura pipeline senza forwarding e con il register file speciale che scrive un registro nella prima parte del ciclo e legge una coppia di registri

Indeed, when M increases, the uniform and Lipschitz constants of V M 0 deteriorate and we had to assume a bounded Lipschitz continuous kernel in the Mean Field theory, with

Dunque se mettiamo entrambi gli elettroni in uno stato con n > 1 (stati eccitati), questi non sono veri e propri stati legati dell’atomo, perché sono stati autoionizzanti, in

[r]

Disegnare il diagramma degli stati (evidenziando gli stati accettanti) e la tabella delle transizioni che corrispondono all’automa di Moore che riceve in input sequenze di bit (0 e 1)