3
$\begingroup$

Given the following complex numbers (defined as the values of two functions f and g defined only on the points 0 and 1):

f[0] := (1 + 0 I)
f[1] := 0.5 E^(I \[Pi]/4)
g[0] := (0 + 1 I)
g[1] := 2 E^(I (\[Pi]/2 + \[Pi]/2 + \[Pi]/2))

is there a way to plot each of f[0], f[1], g[0], and g[0] as "arrow vectors" on the complex plane? Something analogous to the following:

enter image description here

except that (i) each of the complex numbers is labeled f[0], f[1], g[0], g[1] and (ii) the two f complex numbers are colored green while the two g complex numbers are colored blue.

$\endgroup$
1
  • $\begingroup$ There are many posts on plotting complex numbers, e.g. Plotting complex numbers as an Argand Diagram. And there are many posts on plotting arrows (see e.g. this). If you read both your question will be slightly simpler to answer. $\endgroup$
    – Artes
    Commented Jun 10, 2019 at 17:07

2 Answers 2

4
$\begingroup$

You can use ComplexListPlot as follows:

data = Join[Thread[{0, f /@ {0, 1}}], Thread[{0, g /@ {0, 1}}]];
colors = {Red, Green, Blue, Orange};

clp1 = ComplexListPlot[data,  
     PlotStyle -> (Directive[Arrowheads[Large], AbsoluteThickness[3], #] & /@ colors),
     Joined -> True, Mesh -> All, AxesLabel -> {"Re", "Im"}, 
     AxesOrigin -> {-.3, 0}, PlotRange -> All] /. {Point -> Nothing, Line -> Arrow};

clp2 = ComplexListPlot[Join[Callout[f @ #, HoldForm[f @ #]] & /@ {0, 1}, 
    Callout[g @ #, HoldForm[g @ #]] & /@ {0, 1}]] /. Point -> Nothing;

Show[clp1, clp2]

enter image description here

$\endgroup$
4
  • $\begingroup$ This is great. Is there a way to specify a color for each of the arrows? $\endgroup$
    – George
    Commented Jun 10, 2019 at 22:26
  • $\begingroup$ @George, you can try something like PlotStyle -> (Directive[Arrowheads[Large], AbsolutePointSize[0], AbsoluteThickness[3], #]&/@ {Red, Green, Blue, Orange}) $\endgroup$
    – kglr
    Commented Jun 10, 2019 at 22:35
  • $\begingroup$ Last question: is there a way to add the labels "f[0]", "f[1]", etc to the arrows, and expand the axis so that all arrows are guaranteed to be visible? $\endgroup$
    – George
    Commented Jun 10, 2019 at 22:51
  • $\begingroup$ @George, please see the update. $\endgroup$
    – kglr
    Commented Jun 10, 2019 at 23:13
0
$\begingroup$

(* Use all 3 imaginary elements of the 4d quaternion for the Arrow, reserving the first element as 0, or to represent some other quantity, such as color. You must load the Quaternion Package with

<< "Quaternions`" *)

<< "Quaternions`"


q = Quaternion[0, 1, 2, 3];

arrowFromQuaternion[quaternion_Quaternion] :=  Module[{a, b, c}, {a, b, c} = Rest[List @@ quaternion];

Graphics3D[{Purple, Arrow[{{0, 0, 0}, {a, b, c}}], PointSize[Large],Point[{a, b, c}]},Axes -> True]];
arrowFromQuaternion[q]
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.