%casa
clear all

z = 0:.01:5/2;
for i = 1:length(z)
    if z(i) <= .5
        f(i) = 1 - 2.1404*(z(i))^3 - 0.8984*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = 0.3465*(3/2-(3/5)*z(i))^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.0449*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)


%19/03/2013
clear all

z = 0:.01:5/2;
n = length(z);
for i = 1:n
    if z(i) <= .5
        f(i) = 1 - 2.4520*(z(i))^2 + 1.0733*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = 1.7910 + 0.9040*z(i) - 5.1641*(z(i))^2 + 3.6161*(z(i))^3 ...
           - 0.7348*(z(i))^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.1981*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)


%20/03/2013
clear all

z = 0:.01:5/2;
for i = 1:length(z)
    if z(i) <= .5
        f(i) = 1 - 0.3973*(z(i))^2 + 0.2710*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = 1.4696 - 0.7611*z(i) - 1.1097*(z(i))^2 + ...
            0.9499*(z(i))^3 - 0.2040*z(i)^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.0685*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)

%20/03/2013 agora
clear all

z = 0:.01:5/2;
for i = 1:length(z)
    if z(i) <= .5
        f(i) = 1 + 0.9056*(z(i))^2 - 0.2845*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = -1.0286 - 0.2290*z(i) + 1.5927*(z(i))^2 - ...
            0.9160*(z(i))^3 + 0.1734*z(i)^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.0312*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)

%__________________________________________________________________________
%20/03/2013 noite
clear all

z = 0:.01:5/2+1;
for i = 1:length(z)
    if z(i) <= .5
        f(i) = 1 - 1.2878*(z(i))^2 + 0.5637*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = 0.9406 + 0.4748*z(i) - 2.7122*(z(i))^2 + ...
            1.8992*(z(i))^3 - 0.3859*(z(i))^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.0065*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)



f = 0.9406 + 0.4748*(3/2) - 2.7122*(3/2)^2 + ...
            1.8992*(3/2)^3 - 0.3859*(3/2)^4;
        
%________________________________________________________________
%o sistema
clear all
clc

A = [0 -4 -1 -16 -8 -4 -2 -1;
     0 -4 -2 0 -4 -4 -3 -2;
     0 -2 -3 0 0 -2 -3 -3;
     0 0 -12 0 0 0 -6 -12;
     -16 0 0 16 24 36 54 81;
     16 0 0 0 4 12 27 54;
     -12 0 0 0 0 2 9 27;
     24 0 0 0 0 0 6 36];
 
 b = [-16; 0; 0; 0; 0; 0; 0; 0];
 
 x = A\b;
 resp = A*x; 

 
 
 %__________________________________________________________________________
%23/03/2013 
clear all

z = 0:.001:5/2;
for i = 1:length(z)
    if z(i) <= .5
        f(i) = 1 - 1.04348*(z(i))^2 + 0.41739*(z(i))^4;
    elseif (z(i) <= 3/2) && (z(i) > .5)
        f(i) = 0.95652 + 0.34783*z(i) - 2.08696*(z(i))^2 + ...
            1.39130*(z(i))^3 - 0.27826*(z(i))^4;
    elseif (z(i) > 3/2) && (z(i) <= 5/2)
        f(i) = 0.06957*(5/2-z(i))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)





clear all

z = -5/2:.001:5/2;
for i = 1:length(z)
    if abs(z(i)) <= .5
        f(i) = 1 - 1.04348*(abs(z(i)))^2 + 0.41739*(abs(z(i)))^4;
    elseif (abs(z(i)) <= 3/2) && (abs(z(i)) > .5)
        f(i) = 0.95652 + 0.34783*abs(z(i)) - 2.08696*(abs(z(i)))^2 + ...
            1.39130*(abs(z(i)))^3 - 0.27826*(abs(z(i)))^4;
    elseif (abs(z(i)) > 3/2) && (abs(z(i)) <= 5/2)
        f(i) = 0.06957*(5/2-abs(z(i)))^4;
    else
        f(i) = 0;
    end
end

plot(z,f)


