Edward Evans
Edward Evans

Reputation: 127

Plotting in maple

I'm having trouble plotting a set of complex numbers in maple.

I know what it should look like from a drawing I produced but I'd like to plot it in maple. My code is as follows;

z := x + I*y;

plots:-implicitplot([abs(z) <= 2, abs(z) >= 1, abs(arg(z)) >= Pi/4,
                     abs(arg(z)) <= Pi/2], x = -3...3, y = -3...3, filled = true);

The issue is that the inequalities are being plotted independently of each other rather than all together, so even the first pair of inequalities together fill the entire plane. Is there any way I can have the $4$ conditions imposed in $S$ be taken into account at the same time, rather than separately?

Upvotes: 2

Views: 424

Answers (2)

Sometimes using plots:-inequal takes a long time, in those cases I just use plots:-implicitplot with filledregions = true option. But I don't use a list of inequalities as its argument. For one plot only, implicitplot needs one equation/inequality, so what function can you use that gives you the intersection of regions for your inequalities? Very simple, just define a binary piecewise function with piecewise command. Here is how I do your plot.

f := piecewise( And( abs( x + y*I ) <= 2, abs( x + y*I ) >= 1, abs( argument( x + y*I ) ) >= Pi/4, abs( argument( x + y*I ) ) <= Pi/2 ), 1, 0 );
plots:-implicitplot( f > 1/2, x = -3..3, y = -3..3, filledregions = true, coloring = [yellow, white], view = [-3..3, -3..3] );

The output plot is the following. enter image description here

Note that plots:-inequal gives a more accurate output, but plots:-implicitplot takes less time, so you should consider the trade-off between them and see which is better on your specific example.

Upvotes: -1

Carl Love
Carl Love

Reputation: 1471

Didn't you mean for the second inequality to be reversed? Otherwise the first is redundant.

The command that you need is inequal, not implicitplot. Your args should be arguments. Your z expressions should be wrapped in evalc. (I don't why that's necessary, but it seems to be.) There's no need for filled= true. So, the command is

plots:-inequal(
     [evalc(abs(z)) <= 2, evalc(abs(z)) >= 1, 
      evalc(abs(argument(z))) >= Pi/4, evalc(abs(argument(z))) <= Pi/2
     ], x = -3...3, y = -3...3
 );

Upvotes: 4

Related Questions