Message Boards Message Boards

0
|
4811 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

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

Posted 7 years ago

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. enter image description here

Attachments:
POSTED BY: Arthur Hill
4 Replies

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 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]

enter image description here

POSTED BY: Moderation Team
Posted 7 years ago

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

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.

POSTED BY: Arthur Hill

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}]]
POSTED BY: Gianluca Gorni

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}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract