clear;
c = -.99:0.005:.99;
T = 0.01:0.005:1.99;
for l = 1: length( T ),
    for i = 1: length( c ),
    %temp =( ( c( i ) + 1 )/2 )* log( ( c( i ) + 1 ) / 2 ) + ( ( 1 - c( i ) ) / 2 ) * log( ( 1 - c( i ) ) / 2 );
        temp = ( (1 + c( i ) ) / 2 ) * log( (1 + c( i ) ) / 2  ) + ( ( 1 - c( i ) ) / 2 ) *  log( ( 1 - c( i ) ) / 2 );
        S(i , l ) =( 1 - c( i ) ) / 2 - (( 1 - c( i ) ) / 2)^2 + T(l )*temp/2;
    end;
end;
for x = 1:length( T ),
    minValue = 10000;
    for y = 1 : length( c ),
        if S( y , x ) < minValue,
            minValue = S( y , x );
            minC = c( y );
            if y ~=length( T ),
                if S( y+1, x ) > S( y , x ),
                    break;
                end;
            end;
        end;
    end;
    minCS( x ) = minC;
    minCSV( x ) = minValue;
end;
%plot3( T,  minCS , minCSV , T ,   - minCS, minCSV );
%meshc( T , c , S ); 
hold on;
plot3(  T,  minCS , minCSV , 'k-', T ,   - minCS, minCSV , 'k-' );
hold off;
grid on;
xlabel('T');
ylabel('c');
zlabel('F');