These are chat archives for symengine/symengine

19th
Sep 2016
Francesco Biscani
@bluescarni
Sep 19 2016 10:26
@isuruf https://ci.appveyor.com/project/bluescarni/mppp I got the new integer class up and running with MSVC yesterday
Francesco Biscani
@bluescarni
Sep 19 2016 11:07
I've put quite some effort in microbenchmarking, hopefully it's not all in vain and it yields some true benefits once the class starts being used in practice
so far it should be faster than piranha's integer, according to the benchmarks
I've implemented add, mul and addmul so far, which are the most painful ones
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:24
Hey, thanks for the Symengine.jl announcement. Sounds exciting. Are there any benchmarks vs Mathematica?
Isuru Fernando
@isuruf
Sep 19 2016 16:25
@ChrisRackauckas, there are some here at the end, https://github.com/certik/scipy-2016-symengine-talk/blob/master/talk.pdf
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:27
Cool
Those benchmarks look on point!
I plan on converting one of my Mathematica scripts that I can't run on a HPC then (licensing issue...)
Isuru Fernando
@isuruf
Sep 19 2016 16:27
@bluescarni, thanks for the update.
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:27
Also, I plan on getting this to work with Symengine instead of SymPy: https://github.com/JuliaDiffEq/ParameterizedFunctions.jl
Isuru Fernando
@isuruf
Sep 19 2016 16:28
What are the methods that you are using from SymPy?
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:28
Just differentiate
I couldn't find out how to just take the Jacobian
or make a vector function (Mathematica guy here, never really used SymPy)
The Mathematica script is just matrix multiplications and inverses. Getting a (huge) analytical solution for components of certain matrices.
Isuru Fernando
@isuruf
Sep 19 2016 16:29
Jacobian is probably in the matrices section of SymPy
same as in SymEngine
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:30
Okay.
Isuru Fernando
@isuruf
Sep 19 2016 16:30
What do you mean by a vector function?
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:31
f(x)f(x) where xx is a vector, returns a vector of the same length: f:RnRnf:\mathbb{R}^n\rightarrow\mathbb{R}^n
like a system of ODEs
Isuru Fernando
@isuruf
Sep 19 2016 16:32
Is this function called regularly? If so, SymPy has lots of different code generation modules
lambdify converts the sympy expression to a numpy expression. ufuncify makes a numpy ufunc. All of these take in a vector.
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:33
It's only called once to generate a function. I use a Julia macro to read the AST, get what the functions the user wants are, send those over to SymPy, take derivatives on each one to build a matrix which is the Jacobian, and then send that back to Julia to build an in-place computation of the derivative.
Where are the SymEngine docs?
Or does it just override SymPy behavior?
Isuru Fernando
@isuruf
Sep 19 2016 16:36
There are none, actually. Unit tests are the only docs we have for now. (And some wiki pages)
API is very similar to SymPy. (At least the Python wrapper)
That's a good strategy. lambdify is only good if the compile time is a bottleneck. ufuncify compiles the function, but since Julia has JIT compilation, you don't need that
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:41

I also want to make sure it's an in-place op afterwards:

function Base.ctranspose(p::LotkaVoltera) = (t,u,J) -> begin
  J[1,1] = p.a-p.b
  J[1,2] = -p.b
  J[2,1] = u[2]
  J[2,2] = -3 + u[1]
end

where the RHS are the functions I got from the symbolic derivatives. It seemed that all of the functions would return a matrix instead.

Isuru Fernando
@isuruf
Sep 19 2016 16:43
You mean on SymPy or SymPy.jl. In SymPy, default matrix type is MutableDenseMatrix which is mutable
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:43
SymPy.jl
Isuru Fernando
@isuruf
Sep 19 2016 16:46
I have no idea. I'm still not familiar with the internals of SymPy.jl
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:46
It's fine. I got something working anyways, so it's all good.
I see I can just use the same diff function with SymEngine and it should work.
Did you optimize/benchmark memory usage yet?
Isuru Fernando
@isuruf
Sep 19 2016 16:49
That's great. SymEngine.jl uses the cwrappers here. https://github.com/symengine/symengine/blob/master/symengine/cwrapper.h . Matrix functionality is not yet wrapped into Julia, but that should be easy with ccall
Haven't benchmarked memory usage. SymEngine uses reference counting. If you see the expand6b benchmark in the pdf I gave, Maple has a spike probably because of garbage collection.
Christopher Rackauckas
@ChrisRackauckas
Sep 19 2016 16:58
I ask because I have a project with can take exceedingly large amounts of memory in Mathematica. I got an allocation on the Bridges 12 TB of RAM node for dealing with it (but got locked up in license issues).
I'll probably write up some benchmarks (linear algebra memory usage / time) and see what I get for these two
Isuru Fernando
@isuruf
Sep 19 2016 17:01
Oh, wow. Please do share the benchmarks with us.