Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Using Map with a function of more than 1 argument

  • To: mathgroup at
  • Subject: [mg64255] Re: [mg64241] Using Map with a function of more than 1 argument
  • From: Murray Eisenberg <murray at>
  • Date: Wed, 8 Feb 2006 03:53:47 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <>
  • Reply-to: murray at
  • Sender: owner-wri-mathgroup at

Before spending too much time "rolling your own", you may want to take a 
look at David Park's add-on package Cardano3 (based on his DrawGraphics 
add-on).  See:

You can find a few examples of use of this package also on the Files 
page at

(not all the notebooks there involve Cardano3, and none are evaluated, 
so you'll need Park's package).  See, especially, 
IntroComplexGraphics.nb, VisualizeFunctions.nb, RiemannSphere.nb, 
ExponentialLogFunctions.nb, Poles.nb.

Matt wrote:
> Hello Mathematica group,
>   I'm starting down the path of trying to come up with my own complex
> mapping function.  I'm aware of CartesianMap and PolarMap, but I've
> been frustrated by those because of the lack of fine control I seem to
> have (I say 'seem to have' because it might very well be the case that
> I'm not aware of some of the finer points of these two functions).  The
> fine control that is lacking, is for example, the fact that within
> CartesianMap, if I want to specify different colors for the lines, I
> can't really.  Let's say I went with the default of $Lines which is I
> believe 25.  In order to have the lines draw in 25 different colours, I
> believe I'd have to supply 25 color primitives to PlotStyle.  If I
> supply less than 25, then the color primitives are recycled.  My first
> plan of attack was to take the Graphics object that is output by
> CartesianMap and try to manipulate the coloring primitive for each line
> drawn based upon starting and ending points (i.e. within a 'Line', if
> the first point's x value and the last point's x value were 'close',
> than I knew I was dealing with a vertical line, or if the first point's
> y value and the last points y value were 'close', then I knew I was
> dealing with a horizontal line).  So, given the Graphics object output
> by
> graphicOne = CartesianMap[#1 & , {-1, 1}, {-1, 1}, Lines -> theLines,
>     ImageSize -> {500, Automatic}, PlotStyle -> {RGBColor[1, 0, 0],
> RGBColor[0, 0, 1]},
>     PlotPoints -> thePlotPoints];
> I was hoping that invoking something like
> Position[graphicOne, ({RGBColor[__], {Line[_]}})?
>    ((Print[Abs[First[#1[[2,1]]][[1,1]] - Last[#1[[2,1]]][[1,1]]]];
>      Abs[First[#1[[2,1]]][[1,1]] - Last[#1[[2,1]]][[1,1]]] < 1.*^-9) &
> )]
> would give me the positions of all of the horizontal lines, but then,
> it seems that my lack of familiarity with Mathematica's rules for
> working with accuracy and precision, led to results that made no sense
> (i.e. it returned every Line as a match, instead of just the ones where
> the x-coordinates were 'close').  Even worse than that, I realized that
> my attempt was doomed to failure because even if I could get that
> approach to work for a rectangular domain, it would not work once I had
> applied a function that resulted in a graphic where the lines were
> curved, twisted and traveling back over themselves.  It was at this
> point that I decided to just work with single lines (i.e. graph a
> single curve, then operate on each of the points contained within the
> 'Line' object and then graph the result in another graphic).
> So, as a first step towards my goal, I thought, "OK, I need to write a
> function that will be able to be used with Map on a list of points and
> return the 'transformed' points as well as accept an arbitrary function
> that will operate on each of the points."
> Here is what I have thus far:
> Clear[f, g];
> f[z_, func_] := Module[{result}, result = func[Complex[Sequence @@ z]];
> {Re[result], Im[result]}];
> g[z_] := f[z, #1^2 & ];
> Which, using 'g', I can use Map on a list of ordered pairs:
> g /@ {{x,y}, {x,y}, {x,y}, {x,y}, etc.}
> If I wanted to use Sin, I would redefine g as follows:
> g[z_] := f[z, Sin];
> then reapply to the list of ordered pairs.  So, I'm wondering if
> there's a way to accomplish my task without the intermediary function
> definition 'g'?  Also, if what I'm attempting is totally wrong, I'd
> appreciate any pointers as to the correct 'path' as well.
> Thanks,
> Matt

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Solve problems
  • Next by Date: Poisson equation
  • Previous by thread: Using Map with a function of more than 1 argument
  • Next by thread: Re: Using Map with a function of more than 1 argument