Re: Function for complex polynomial with variable number of arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg123542] Re: Function for complex polynomial with variable number of arguments
- From: Christopher Young <cy56 at comcast.net>
- Date: Sat, 10 Dec 2011 07:31:27 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112081021.FAA18802@smc.vnet.net> <4EE0E621.3050600@math.umass.edu>
Thanks, this looks like the way to do it here, since I need to distinguish a possible scaling constant from the roots, and LocatorAutoCreate hands me a list of points. On Dec 8, 2011, at 11:30 AM, Murray Eisenberg wrote: > I presume you want the constant 1 as result in case you have an empty list of points, as the product of an empty list should be 1 in order for the generalized associative rule to hold for multiplication. > > There's an easy solution, obtained by making things simpler: avoid indices entirely and directly use list-manipulation: > > poly[z_, p_] := Times @@ (z - p) > > poly[z, {a + b I, c + d I, c + d I}] > (-a - I b + z) (-c - I d + z)^2 > > poly[z, {a + b I}] > -a - I b + z > > poly[z, {}] > 1 > > If you insist on your original syntax, then change the above to: > > poly2[z_, p___] := Times @@ (z - {p}) Chris Young cy56 at comcast.net
- References:
- Function for complex polynomial with variable number of arguments
- From: Chris Young <cy56@comcast.net>
- Function for complex polynomial with variable number of arguments