Dan Bron wrote:
> Given two polynomials, what is the simplest (most succinct) J phrase which
> gives their intersection?


The examples already given are probably the best way to do it for 2
polynomials.  If you want the common intersection of several, here is a
non-succinct method.

You can test whether f0,f1,... are all equal by
forming the sum of (fi-fj)^2 and setting it to zero.


ppr  =: +//.@(*/)  NB. polynomial product
pdiff=: -/@,:      NB. polynomial difference
pps   =: ppr~      NB. polynomial square


comb=: 4 : 0
 k=. i.>:d=.y-x
 z=. (d$<i.0 0),<i.1 0
 for. i.x do. z=. k ,.&.> ,&.>/\. >:&.> z end.
 ; z
)

NB. g <list of boxes of coefficients>
NB. returns x-coordinates of common intersection points
g=:3 : 0
a=.>y
c=.2 comb #a
~. (#~ (= +)) 1{:: p. +/ [EMAIL PROTECTED] /"2  c { a
)


a=:0 0 1
b=:2 0 _1
c=:1


   ]r=:g a;b;c
1 _1
   a p. r
1 1
   b p. r
1 1
   c p. r
1 1

Best wishes,

John


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to