[racket-users] Interpolating Polynomial in Newton Form

2015-11-06 Thread dyrueta
Hi All -- I'm hoping the answer to the question below will serve as an intro to macros, a subject I've been interested in for awhile but haven't had time to look into much. Here goes, fingers crossed: Given a list of constants (a0, a1… an) and a list of x-values (x0, x1,….xn), I want to desig

[racket-users] Interpolating Polynomial in Newton Form

2015-11-10 Thread Dave Yrueta
Hi All — Given a list of constants (a0, a1… an) and a list of x-values (x0, x1,….xn), I want to write a function in Racket that produces the function p(x) = a0 + a1(x - x0) + a2(x - x0)(x - x1) + a3(x - x0)(x - x1) (x - x2) + ….+ an(x - x0)(x - x1)…(x - xn), or the interpolating polynomial in N

Re: [racket-users] Interpolating Polynomial in Newton Form

2015-11-06 Thread Matthias Felleisen
> On Nov 6, 2015, at 9:07 PM, dyrueta wrote: > > Hi All -- > > I'm hoping the answer to the question below will serve as an intro to macros, > a subject I've been interested in for awhile but haven't had time to look > into much. Here goes, fingers crossed: > > Given a list of constants (a0

Re: [racket-users] Interpolating Polynomial in Newton Form

2015-11-07 Thread Dave Yrueta
Yes, I can see at least two significant errors in my description. The first is in the sequence definitions. They should be list of constants (a0, a1… an) and a list of x-values (x0, x1,….x(n-1)) Similarly, the def of p(x) should read p(x) = a0 + a1(x - x0) + a2(x - x0)(x - x1) + a3(x - x0)(x

Re: [racket-users] Interpolating Polynomial in Newton Form

2015-11-07 Thread Matthias Felleisen
#lang racket ;; - ;; the macro approach (module macro-server racket (provide ;; syntax: (make-p number? (number? ...) (number? ...)) ;; in (make-p a0 (a ...) (x ...)) must be of equal length ;; the result i

Re: [racket-users] Interpolating Polynomial in Newton Form

2015-11-10 Thread Jens Axel Søgaard
Use Horner's rule. /Jens Axel 2015-11-06 22:27 GMT+01:00 Dave Yrueta : > Hi All — > > Given a list of constants (a0, a1… an) and a list of x-values (x0, > x1,….xn), I want to write a function in Racket that produces the function > p(x) = a0 + a1(x - x0) + a2(x - x0)(x - x1) + a3(x - x0)(x - x1)