using System; using System.Collections.Generic; using System.Linq; using System.Text; using L = Science.Mathematics.LinearAlgebra; namespace Strang3Ed.Chapter04.Section3 { public class ExampleA { public ExampleA() { } private string result; public string Result { get { return result; } } public void Compute() { double[,] x = {{1.0, 1.0}, {1.0, 2.0}, {1.0, 3.0}, {1.0, 4.0}, {1.0, 5.0}, {1.0, 6.0}, {1.0, 7.0}, {1.0, 8.0}, {1.0, 9.0}, {1.0, 10.0}}; L.Matrix A = new L.Matrix(x); L.Vector b = new L.Vector(10); b[0] = 0.0; b[1] = 0.0; b[2] = 0.0; b[3] = 0.0; b[4] = 0.0; b[5] = 0.0; b[6] = 0.0; b[7] = 0.0; b[8] = 0.0; b[9] = 40.0; L.LeastSquareApproximation obj = new L.LeastSquareApproximation(A, b); foreach (double k in obj.Solution) result += k.ToString() + "\r\n"; } } } /* -8 2.18181818181818 */