In which norm the approximation has to be done? Euclidean? C-norm? The basis seem to be xn? --Dmitry-kazakov 14:10, 4 June 2008 (MDT)
Any norm could be used. The task is not about mathematics. This task is intended as a subtask. The produced polynoms are used as labels for simple charts, therefore any norm will suffice. You may create a new task if a more formal task statement is desirable. The basis is 1, x, x2, x3, ..., xn. `n' is supposed to be known. -- Geka Sua 08:04, 7 June 2008 (MDT)
It is quickly coded, and while trying to remember things. It works anyway, but I suppose there's a better way. the method I've followed is straightforwardly from Wolfram.com --ShinTakezou 23:58, 18 December 2008 (UTC)
Good work with the Fortran routine. However, the scaling of the independent variable is missing without which the fitting will fail in many cases. For this purpose one needs the mean and standard deviation of the independent variable (vx in the code). Now scale vx to vxcopy and do everything using vxcopy. The code should be changed as follows. I am using this modified version for big applications in my work.
allocate(ipiv(n)) allocate(work(lwork)) allocate(XT(n, size(vx))) allocate(X(size(vx), n)) allocate(XTX(n, n)) vxcopy = vx !=== make a copy of the independent variable mu = stdmean(size(vxcopy), vxcopy) !=== call the function stdmean and get mu(1) - mean, mu(2) - standard deviation vxcopy = (vxcopy - mu(1)) / mu(2) !=== scale the coordinates
! prepare the matrix do i = 0, d do j = 1, size(vx) X(j, i+1) = vxcopy(j)**i !=== do the rest with vxcopy end do end do
--Raghu 12:31, 12 July 2011 (UTC)
Fortran matmul use
I am re working the Fortran example to use in a Delphi project.
The matrix multiply at the end of the example looks to be in the incorrect order.
I believe it should be.
polyfit = matmul( XTX, matmul(XT, vy))
I would appreciate if somebody with the Fortran language available could confirm.