Talk:Display a linear combination: Difference between revisions

(→‎Wat?: new section)
 
Line 2:
 
There's a variety of ways of implementing linear combinations, and this particular task is requiring a representation which will not be executable in many languages. So it would be good to add some motivation to the task description. Why would someone want to do this? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 16:15, 13 October 2015 (UTC)
 
:I was working on my [https://github.com/grondilu/clifford Perl 6 Geometric Algebra library] and I needed some way of displaying a multivector. By default I had an output like this one:
 
<pre>MultiVector.new(blades => (my Real %{UInt} = 0 => 1, 4 => 1, 10 => 3))</pre>
 
:Which is the output from <math>1 + e(2) + 3*e(1)*e(3)</math>, and it is clearly not satisfying. I wanted an output that looks like the input. The more I thought about it the more I was annoyed by the idea that in order to have something that looks good I would have to make sure I don't display the scalars if they are 1, and that I use a subtraction where appropriate. It was looking like quite a hassle,so I thought: « why not make a rosetta task so that I can steal the solution from others? » :-)
 
:As a matter of fact soon after I created the task I realized I could get a simple solution by using string substitutions on the output, so I was actually able to write the first solution in Perl 6.
 
:I still think it's a useful task, as it can be used for instance to display complex numbers or quaternions. In perl 6 for instance the output for complex numbers is not perfect. i is displayed as '0+1i;', which to me is acceptable but not so great. With [https://github.com/Util/Perl6-Math-Quaternion/ Math::Quaternions] it's much worse and arguably not acceptable.
 
:--[[User:Grondilu|Grondilu]] ([[User talk:Grondilu|talk]]) 22:09, 13 October 2015 (UTC)
1,934

edits