From: Leeoswald
Subject: Lambda expression
Date: 
Message-ID: <84cta9$kr3$1@nnrp1.deja.com>
I need to do a program that get a lambda expression from a polynomial
function and than transform the lambda expression to a simplified
polynomial form
For ex.

(defun F (X) (+ (* C1 (expt X P1)) (* C2 (expt X P2)) ... (* Cn (expt X
Pn))))

I get the following lambda expression:

(lambda (X) (+ (* C1 (expt X P1)) (* C2 (expt X P2)) ... (* Cn (expt X
Pn))))

than

if C1, C2, Cn.. is 1 I need to remove it from the lambda expression.
if P1, p2, pn = 0, I need to remove X where P is 0
if p1, p2, pn = 1, I need to remove the P where it is equal 1

For ex again

(lambda (1) ( + (* 1 (expt 1 2)) (* 2 (expt 1 1)))

must be transformed in :

(lambda (1) ( + (expt 1 2) (* 2 (expt 1)))


HELP!!!!!!!!


Sent via Deja.com http://www.deja.com/
Before you buy.

From: Barry Margolin
Subject: Re: Lambda expression
Date: 
Message-ID: <mQua4.43$i25.708@burlma1-snr2>
In article <············@nnrp1.deja.com>,
Leeoswald  <·······@bestway.com.br> wrote:
>I need to do a program that get a lambda expression from a polynomial
>function and than transform the lambda expression to a simplified
>polynomial form
...
>HELP!!!!!!!!

If you don't ask a more specific question, I don't see how we can help
you.  You won't learn anything by having us write it for you.

I'll give you a hint: recursion

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Janos Blazi
Subject: Re: Lambda expression
Date: 
Message-ID: <bimetallic-84g6v0/INN-2.2.1/brett@broadway.news.is-europe.net>
You are right, dad! It is in the boy's own best interest...
Janos Blazi

Barry Margolin <······@bbnplanet.com> schrieb in im Newsbeitrag:
················@burlma1-snr2...
> In article <············@nnrp1.deja.com>,
> Leeoswald  <·······@bestway.com.br> wrote:
> >I need to do a program that get a lambda expression from a polynomial
> >function and than transform the lambda expression to a simplified
> >polynomial form
> ...
> >HELP!!!!!!!!
>
> If you don't ask a more specific question, I don't see how we can help
> you.  You won't learn anything by having us write it for you.
>
> I'll give you a hint: recursion
>
> --
> Barry Margolin, ······@bbnplanet.com
> GTE Internetworking, Powered by BBN, Burlington, MA
> *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to
newsgroups.
> Please DON'T copy followups to me -- I'll assume it wasn't posted to the
group.
From: Leeoswald
Subject: Re: Lambda expression
Date: 
Message-ID: <84iqnh$m6c$1@nnrp1.deja.com>
Hey, did I ask to anybody write the complete program for me??
I just asked help.
Anyway I would like to thank all the people who sent me e-mails
with a lof of help! By the Way, any suggestion is still welcome.
Thanks people, you are the best!
Daniel





In article <·································@broadway.news.is-
europe.net>,
  "Janos Blazi" <······@netsurf.de> wrote:
> You are right, dad! It is in the boy's own best interest...
> Janos Blazi
>
> Barry Margolin <······@bbnplanet.com> schrieb in im Newsbeitrag:
> ················@burlma1-snr2...
> > In article <············@nnrp1.deja.com>,
> > Leeoswald  <·······@bestway.com.br> wrote:
> > >I need to do a program that get a lambda expression from a
polynomial
> > >function and than transform the lambda expression to a simplified
> > >polynomial form
> > ...
> > >HELP!!!!!!!!
> >
> > If you don't ask a more specific question, I don't see how we can
help
> > you.  You won't learn anything by having us write it for you.
> >
> > I'll give you a hint: recursion
> >
> > --
> > Barry Margolin, ······@bbnplanet.com
> > GTE Internetworking, Powered by BBN, Burlington, MA
> > *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to
> newsgroups.
> > Please DON'T copy followups to me -- I'll assume it wasn't posted
to the
> group.
>
>

--
---// My job is shoot presidents //---


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Barry Margolin
Subject: Re: Lambda expression
Date: 
Message-ID: <sebb4.23$NC6.597@burlma1-snr2>
In article <············@nnrp1.deja.com>,
Leeoswald  <·······@bestway.com.br> wrote:
>Hey, did I ask to anybody write the complete program for me??
>I just asked help.

The non-specific way you asked for help made it seem like you wanted the
program.

Like I said, if you want help, you should ask specific questions.  Or you
could post the code you've written so far and ask for suggestions to fix
the problems.

But when you just describe the problem and say "help", it seems like you're
looking for someone to do the problem for you.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Johan Kullstam
Subject: Re: Lambda expression
Date: 
Message-ID: <m27lhv9kkb.fsf@sophia.axel.nom>
Leeoswald <·······@bestway.com.br> writes:

> I need to do a program that get a lambda expression from a polynomial
> function and than transform the lambda expression to a simplified
> polynomial form
> For ex.
> 
> (defun F (X) (+ (* C1 (expt X P1)) (* C2 (expt X P2)) ... (* Cn (expt X
> Pn))))
> 
> I get the following lambda expression:
> 
> (lambda (X) (+ (* C1 (expt X P1)) (* C2 (expt X P2)) ... (* Cn (expt X
> Pn))))
> 
> than
> 
> if C1, C2, Cn.. is 1 I need to remove it from the lambda expression.
> if P1, p2, pn = 0, I need to remove X where P is 0
> if p1, p2, pn = 1, I need to remove the P where it is equal 1
> 
> For ex again
> 
> (lambda (1) ( + (* 1 (expt 1 2)) (* 2 (expt 1 1)))
> 
> must be transformed in :
> 
> (lambda (1) ( + (expt 1 2) (* 2 (expt 1)))
> 
> 
> HELP!!!!!!!!

this may be tangential to your problem but i think horner's schema
would be a better way to represent/compute your polynomial.

in standard math notation
 4x^3+3x^2+2x+1 = ((4x+3)x+2)x+1

in lisp

(lambda (x)
  (+ (* (+ (* (+ (* 4 x) 3) x) 2) x) 1))

you can reverse the order if it makes it easier to see/use

(lambda (x)
  (+ 1 (* x (+ 2 (* x (+ 3 (* x 4)))))))

distill the coefficients into a list, e.g.,

(1 2 3 4)

and create functions to go back and forth and evaluate it.  i think i
like this second form best but ymmv.

1) for representation this gives a canonical format.  any polynomial
   can be mapped to this form and testing for equality &c is easy
   since the rich supply of lisp list functions can help you.

2) for computation this avoids the expt and uses a minimum number of
   multiplies and adds.

hope this helps.

-- 
J o h a n  K u l l s t a m
[········@ne.mediaone.net]
Don't Fear the Penguin!