How to resolve the algorithm Polynomial regression step by step in the HicEst programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Polynomial regression step by step in the HicEst programming language

Table of Contents

Problem Statement

Find an approximating polynomial of known degree for a given data. Example: For input data: The approximating polynomial is: Here, the polynomial's coefficients are (3, 2, 1). This task is intended as a subtask for Measure relative performance of sorting algorithms implementations.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Polynomial regression step by step in the HicEst programming language

Source code in the hicest programming language

REAL :: n=10, x(n), y(n), m=3, p(m)

   x = (0,  1,  2,  3,  4,  5,  6,   7,   8,   9,   10)
   y = (1,  6,  17, 34, 57, 86, 121, 162, 209, 262, 321)

   p = 2 ! initial guess for the polynom's coefficients

   SOLVE(NUL=Theory()-y(nr), Unknown=p, DataIdx=nr, Iters=iterations)

   WRITE(ClipBoard, Name) p, iterations

FUNCTION Theory()
   ! called by the solver of the SOLVE function. All variables are global
   Theory = p(1)*x(nr)^2 + p(2)*x(nr) + p(3)
 END

  

You may also check:How to resolve the algorithm First-class functions/Use numbers analogously step by step in the Elena programming language
You may also check:How to resolve the algorithm Josephus problem step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Fork step by step in the Java programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the EchoLisp programming language
You may also check:How to resolve the algorithm 100 doors step by step in the TI-89 BASIC programming language