KKKA10 2012 tenta Carmen Arevalo

Contents

close all

Uppgift 1

The method is the trapezoidal rule (note the factor 2 in the formula)

type qmetod.m
f=@(t)1./(1+t.^2).^2;
format long
I=qmetod(f,0,1,100)
% Comparison with Simpson with small tolerance
S=quad(f,0,1,1e-15)
function I=qmetod(f,a,b,stegtal)
% tenta KKKA10 2012-5-23
x=a;
h=(b-a)/stegtal;
s=f(a);
for j = 1:stegtal-1
x = x+h;
s = s+2*f(x);
end
s = s+f(b);
I = h*s/2;
I =
   0.642694915052892
S =
   0.642699081698724

Solution: 0.6427

Uppgift 2

format short
mass=[0.16;0.3;2;45;70;400];
met=[0.97;1.45;4.8;50;82;270];
figure
plot(mass,met,'o')
xlabel('mass')
ylabel('metabolism')

With basic fitting I see a quadratic polynomial fits best

The coefficients of $ax^2+bx+c$ are:

p=polyfit(mass,met,2)
p =
   -0.0014    1.2212    1.0518
mx=linspace(0.16,400);
my=polyval(p,mx);
plot(mass,met,'o',mx,my)
legend('data points','met(mass)','Location','best')

Uppgift 3

m=2;n=1;alfa=2;beta=0.27;delta=0.25;RQ=1.5;
A=[0 0 1 0 1;
    0 3 -alfa -2 0;
    2 0 -beta -1 -2;
    0 1 -delta 0 0;
    RQ 0 0 0 -1];
b=[1;-m;-n;0;0];

The constants, ordered a, b, c, d, e, are

constants=A\b
constants =
    0.2316
    0.1631
    0.6525
    0.5922
    0.3475