# \[?\] Plot 2-D linear combinations with general coefficients?

**URL:** <https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [May 6, 2017, 9:05pm UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488 "2017-05-06T21:05:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahill](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@ahill](https://community.wolfram.com/u/ahill)\
**Post date:** [May 6, 2017, 9:05pm UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488/1 "2017-05-06T21:05:17Z")

</div>

In an attempt to display 2-D linear combinations and the span when the coefficients of the linear combination are s and 1-s , Wolfram Language won’t accept:

```
{Graphics[{Arrow[{{0, 0}, {2, 4}}], Arrow[{{0, 0}, {4, 2}}]}, 
Axes -> True], 
Graphics[Table[
Arrow[{{0, 0}, {s {2, 4}}, {(1 - s) {4, 2}}}], {s, 0, 1, 0.025}], 
Axes -> True]}

```

but does accept and performs an accurate calculation:

```
{Graphics[{Arrow[{{0, 0}, {2, 4}}], Arrow[{{0, 0}, {4, 2}}]}, 
Axes -> True], 
Graphics[Table[Arrow[{{0, 0}, {4 - 2 s, 2 + 2 s}}], {s, 0, 1, 0.25}],
Axes -> True]}(*{{0,0},{4 - 2 s,2 + 2 s}} is the same as {{0,0},{s \
{2,4},(1-s) {4,2}}*)

```

Please see attached Mathematica file. The math is the same either way, but the more generalized formula is not accepted.  
Perhaps this is a trivial coding error. But, it seems that there is an underlying Mathematica language issue.

 ![Linearcombinationcoefficientsand1minuss.jpg](https://global.discourse-cdn.com/wolfram/original/2X/9/95a254f9d1bb57ec283a01693819ab798cb64a3e.jpeg)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [May 6, 2017, 10:31pm UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488/2 "2017-05-06T22:31:01Z")

</div>

I think you should remove the extra curly braces:

```
Graphics[Table[
  Arrow[{{0, 0}, s {2, 4}, (1 - s) {4, 2}}], {s, 0, 1, 0.025}]]

```

---

<div class="post-metadata">

**Author:** ![ahill](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@ahill](https://community.wolfram.com/u/ahill)\
**Post date:** [May 7, 2017, 12:50am UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488/3 "2017-05-07T00:50:15Z")

</div>

Gianluca: Thank you for your reply. I tried using your suggestion with the following result:

 ![LinearcombinationcorrectionJPEG.jpg](https://global.discourse-cdn.com/wolfram/original/3X/b/f/bf94881401d3612418e8c887d86db3558c1a0460.jpeg)

Your suggestion is:  
Graphics[Table[  
Arrow[{{0, 0}, s {2, 4}, (1 - s) {4, 2}}], {s, 0, 1, 0.025}]]

However, following the “{0,0},” there will need to be a curly brace preceding “s {2, 4}, (1 - s) {4, 2}” because it is the vector used to create the arrow: Graphics[Table[Arrow[{{0, 0}, {s {2, 4}, (1 - s) {4, 2}}], {s, 0, 1, 0.025}]] –  
It seems that the curly braces are required because the Arrow operator requires curly braces and the creation of a vector also requires curly braces, (resulting in a pile-up of curly braces):  
{Graphics[{Arrow[{{0, 0}, {2, 4}}], Arrow[{{0, 0}, {4, 2}}]},  
Axes → True],  
Graphics[Table[  
Arrow[{{0, 0}, {{s {2, 4}, (1 - s) {4, 2}}}}], {s, 0, 1, 0.025}]  
, Axes → True]}  
This again results in a non-result…corrected by carrying out the arithmetic.

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [May 7, 2017, 6:27am UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488/4 "2017-05-07T06:27:00Z")

</div>

Welcome to Wolfram Community! Please make sure you know the rules and how to format your code properly, which you can find here: [https://wolfr.am/READ-1ST](https://wolfr.am/READ-1ST) If you do not format code, it may become corrupted and useless to other members. Please EDIT your posts and make sure code blocks start on a new paragraph and look framed and colored like this.

```
int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

```

 ![ScreenShot2017-04-28at9.43.33AM.png](https://global.discourse-cdn.com/wolfram/original/3X/f/3/f3367c082cbad32b79855f70628ea173f845653e.png)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [May 7, 2017, 9:23am UTC](https://community.wolfram.com/t/plot-2-d-linear-combinations-with-general-coefficients/10488/5 "2017-05-07T09:23:40Z")

</div>

If you enclose `s {2, 4}, (1 - s) {4, 2}` within braces, it becomes a 2 by 2 matrix, not a vector. If you want a linear (convex) combination of the vectors `{2,4}` and `{4,2}` you should combine them with a plus sign:

```
Graphics[Table[
  Arrow[{{0, 0}, s {2, 4} + (1 - s) {4, 2}}], {s, 0, 1, 0.025}]]

```
