<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <br>
    <font face="Courier New">Stéphane, </font><br>
    <br>
    <blockquote type="cite"
      cite="mid:0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr"><font
        face="Courier New">Yeah, but really badly conditionned compared
        to the above method which is based on orthogonal tranformations
        (X=Q*R factorization). With your below method you solve a linear
        system with X'*X matrix which has a condition number which is
        the square of the condition number of the R matrix issued from
        the Q*R factorization of X.</font></blockquote>
    <br>
    Thanks for the clarification!<br>
    <br>
    Is it posible to predict in what kind of cases will the bad
    conditioning impact on the result? I've compared the results for
    several cases and they are exactly the same. <br>
    <br>
    However, I've noticed that when taking the inverse of a matrix whose
    components span several orders of magnitude there are important
    errors, but if I manage to normalize the poblem the errors are
    substantially reduced<br>
    <br>
    Regards,<br>
    <br>
    Federico<br>
    <br>
    <br>
    <blockquote type="cite"
      cite="mid:0533e578-1226-e6df-a52b-ba6aa5a92bc4@utc.fr">
      <p><font face="Courier New">S.<br>
        </font></p>
      <blockquote type="cite"
        cite="mid:208747ef-5ed7-4d7f-3883-391c60c2a804@fceia.unr.edu.ar"><font
          face="Courier New"> <br>
          The basic algorithm I use is (n = desired degree):<br>
          <br>
          // Initialize matrix X<br>
          X = ones(length(x), n+1);<br>
          // Compute Vandermonde's matrix<br>
          for k =2:n+1<br>
             X(:,k) = X(:,k-1).*x;<br>
          end<br>
          // Apply the Moore-Penrose pseudoinverse matrix and<br>
          // multiply by the dependent data vector to get the<br>
          // least squares approximation of the polynomial<br>
          // coefficients<br>
          A = inv(X'*X)*X'*y;<br>
          <br>
          I've seen some discussion regarding the need for a polyfit
          function in Scilab. The main argument against such a function
          is that it is unnecessary since it is a particular case of the
          backslash division. This is true, but the above example shows
          that users' implementations are not always optimized, and as
          it is such a frequent problem, it would be nice to have a
          native polyfit (or whatever it may be called) function. <br>
          <br>
          Regards,<br>
          <br>
          Federico Miyara<br>
        </font> <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org" moz-do-not-send="true">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users" moz-do-not-send="true">https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users</a>
</pre>
      </blockquote>
      <pre class="moz-signature" cols="72">-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
<a class="moz-txt-link-freetext" href="http://www.utc.fr/~mottelet" moz-do-not-send="true">http://www.utc.fr/~mottelet</a>
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>