Bug 302813 - Complex numbers support
Summary: Complex numbers support
Status: RESOLVED FIXED
Alias: None
Product: analitza
Classification: Frameworks and Libraries
Component: core (show other bugs)
Version: unspecified
Platform: unspecified All
: NOR wishlist
Target Milestone: ---
Assignee: Aleix Pol
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-30 21:18 UTC by Percy Camilo Triveño Aucahuasi
Modified: 2014-07-21 02:23 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Percy Camilo Triveño Aucahuasi 2012-06-30 21:18:31 UTC
Hi there, I'll like to ask:

Support complex numbers and operations, for example:
String form: "i*i" or "complex(0,1)*complex(0,1)"
String result: "-1" or "complex(-1,0)"
Internal: if is posible std::complex :)

Percy


Reproducible: Always
Comment 1 Aleix Pol 2012-07-01 11:56:02 UTC
So you'd use i for it?

There's a proof of concept made by adria here: http://swiftscythe.blogspot.com/2011/02/how-to-work-with-complex-numbers-in.html

maybe we should develop it further like he did?
Comment 2 Percy Camilo Triveño Aucahuasi 2013-10-28 19:06:53 UTC
Well can be done like that, but note that its better to put all those calculations in a way that more students learn this topic, for example for the student that open KAlgebra it would be natural to think this:

i*i
and get
-1

I think is important to copy or emulate the symbolism used in math classes ;)

Percy
Comment 3 Aleix Pol 2013-10-28 20:28:19 UTC
Git commit fde6bdfb0114d384c1ad258fd351f4558ea63e09 by Aleix Pol.
Committed on 28/10/2013 at 20:28.
Pushed by apol into branch 'master'.

Support roots with an imaginary part
Related: bug 231816

M  +7    -3    analitza/operations.cpp
M  +5    -3    analitza/tests/analitzatest.cpp

http://commits.kde.org/analitza/fde6bdfb0114d384c1ad258fd351f4558ea63e09
Comment 4 Aleix Pol 2013-10-29 17:36:17 UTC
Git commit cd3fbd29bd9c29a6033729b42d98bf37b3f551a7 by Aleix Pol.
Committed on 29/10/2013 at 16:22.
Pushed by apol into branch 'imaginary'.

Considering approaches to imaginary numbers

I'm unsure what approach to take though, usually imaginary numbers are
represented by an expression such as a+bi and this would be stored in a
separate Cn instance. This is not ideal because this means we'll have
values that output an expression.

M  +1    -1    analitza/value.cpp
M  +8    -1    analitza/value.h

http://commits.kde.org/analitza/cd3fbd29bd9c29a6033729b42d98bf37b3f551a7
Comment 5 Aleix Pol 2013-10-29 17:36:42 UTC
maybe you'd like to take a look at the "imaginary" branch?
Comment 6 Percy Camilo Triveño Aucahuasi 2013-10-30 04:40:23 UTC
(In reply to comment #4)
> Git commit cd3fbd29bd9c29a6033729b42d98bf37b3f551a7 by Aleix Pol.
> Committed on 29/10/2013 at 16:22.
> Pushed by apol into branch 'imaginary'.
> 
> Considering approaches to imaginary numbers
> 
> I'm unsure what approach to take though, usually imaginary numbers are
> represented by an expression such as a+bi and this would be stored in a
> separate Cn instance. This is not ideal because this means we'll have
> values that output an expression.
> 
> M  +1    -1    analitza/value.cpp
> M  +8    -1    analitza/value.h
> 
> http://commits.kde.org/analitza/cd3fbd29bd9c29a6033729b42d98bf37b3f551a7

It seems ok for mathml standard, see Cn description:

http://www.w3.org/TR/2003/REC-MathML2-20031021/chapter4.html#contm.cn

and

http://www.w3.org/TR/2003/REC-MathML2-20031021/chapter4.html#contm.complexes

What is the issue that I can't see? :)

'i' is a value, a complex one, so it seems a good approach.
Comment 7 Percy Camilo Triveño Aucahuasi 2014-07-21 02:23:42 UTC
With 
Git commit f9bed1300be72c23a3ebc7237a8f4de91d756566 by Aleix Pol.
this issue is closed.