Tag Info

Hot answers tagged

46

Building on Heike's ColorFunction, I came up with this: z = Transpose@Reverse@Sin@ Outer[Complex, Range[-Pi, Pi, 0.01], Range[-Pi, Pi, 0.01]]; hsbdata = Transpose[{ Rescale[Arg[z], {-Pi, Pi}], 1 - 0.05/Abs[Sin[2 Pi Abs[z]]], 0.02/Abs[Sin[2 Pi Abs[z]]] + Abs[Sin[2 Pi Im@z] Sin[2 Pi Re@z]]^0.25} , {3, 1, 2}]; Image[hsbdata, ColorSpace -> "HSB"] ...


38

In general, a typical root of a negative number is complex, so you need to get rid of most roots. A nice approach would be Root, e.g. Root[ x^3 + 8, #] & /@ Range[3] {-2, 1 - I Sqrt[3], 1 + I Sqrt[3]} To get only real roots you can do : Select[Root[ x^3 + 8, #] & /@ Range[3], Re[#] == # &] {-2} This is a handy approach when you ...


21

Well, you have to treat the real and imaginary parts separately. You can't really have a complex $z$ value in these plots. Here's one way to visualize complex sine: Table[Plot3D[f[Sin[x + I y]], {x, -1, 1}, {y, -1, 1}, PlotLabel -> TraditionalForm[f[Sin[z]]], RegionFunction -> Function[{x, y, z}, x^2 + y^2 < 1]], {f, {Re, Im, Abs}}] // ...


21

You can plot in 3 dimensions only real and/or imaginary parts of a function. One can make use of Plot3D, but since there was a question how the sine function looks like on the unit circle, first I demonstrate usage of ParametricPlot3D and later I'll show a few of many possible uses of Plot3D. When we'd like to use ParametricPlot3D, then instead of ...


21

Not as pretty as the one in the original post, but it's getting in the right direction I think: RegionPlot[True, {x, -Pi, Pi}, {y, -Pi, Pi}, ColorFunction -> (Hue[Rescale[Arg[Sin[#1 + I #2]], {-Pi, Pi}], Sin[2 Pi Abs[Sin[#1 + I #2]]]^2, Abs@(Sin[Pi Re[Sin[#1 + I #2]]] Sin[Pi Im[Sin[#1 + I #2]]])^(1/ 4), 1] &), ...


16

You may use a function, which gives you the "real Power": rprule=(b_?Negative)^Rational[m_,n_?OddQ]:>(-(-b)^(1/n))^m; Attributes[realPower]={Listable, NumericFunction,OneIdentity} (* same as Power *) realPower[b_?Negative, Rational[m_, n_?OddQ]] := (-(-b)^(1/n))^m; realPower[x_,y_]:=Power[x,y]; realPower[x_]:=x//.rprule; Then you'll get: ...


16

Here's a view that shows how the graph starts to spiral for negative $x$ values, if we take the complex values into account. ParametricPlot3D[{x, Re[Exp[x*Log[x]]], Im[Exp[x*Log[x]]]}, {x, -4, 2}, PlotRange -> All, ViewVertical -> {0, 1, 0}, BoxRatios -> {2, 1, 1}, ViewPoint -> {2, 2, 12}] In fact, if we write $x^x = e^{x\log(x)}$, this ...


14

Here are two suggestions for the function f[z_] := 1/z; First, instead of defining a region to omit from your plot, you should base the omission criterion on the length of the vectors (so that you don't have to adjust the criterion manually when switching to a function with different pole locations). That can be achieved like this: With[{maximumModulus = ...


14

The functions Re and Im (just as Conjugate) don't satisfy the Cauchy-Riemann differential equations and are therefore not analytic. That means their derivative is not uniquely defined in the complex plane. That's the reason why Re' and Im' can't be simplified. Therefore, we have to be more specific about how we want the limit to be done that corresponds to ...


14

Defining the function F and a subset of its domain : pts : F[z_] := (5 - I z)/(5^2 + z^2) pts = {-7, -2, 0, 2, 7}; the most straightforward way fulfilling the task is based on ParametricPlot and Epilog. We can also make a diagram with the basic graphics primitives like e.g. : Line, Circle, Point. Here are the both ways enclosed in GraphicsRow : ...


14

What is wrong: a) you're using exact arithmetic. b) You keep iterating even if the point seems to be escaping. Try this ClearAll@prodOrb; prodOrb[c_, maxIters_: 100, escapeRadius_: 1] := NestWhileList[#^2 + c &, 0., Abs[#] < escapeRadius &, 1, maxIters ] prodOrb[0. + 10. I] prodOrb[0. + .1 I] (if you don't need the entire list but ...


13

For Integrate as well as for Simplify, Refine FunctionExpand, Limit etc. there is an option Assumptions: Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}, Assumptions -> (u | l) ∈ Reals] ConditionalExpression[ 2 ArcSinh[ l/Abs[ u]], u != 0 && l >= 0] or one can use Assuming[ (u | l) ∈ Reals, Integrate[ 1/Sqrt[ z^2 + u^2], {z, -l, l}]] the ...


13

This is a good way : DensityPlot[ Rescale[ Arg[Sin[-x - I y]], {-Pi, Pi}], {x, -Pi, Pi}, {y, -Pi, Pi}, MeshFunctions -> Function @@@ {{{x, y, z}, Re[Sin[x + I y]]}, {{x, y, z}, Im[Sin[x + I y]]}, {{x, y, z}, Abs[Sin[x + I y]]}}, MeshStyle ...


13

This explicitly converts any numeric quantities in the expression to the desired form: polarForm = Expand[# /. z_?NumericQ :> Abs[z] Exp[I Arg[z]]] &; e.g. (1/4 + I/4) ((1 - 2 I) x + Sqrt[3] y) // polarForm $\frac{1}{2} \sqrt{\frac{5}{2}} e^{\frac{i \pi }{4}-i \text{ArcTan}[2]} x+\frac{1}{2} \sqrt{\frac{3}{2}} e^{\frac{i \pi }{4}} y$ ...


13

The plot is correct: the dashed line lies outside the domain of definition of the function. Let's first clean up the syntax. Capitalized names are reserved and you ought to delay evaluation using := instead of =. It's also a good idea to make a, b, and c local: g[x_, y_] := With[{a = Sqrt[x^2 - (1 - 1/y^2) y^2], b = Sqrt[x^2 - 2 y^2], c = Sqrt[x^2 - ...


12

You can modify the global system variable $Assumptions, to get the effect you want: $Assumptions = aa[t] > 0 Then Integrate[D[yy[x, t], t]^2, {x, 0, 18}] 10.1601 Derivative[1][aa][t]^2 This may, however, be somewhat error-prone. Here is how I'd do this with local environments. This is a generator for a local environment: ...


12

In general, to get a list of all the cube roots of -8 (or the $m$ roots of any number $n$), you can use either the the Roots or Solve or Reduce functions. Roots[x^3 == -8, x] (* Out[1]= x == 2 || x == 2 (-1)^(2/3) || x == -2 (-1)^(1/3) *) Reduce and Solve are perhaps more flexible because you can specify the domain that you want or leave it out for all ...


12

I already mentioned Bernd Thaller's package Graphics`ComplexPlot` in the comments; if one blends the ideas from Artes's and Heike's answers, and then use the function $ComplexToColorMap[] from Thaller's package (I won't include it here; again, see the package for that), we get this: Needs["Graphics`ComplexPlot`"] (* Thaller's package; get it yourself *) ...


12

As yulinyu has pointed out, something like the following will give you the desired plot. Plot[Through[{Re, Im}[x^x]], {x, -2, 2}, Evaluated -> True] You might also be interested in this excellent answer by Simon Woods to create a graph of the plot over the complex domain. Using his function and evaluating the following gives you a pretty picture ...


11

Use ContourPlot for equalities: ContourPlot[ Evaluate[z + Conjugate[z] == Abs[z]^2 /. z -> x + I y], {x, -2, 2}, {y, -2, 2}, FrameLabel -> Automatic ]


11

The following function gives the complete information for a function $f:\mathbb{C}\mapsto\mathbb{C}$, by giving the absolute value as $z$-coordinate, and the argument as colour: ComplexFnPlot[f_, range_, options___] := Block[{rangerealvar, rangeimagvar,g}, g[r_,i_]:=(f/.range[[1]]:>r+I i); Plot3D[Abs[g[rangerealvar,rangeimagvar]], ...


11

The way you could use ContourPlot here, assuming your variable f is complex (f == x + I y) : eqn[x_, y_] := (25 Pi ( x + I y) I)/(1 + 10 Pi ( x + I y) I) {ContourPlot[Re@eqn[x, y], {x, -1, 1}, {y, -1, 1}, PlotPoints -> 50], ContourPlot[Im@eqn[x, y], {x, -1, 1}, {y, -1, 1}, PlotRange -> {-0.5, 0.5}, PlotPoints -> 50]} These are respectively ...


11

Let's find out. Here is a function to compare the results of evaluating f on a machine approximation of an exact argument z to its exact value: test[f_] := Function[{z}, f[N[z]] - f[z]]; We expect to find problems around the 52nd significant binary digit or so. Let's magnify these differences, then, by about $2^{60}$ and use logarithmic axes to study ...


11

Specify the display format of something using MakeBoxes, like so: MakeBoxes[polarForm[z_Complex], form_] := With[{r = Abs[z], ϕ = Arg[z]}, RowBox[{If[r == 1, Sequence @@ {}, MakeBoxes[r, form]], If[ϕ == 0, Sequence @@ {}, SuperscriptBox[MakeBoxes[E, form], RowBox[{MakeBoxes["\[ImaginaryI]", form], If[ϕ == 1, Sequence @@ {}, ...


11

ImageForwardTransformation[] is the function you want here. To give a concrete example, here's how an image might be transformed by the complex mapping $w=z^3$: img = ExampleData[{"TestImage", "Mandrill"}]; imgc = ImageForwardTransformation[img, Through[{Re, Im}[(#[[1]] + I #[[2]])^3]] &, Background -> 1, ...


10

Integrate can take the option Assumptions. Integrate[1/Sqrt[z^2 + u^2], {z, -l, l}, Assumptions -> u > 0 && l > 0 && Element[u | l, Reals]] ==> 2 Log[(l + Sqrt[l^2 + u^2])/u] Alternatively use Assuming. Assuming[u > 0 && l > 0 && Element[u | l, Reals], Integrate[1/Sqrt[z^2 + u^2], {z, -l, l}]] ...


10

I like ParametricPlot for visualizing domain mappings: f[z_] := (z + I)/(z - I); pp=ParametricPlot[ {Re@#, Im@#} &@f[x + I y] , {x, 0, 5}, {y, 0, 5}] You can use this interactive example to get more clarity what is mapped where: Manipulate[ {Graphics[Point[pt], PlotRange -> {{0, 5}, {0, 5}}, Axes -> True, GridLines -> Automatic], ...


9

You should assume that your variables are real, (if you want M to proceed further) because Mathematica treats variables in general as complex. One of many ways to do it : expr = A ((Cos[k y] + I Sin[k y]) 2 I Sin[t ω]); Refine[ Im[ expr], (A | k y | t ω) ∈ Reals] 2 A Cos[k y] Sin[t ω] We needn't use ComplexExpand defining expr, but in this case it ...


8

Just use ParametricPlot and split up the real and imaginary parts as shown below: eqn = (25 Pi f I)/(1 + 10 Pi f I) ParametricPlot[{Re[eqn], Im[eqn]}, {f, -5, 5}, AspectRatio -> 1] Note that you can use Set (=) rather than SetDelayed (:=) here.


8

Why not just the following? Solve[a z + b Conjugate[z] == c, z] Or, if you prefer separating real and complex parts: Solve[a (x + I y) + b (x - I y) == c, {x, y}] Or, if you want to worry about degenerate cases, replace Solve above by Reduce in each form.



Only top voted, non community-wiki answers of a minimum length are eligible