Hi, here's some additional homework for you (btw, the straight line fit from the Wikipedia page using GSL is still actual). Extend my lsq-example program to allow k projection lines. It should read the input from a file called "lines" (or if you want you can make it a command line parameter). The file format can be something like this: <...> For example, the example in my original program can be written in this format like this (the comments are not part of the input file, though you can implement that, too, if you want): 2 4 ; two lines and four points on each line 1 5 ; tangent vector of the first line 2 5 7 9 ; distances from the origin for all four points on the first line 3 1 ; tangent vector of the second line 2 6 8 9 ; distances from the origin for all four points on the second line As for the GNUPlot interface, you can output the lines and the solution all in one file like this: ... ... ... So for example the output of the original program would be: 0.392232 1.96116 1.89737 0.632456 1.53034 1.73354 0.980581 4.9029 5.6921 1.89737 4.95523 4.10797 1.37281 6.86406 7.58947 2.52982 6.48557 5.84151 1.76505 8.82523 8.53815 2.84605 6.88652 7.80093 Then the display.plot file should also be written by the program, it should look like this: set size ratio -1 set pointsize 3 plot "output" using 1:2 with linespoints title "Line 1", \ "output" using 3:4 with linespoints title "Line 2" pause mouse replot "output" using 5:6 with linespoints title "Solution" pause mouse These changes should be rather easy, the only difficulty is by changing the commands concerning the matrix. Be sure that you understand the original code before you start to alter it. Have fun, peter