Jump to content

Display a linear combination: Difference between revisions

adding absolute values
mNo edit summary
(adding absolute values)
Line 3:
The purpose of this task is to display a finite [[wp:linear combination|linear combination]] in an infinite vector basis <math>(e_1, e_2,\ldots)</math>.
 
Write a function that, when given a finite list of scalars <math>(\alpha^1,\alpha^2,\ldots)</math>, creates a string representing the linear combination <math>\sum_i\alpha^i e_i</math> as a string in an explicit format often used in mathematics, that is:
 
The string should have an explicit format often used in mathematics, that is :<math>\alpha^{i_1}e_{i_1}\pm|\alpha^{i_2}|e_{i_2}\pm\ldots</math> where <math>|\alpha^{i_ki_3}|e_{i_3}\neq 0ldots</math>
 
where <math>\alpha^{i_k}\neq 0</math>
 
In other words, and with examples and counter-examples, your output must comply to the following rules:
1,934

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.