Display a linear combination: Difference between revisions
Content added Content deleted
(Added Elixir) |
m (used a larger font to make it easier to read the superscripts and symbols, added other whitespace and highlighting, re-did the examples with more whitespace, reduced some verbiage, added a ;Task; (bold) header, added whitespace before the TOC.) |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
;Task: |
|||
Display a finite [[wp:linear combination|linear combination]] in an infinite vector basis <big><big><math> (e_1, e_2,\ldots)</math></big></big>. |
|||
Write a function that, when given a finite list of scalars <math>(\alpha^1,\alpha^2,\ldots)</math>, |
Write a function that, when given a finite list of scalars <big><big><math> (\alpha^1,\alpha^2,\ldots) </math>,</big></big> |
||
<br>creates a string representing the linear combination <big><big><math> \sum_i\alpha^i e_i </math></big></big> in an explicit format often used in mathematics, that is: |
|||
:<math>\alpha^{i_1}e_{i_1}\pm|\alpha^{i_2}|e_{i_2}\pm|\alpha^{i_3}|e_{i_3}\pm\ldots</math> |
::: <big><big><math> \alpha^{i_1}e_{i_1}\pm|\alpha^{i_2}|e_{i_2}\pm|\alpha^{i_3}|e_{i_3}\pm\ldots </math></big></big> |
||
⚫ | |||
<br> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
::::::: '''e(1)''' is fine, '''e(1) + 0*e(3)''' or '''e(1) + 0''' is wrong. |
|||
⚫ | |||
⚫ | |||
::::::: '''e(3)''' is fine, '''1*e(3)''' is wrong. |
|||
⚫ | |||
* |
* don't prefix by a minus sign if it follows a preceding term. Instead you use subtraction. |
||
::::::: '''e(4) - e(5)''' is fine, '''e(4) + -e(5)''' is wrong. |
|||
<br> |
|||
Show here output for the following lists of scalars: |
Show here output for the following lists of scalars: |
||
<pre> |
<pre> |
||
1) 1, 2, 3 |
|||
2) 0, 1, 2, 3 |
|||
3) 1, 0, 3, 4 |
|||
4) 1, 2, 0 |
|||
5) 0, 0, 0 |
|||
6) 0 |
|||
7) 1, 1, 1 |
|||
8) -1, -1, -1 |
|||
9) -1, -2, 0, -3 |
|||
10) -1 |
|||
</pre> |
|||
<br><br> |
|||
=={{header|EchoLisp}}== |
=={{header|EchoLisp}}== |