Problhma 1: pseudoinverse, basis and more...

Mas dinetai o plh8usmos twn HPA (se ekatomuria) gia ta xronia 1900 mexri 1970.  Exoume  dhladh ta zeugh  {(Subscript[x, i]),  (Subscript[y, i])}, i = 1, ..., 8 opou (Subscript[x, i]) einai to etos kai (Subscript[y, i]) o plh8usmos gia to etos (Subscript[x, i]).  8eloume na broume ena poluwnumo 2ou ba8mou, dhladh f(x)= (Subscript[c, 1]) + (Subscript[c, 2]) x + (Subscript[c, 3]) (x^2), etsi wste h timh f((Subscript[x, i])) na proseggizei thn timh (Subscript[y, i]).

x = years = {1900, 1910, 1920, 1930, 1940, 1950, 1960, 
            1970};
y = population = {75.99, 91.97, 105.71, 122.75, 131.67, 150.69, 
            179.32, 203.21};

Lush me Grammikh Algebra:

Psaxnoume dhladh na broume to dianusma c = {(Subscript[c, 1]),  (Subscript[c, 2]),  (Subscript[c, 3])}.  Gia ka8e xrono, oi suntelestes twn {(Subscript[c, 1]),  (Subscript[c, 2]),  (Subscript[c, 3])} einai {1, etos, (etos^2)}, opote prokuptei o pinakas A:

A=(({{1, 1900, 3610000}, {1, 1910, 3648100}, {1, 1920, 3686400}, {1, 1930, 3724900}, {1, 1940, 3763600}, {1, 1950, 3802500}, {1, 1960, 3841600}, {1, 1970, 3880900}}));

To systhma pou 8eloume na lusoume einai A c = y.

1on:  Kanete svd analush tou pinaka A.  Poses kai poies einai oi times stretchers.  Einai o pinakas A plhrous ta3ews?  Mia timh tou stretcher einai parea polu mikrh!  Auto sumainei oti o pinakas A einai ill-conditioned!!  Perissotera ep' autou sto 2o problhma.

Ypologiste ton pseudoAntistrofo tou A.  Syggrinete thn apanthsh sas me to apotelesma ths sunarthshs PseudoInverse[A].

2on:  Ypologiste me 2 tropous pou brisketai to y.  Dhladh einai to y ston upoxwro twn sthlwn tou A h oxi?  Zwgrafiste tous upoxwrous (osous uparxoun) twn (R^3) kai (R^8) kai dei3te pou brisketai to y.  Ypologiste mia bash gia olous tous upoxwrous.  Idiaitera gia to Nullspace tou pinaka (A^T)upologiste mia bash kai sugkrinete thn (ws pros thn or8okanonikothta) me thn bash pou prokuptei apo to NullSpace[Transpose[A]]

3on:  Brhte (me 2 tropous) thn proseggistikh lush tou susthmatos kai grapste poio susthma lunetai me authn thn lush.

Lush me Calculus (prosferetai dwrean gia sugkrish apotelesmatwn):

points = Transpose[{years, population}]

plotpoints = 
        ListPlot[points, PlotStyle -> PointSize[0.02], 
          AxesOrigin -> {1900, 70}];

poly = Fit[points, {1, x, x^2}, x]

Oi suntelestes pou brhkame twra einai idioi me ekeinous pou brhkame lunontas susthma grammikwn e3iswsewn.

c

H grafikh parastash tou poluwnumou einai:

plotline = 
        Plot[poly, {x, 1900, 1970}, AspectRatio -> 1];

H grafikh parastash tou poluwnumou mazi me ta shmeia einai:

Show[plotpoints, plotline];

Problhma 2: ill-conditioned system!

Dinetai o pinakas A kai to antistoixo grammiko susthma A.X ==  Y, opou X = {(Subscript[x, 1]), (Subscript[x, 2]), (Subscript[x, 3])} kai Y = {(Subscript[y, 1]), (Subscript[y, 2]), (Subscript[y, 3])}:

Clear[x, y, k];

A=(({{-0.1716, 2.9474, 1.4518}, {-2.0640, 1.8970, -2.1660}, {-1.4421, -1.2106, -2.9971}}));

X = Table[(Subscript[x, k]), {k, 1, 3}];
Y = Table[(Subscript[y, k]), {k, 1, 3}];

linearsystem  =  
      ColumnForm[Thread[A . X  ==   Y]]

Prose3te oti o pinakas A einai full rank dioti uparxoun 3 mh mhdenikoi stretchers.  O enas omws einai polu mikros, pou shmainei oti o pinakas A einai ill-conditioned.  Ara 8a doume para3ena pragmata....

{h, s, a} = 
        SingularValues[A]; 

s

Gia to dianusma Y (de3i meros) kanoume 3 diaforetikes metrhseis kai briskoume ta e3hs 3 dianusmata:

Y1 = {-3.1071, 7.4542, 8.5967}
Y2 = {-3.1076, 7.4545, 8.5960}
Y3 = {-3.1077, 7.4522, 8.5967}

Epeidh oi times twn 3 dianusmatwn einai peripou oi idies ta antika8istoume me ena sto opoio exoume stogguleusei tous ari8mous (logiko, etsi?):

roundedY = {-3.11, 7.45, 8.60}

Epeidh o pinakas einai full-rank upaxei mia akribws lush tou susthmatos pou upologizetai apo ton tupo:

Xsol = Inverse[A] . roundedY

h kai pio analutika apo ton tupo

Xsol = (∑_(i = 1)^3)(((roundedY . h[[i]]))/s)[[i]] 
          a[[i]]

PROSOXH!!  Ypologizontas OMWS tis luseis pou prokuptoun apo ta 3 dianusmata exoume entelws diaforetika apotelesmata:

Xsol1 = Inverse[A] . Y1

Xsol2 = Inverse[A] . Y2

Xsol3 = Inverse[A] . Y3

1on:  E3hghste to parapanw fainomeno tou ill-conditioned pinaka A me thn boh8eia tou tupou \(\(\(
\)\(
\)\(Xsol = ∑\+\(i = 1\)\%3\(\((roundedY . h[\([i]\)])\)\/s[\([i]\)]\) a[\([i]\)]\)\)\)

2on:  Metatrepste ton ponaka A se enan well-conditioned pinaka me thn texnikh pou xrhshmopoihsame gia thn sumpiesh twn eikonwn.  Brhte mia logikh lush tou problhmatos.