Author Topic: Horner scheme  (Read 5869 times)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Horner scheme
« on: March 19, 2013, 11:58:22 AM »
I am playing with two new macros that use a variant of the Horner scheme:
                SetPoly3 My3Pts()                ; use three XY pairs to get a0...a2
                GetPoly3(AllPts())                ; fill an array using y=a0+a1*(x-x0)+a2*(x-x0)*(x-x1)

Work in progress. In the attached executable, the two outer points are fixed, the middle one moves with the mouse.

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Horner scheme
« Reply #1 on: March 19, 2013, 01:52:09 PM »
very cool   :t
i remember, long ago, i needed something like this
now, i can't remember what it was for - lol
that was back in the DOS days

it seems to hang up under certain conditions - hard to describe
i am sure you are aware of it - as you say, work in progress

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Horner scheme
« Reply #2 on: March 19, 2013, 06:28:37 PM »
it seems to hang up under certain conditions - hard to describe

Usually you can unblock it by moving around the lower right corner.

Here is a variant that uses the three red points to define the bounding rectangle. The only difference is that now the other points can go outside the rect.

if 1        ; optional: use the "biggest" array to define a common range
        ArrayPlot My3Pts(XY), 0, 0, MyMargins, SetRange        ; the three red points define the range
else
        ArrayPlot AllPts(XY), 0, 0, MyMargins, SetRange        ; the big array defines the range
endif

dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Horner scheme
« Reply #3 on: March 19, 2013, 11:53:00 PM »
Seeing your code would be nice indeed ;-)

it is an assembler forum, afterall   :P

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Horner scheme
« Reply #4 on: March 22, 2013, 12:56:02 PM »
I somehow like the idea and looked up for an robust algorithm for getting polynomials through arbitrary points and found the method of divided differences (similar: hermite interpolation ).
An C implementation can be found here (functions: data_to_dif  and dif_val).

In the attachment a example (sry, no source): with the left mouse button you can add and drag points, which are used for interpolation. With the right mouse button selected points are removed.

qWord
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Horner scheme
« Reply #5 on: March 22, 2013, 05:28:48 PM »
method of divided differences (similar: hermite interpolation )

Nice link :t
Reference:
    Carl deBoor,
    A Practical Guide to Splines,
    Springer, 2001

The reference for my macros is Dubbel, Taschenbuch für den Maschinenbau, Springer 19xx (can't find the book right now, but it must be before 1981).
If I find time over the weekend, I'll post a new edition of MasmBasic with the sources.

EDIT: Sources are online, see here
« Last Edit: March 24, 2013, 11:39:09 AM by jj2007 »