3
$\begingroup$

I am having difficulty plotting something along these lines in Mathematica.

Imgur

I will explain what is going on here. Basically, I am solving an interval equation $ax=b$, in the first example $a = [1, 20]$ and $b =[3, 4]$ and therefore $b/a = [3/20, 4]$. As you can see from the graph I want a circle representing the projective line. A straight line will come off the two end points of the interval which represents the solutions and those lines will go through the center of the circle and the region bounded by the lines should be shaded in.

Similarly the other example below is an unbounded one where $a = [-1,2]$ and $b = [5,100]$ and hence $b/a = (-\infty, -5] \cup [5/2, \infty]$. Same type of plot though, the lines come off $-5$ and $5/2$ on the x axis and go through the center of the circle and the bounded regions are shaded.

Could someone please help me plot this?

$\endgroup$
7
  • $\begingroup$ How are the circles constructed? Are they unit circles centered at {0, -1}. $\endgroup$ Commented Aug 18, 2014 at 18:54
  • $\begingroup$ Yes they are :) $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 19:17
  • $\begingroup$ Oh also letting you know that my solution to the interval equation will be given as a system of inequalities so for the first example above I will be given the following: x1 >= 0 && 1*x1 <= 4 && 20*x1 >= 3 || x1 <= 0 && 20*x1 <= 4 && 1*x1 >= 3 $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 19:20
  • $\begingroup$ It would help to know what you have tried, to avoid unnecessarily spending time explaining things you already did. $\endgroup$
    – Jens
    Commented Aug 18, 2014 at 19:30
  • $\begingroup$ I am completely new to mathematica I have no clue to be honest and need this desperately as soon as possible. Could someone please help? My idea is to figure out the points from the inequalities somehow then make a function that computes a straight line that goes through that point on the x axis and (0,-1) then fill in the region :/ $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 19:39

1 Answer 1

5
$\begingroup$

This is not a complete solution but it may help.

Manipulate[
 Graphics[{{Circle[{0, -1}, 1]}, {Blue, 
    Disk[{0, -1}, 1, {ArcTan[1/b], ArcTan[1/a]}]}, {Blue, 
    Disk[{0, -1}, 
     1, \[Pi] + {ArcTan[1/b], 
       If[b < 0, \[Pi], 0] + ArcTan[1/a]}]}, {Green, 
    Line[{{{a, 0}, {0, -1}}, {{b, 0}, {0, -1}}}]}}, Frame -> True, 
  PlotRange -> {{-5, 5}, {-3, 1}}, Axes -> True], {a, .1, 3}, {b, -5, 
  5}]
$\endgroup$
10
  • $\begingroup$ This is incredible thanks! How do I modify it so I can see the Circle itself as well rather than just the shaded in areas? $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 20:06
  • $\begingroup$ If i substitute in -5, and 5/2 for a and b respectively, it doesn't exactly plot what I am looking for. Doesn't shade the bottom part? Looks really close though. Any idea how to fix that? Thanks] $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 20:13
  • $\begingroup$ @Kadir (1) add Circle[{0, -1}] to the list of directives. $\endgroup$
    – Mr.Wizard
    Commented Aug 18, 2014 at 20:26
  • $\begingroup$ @Kadir I have already add the circle. for the range -5 and 5/2, you may change the plot range to include the far distances of a or b. I have already did that. $\endgroup$ Commented Aug 18, 2014 at 20:30
  • $\begingroup$ You are a brilliant brilliant man, just one last little thing, which value of the intervals have you referred to as a and b, I am getting tad confused when plotting. In the bounded case the interval is of the form [a,b], in the unbounded form its of the form (-infinity, a] UNION [b, +infinity) ? I think you may have swapped the two by mistake but I am not sure? $\endgroup$
    – Kadir
    Commented Aug 18, 2014 at 20:37

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.