These are chat archives for symengine/symengine

26th
Jun 2014
Ondřej Čertík
@certik
Jun 26 2014 18:37
@thilinarmtb thanks for working on the simplification issue. Why isn't it triggered by (2/x) * (x/2)?
Ondřej Čertík
@certik
Jun 26 2014 18:42
(sympy/csympy#212)
Ondřej Čertík
@certik
Jun 26 2014 18:53

I think I know, it's this part of `Mul::dict_add_term()`:

``````        } else {
// General case:
if (is_a<Integer>(*it->second) &&
rcp_static_cast<const Integer>(it->second)->is_zero()) {
d.erase(it);
}
}``````

which checks that the coefficient is `zero` (after combining 2/x and 2/x), and removes it from the dictionary. So I think all that is needed is to check, that the combined coefficient and key is of the type 2^-5, i.e. that it can be represented as a Rational, and if so, remove it from the dict, and add it to the overall coefficient.

Jess Smith
@smithjessk
Jun 26 2014 19:06
Hi, I'm new here. Does anyone know if integrals will soon be included in CSympy?
Ondřej Čertík
@certik
Jun 26 2014 19:07
hi @smithjessk what kind of integrals do you need?
Jess Smith
@smithjessk
Jun 26 2014 19:08
@certik relatively simple indefinite ones that can be handled by sympy. for example, integrating sin(x)
Ondřej Čertík
@certik
Jun 26 2014 19:10
@smithjessk what is your application that sympy is too slow for this?
Jess Smith
@smithjessk
Jun 26 2014 19:11
@certik i'd prefer to use sympy, but the application is for the iphone.
Ondřej Čertík
@certik
Jun 26 2014 19:13
I thought that iphone runs python?
anyway, to answer your question, we can add some simpler integrals, but I don't want to reimplement the whole sympy. The goal of csympy is to deliver the speed.
Jess Smith
@smithjessk
Jun 26 2014 19:16
@certik at least to my knowledge, there's no effective way to include Python code in an iOS application.
Ondřej Čertík
@certik
Jun 26 2014 19:16
I see. How would you include a C++ application like csympy?
Jess Smith
@smithjessk
Jun 26 2014 19:17
@certik do you mean reimplementing all of the sympy integrals module?
@certik you can ship c++ code inside of an iOS application. since it's MIT licensed, it can be ported without too much trouble. please correct me if I'm wrong here :)
Ondřej Čertík
@certik
Jun 26 2014 19:18
(I don't want to reimplement the whole sympy integrals module, as it depends on good polynomial support and then it's highly nontrivial, i.e. that would be like a year of work or so.)
Jess Smith
@smithjessk
Jun 26 2014 19:19
yes, but csympy is MIT.
what is lacking about the polynomial support now?
Ondřej Čertík
@certik
Jun 26 2014 19:19
right. What is the problem with a BSD license?
I am genuinely curious.
Jess Smith
@smithjessk
Jun 26 2014 19:20
there isn't a problem! i was just saying
Ondřej Čertík
@certik
Jun 26 2014 19:21
I don't understand your argument, that thanks to MIT, it can be ported, but due to BSD, it can't be ported.
Jess Smith
@smithjessk
Jun 26 2014 19:21
sorry for the confusion, that wasn't my argument.
Ondřej Čertík
@certik
Jun 26 2014 19:21
I see.
As to polynomials, essentially nothing is implemented yet in csympy, but I plan to use https://github.com/bluescarni/piranha for good and fast polynomial support.
But for integrals, I think some factorization and other polynomial algorithms are needed, and those would have to be implemented.
Jess Smith
@smithjessk
Jun 26 2014 19:24
alright.
i read something somewhere about converting Sympy to its C code and using that.
do you have any thoughts about that approach?
Ondřej Čertík
@certik
Jun 26 2014 19:25
Is the goal to run sympy on platforms that don't run python?
or is the goal to have faster sympy by some automatic translation to C?
Jess Smith
@smithjessk
Jun 26 2014 19:26
the former
Ondřej Čertík
@certik
Jun 26 2014 19:26
If the latter, I don't think that's viable, see my thoughts here https://groups.google.com/d/topic/sympy/n5MS2khr3pI/discussion
if the former, I still don't know any tool that could do that. Since Python is written in C, sympy is essentially a C library in this sense.
Jess Smith
@smithjessk
Jun 26 2014 19:28
i see.
Ondřej Čertík
@certik
Jun 26 2014 19:28
I still don't understand why you can't run python. A quick google searched revealed:
https://itunes.apple.com/us/app/python-2.7-for-ios/id485729872?mt=8
http://www.saurik.com/id/5
In fact, the first link has sympy running in iphone...
Jess Smith
@smithjessk
Jun 26 2014 19:29
i think that uses a network connection to interpret.
and i was hoping for a completely network-free solution
Ondřej Čertík
@certik
Jun 26 2014 19:32
Of course. I didn't know it is using the network. How exactly does that work? Does it require a server to run?
This fact isn't mentioned anywhere.
Jess Smith
@smithjessk
Jun 26 2014 19:33
I could very well be wrong, I just assumed it was network-based since the app is only 38 Mb large.
and the python interpreter + sympy, etc, would be much larger than that
Ondřej Čertík
@certik
Jun 26 2014 19:36
sympy source code is 5.7MB, python source code is 14MB
The python binaries are 101MB on my linux
But maybe you can strip them down a bit.
Jess Smith
@smithjessk
Jun 26 2014 19:38
yeah, probably could.