Plot in a 2-dimensional simplex

I have a row vector as $P=(p_1,p_2,p_3)$ which should be obtained from the following constraints:

1. $a_1p_1 + a_2p_2 + a_3p_3 = b_1p_1 + b_2p_2 + b_3p_3$ ($a_i$'s and $b_i$'s are known)
2. $p_1 + p_2 + p_3 = 1$
3. $p_i\geq 0,\ i=1,2,3.$

Furthermore, there may be more than one P vector satisfying the above constraints. Then, I want to use each P vector in the following equations to plot (x,y) in a 2-dimensional space.

1. $x = p_1x_1 + p_2x_2 + p_3x_3$
2. $y = p_1y_1 + p_2y_2 + p_3y_3$ (Both $x_i$'s and $y_i$'s are known)

I would be very thankful if anyone has any idea!

Best,

Thank you very much for your help! Your codes gave so many ideas to me since I'm a beginner in Mathematica.

But the point is that putting $p_i=0$ at every step and finding the corresponding 2-dimensional line is not always correct because there may be some solutions whose $p_i$'s are not equal to 0.

Maybe, I did not explain properly about my problem. Here is what I'm looking for: I have the following set of constraints:

1. $P.C>=0$, where $P=(p_1,p_2,p_3)$ and $C=(c_1,c_2,c_3)$ and $C$ is known.
2. $P.D>=0$, where $P=(p_1,p_2,p_3)$ and $D=(d_1,d_2,d_3)$ and $D$ is known.
3. $P.E>=0$, where $P=(p_1,p_2,p_3)$ and $E=(e_1,e_2,e_3)$ and $E$ is known.
4. $p_1+p_2+p_3=1$ (* edited *)
5. $p_i>=0$ for all $i$

As I said before, there may be several $P$ vectors satisfying the above constraints. Furthermore, there may be non-negative $P$ vectors, e.g. $P=(1/3,1/3,1/3)$ that satisfies the above constraints. After obtaining all such $P$ vectors, based on them, I want to plot the following x-y variables in 2 dimensions:

1. $x=p_1x_1+p_2x_2+p_3x_3$
2. $y=p_1y_1+p_2y_2+p_3y_3$

Furthermore, the way my problem is modeled, I am sure that I have a line in 2D. I tried so many different methods found in internet, but unfortunately, none of them worked.

Again, I would be very grateful if anyone help me in this case!

Let $c=(a_1-b_1,a_2-b_2,a_3-c_3)$. To start with notice that eqns 1 and 2 represent each a 3D-plane whose intersection is a line (unless all $c_i$'s are equal). When intersected with eqn. 3 this gives either nothing, a single point or a line segment. Take for example $c=(1,2,-3)$ and intersect the line with canonical planes :

c = {1, 2, -3};
u = {1, 1, 1};
p := {p1, p2, p3};
Pt1 = p /. (First@Solve[c.p == 0 && u.p == 1 && p1 == 0, p])
Pt2 = p /. (First@Solve[c.p == 0 && u.p == 1 && p2 == 0, p])
Pt3 = p /. (First@Solve[c.p == 0 && u.p == 1 && p3 == 0, p])

Show[
RegionPlot3D[c.p <= 0 && u.p <= 1,
{p1, 0, 1}, {p2, 0, 1}, {p3, 0, 1},
AxesOrigin -> {0, 0, 0}, Boxed -> False, PlotPoints -> 50,
AxesLabel -> Automatic],
Graphics3D[{Red, Thickness -> .02, Line[{Pt1, Pt2}]}]
]

output :

{0, 3/5, 2/5}
{3/4, 0, 1/4}
{2, -1, 0} Just by looking at the 3 points you figure out that the line segment you need is Pt1-Pt2 (positive coordinates). Now, what you want is to linearly transform this line segment, the result is the (2D) segment between the two transforms:

(* example of X and Y :*)
X = {1, 2, 3}; Y = {4, 5, 6}; M = {X, Y};
start = M.Pt1
end = M.Pt2
ParametricPlot[t start + (1 - t) end, {t, 0, 1}, AxesOrigin -> {0, 0}]

output:

{12/5, 27/5}
{3/2, 9/2} Edit

Now for the more general case. Eqns 4 (which I am assuming you meant "... = 1") and 5 define a 2D-triangle in 3D-space, so we can use that as a parametric surface of points that look like this: point $=(p_1,p_2,1-p_1-p_2)$. We make sure these points only exist when all constraints are satisfied. With made-up data:

u = {1, 1, 1};
CDE = {{1, 2, -3}, {-1, 2, -1}, {-1, 1, 1}};
X = {1, 2, 3}; Y = {-1, 2, -3}; M = {X, Y};

point[p1_, p2_] := With[{p = {p1, p2, 1 - p1 - p2}},
If[And @@ Positive@(CDE.p) && u.p == 1, p, Undefined]]

Show[
ParametricPlot3D[point[p1, p2], {p1, 0, 1}, {p2, 0, 1},
PlotRange -> {{0, 1}, {0, 1}, {0, 1}},
PlotLabel -> "Region in the 3D simplex",
AxesOrigin -> {0, 0, 0}, Boxed -> False, PlotPoints -> 100,
AxesLabel -> {"p1", "p2", "p3"}, ImageSize -> Medium],
Graphics3D[{Thick, Orange, Dashed,
Line[{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {1, 0, 0}}]}]] Now just transform that as above:

ParametricPlot[M.point[p1, p2], {p1, 0, 1}, {p2, 0, 1},
AxesOrigin -> {0, 0}, PlotRange -> Full,
PlotLabel -> "Region in the 2D plane",
PlotPoints -> 200, AspectRatio -> .8] Note

As your are taking the linear transform of a polyhedron the region in 2D-space is likely to be a polyhedron as well, except in rare cases where it can be a line, point, or be empty.

• Thank you very much for your help! – Alex Jan 5 '14 at 2:08
• Thank you very much! Here is an instance of my problem: CD = {{0.8,-0.9,1.5}, {0.7,0.3,-0.4}}; X = {0.5, 0, 1}; Y = {Sqrt[0.75], 0, 0}; M = {X, Y}; But when I use your code and obtain the transformed region in 2D, some sides of the region has zig-zag form, while the actual side must be like a straight line. Would you know how this can be resolved? Thanks! – Alex Jan 6 '14 at 19:00
• @Alireza I changed my example and added a note in response to your comment. Lines appearing as jagged are usually fixed by increasing PlotPoints as shown. – A.G. Jan 6 '14 at 21:13
• Dear A.G., I really appreciate your help! Thank you so much! – Alex Jan 6 '14 at 21:37
• @Alireza. My pleasure! As I can see that you are new here I suggest that, if the answer works for you, you mark it as "accepted" (the check-mark next to the answer). – A.G. Jan 6 '14 at 21:50