Suppose I make the following function to plot contour lines for a complex function:
ContourRe[Func_, xrange_, yrange_, Nlines_: 30, size_: 400] := ContourPlot[Re[Func[x + I*y]],
{x, xrange[[1]], xrange[[2]]}, {y, yrange[[1]], yrange[[2]]},
ContourShading -> False, Contours -> Nlines, ContourStyle -> Red, ImageSize -> size]
How can I generalize it so that the input function Func
can have additional parameters?
For example I have:
F1[z_]:=Exp[z]+3*I
F2[z_,a_:-2]:=a*Exp[z]
How should I modify ContourRe
so that it can take both F1
and F2
as arguments and plot them?
It is like in python in which many of the built-in scipy functions have args={}
for us to specify any parameters associated with the input function. In mathematica there are things like OptionsPattern
and OptionValue
, but after looking at the documentations I don't really know how to use them in this specific example.