GSoC 2011 Application

17 views
Skip to first unread message

Yuri Karadzhov

unread,
Mar 21, 2011, 3:10:27 PM3/21/11
to sympy
Hello:

I am PhD student of the Kiev Institute of Mathematics, National
Academy of Science, Ukraine. I have an honors master's degree in
mathematical physics and computer sciences.

Currently in applied math department I study the theory of Lie groups
and it's application to the differential equations. The most recent
works however concerned with supersymmetry of Schrödinger-Pauli
equation of arbitrary dimension. The obtained results widely extend
the number of exactly solvable Quantum Mechanic problems as well as
generalize the approach of finding such problems.

I am interested in participating in Sympy 2011 GsoC project. I have
required mathematical skills as well as good knowledge of different
CAS (Mathematica, Maple, Sage) and experience to write extensions for
them. The proposed ideas were interesting for me and I would be glad
to help with most of them, especially with ones concerned with
integration, series, ordinary and partial differential equation, Lie
groups, supersymmetry and quantum mechanics.

I would also like to propose my own ideas which I found helpful in my
study.
1. Implement functions to be able to collect similar members of
expression containing functions and to gather coefficients of linearly
independent members.

e.g. expression
x*(a+b*y+sin(y))+y*(c+3*x+x^2)+x*sin(y+3)+x*cos(y)+f(x,y,t)

should be translated to
a*x+(b+c)*y+3*x*y+x^2*y+(1+cos(3))*x*sin(y)+(1+sin(3))*x*cos(y)
+f(x,y,t)

and functions and coefficients should be gathered
[a, b+c, 3, 1, 1+cos(3), 1+sin(3), 1]
[x, y, x*y, x^2*y, x*sin(y), x*cos(y), f(x,y,t)]

where x, y are variables and a, b, c, t - unknown constants
That is, to do the same things that collect and coeffs functions do
with polynomials.
2. Implement case wise methods for expressions depending on
parameters.
e.g. Solve ODE containing constant parameters
diff(f(r),r)=a*f(r)+b*r+c

has two significantly different solutions
f(r)=C1*exp(a*r)-b*r/a-(b+a*c)/a^2 if a != 0
f(r)=b*r^2/2+c*r+C1 if a = 0

where r - independent variable, f - dependent variable, a, b, c -
arbitrary constants
This problems become extremely painful, when we have bunch of more
complex equations and expressions. Unfortunately there are no
solutions in commercial CAS, such as Maple, Mathematica and MatLab as
well as in open source such as Maxima and Sage. Actually Symbolic
Tools Box (former MuPad) in MatLab tried to solve the second problem,
but the solution does not work well. Mentioned problems are connected
with each other and with improvement of pattern matching problem in
Sympy. I have complete solution for Maple and porting it to
Mathematica. I think it won't be a problem to implement this algorithm
in Sympy.

Also I want to concentrate attention on some small problems, solution
of which can improve usability of Sympy
e.g. It is possible to simplify usage of dsolve function in case when
dependent and independent variables are obvious.
The equation
eq=diff(y,x)+a*y+b*x+c
has y as dependent variable and x as independent, so it is better to
write
dsolve(eq)
The solution is complete (as patch for Sage, but it can be easily
adopt to Sympy).

I think that it can be interesting to implement this algorithms in
Sympy in terms of the GSoC project.

If you are interested in my proposal please contact me and I will send
you precise plan and if not, I will be glad to participate in one of
the proposed projects.

Best regards,
Yuri Karadzhov

Yuri Karadzhov

unread,
Mar 21, 2011, 3:33:15 PM3/21/11
to sympy

Aaron S. Meurer

unread,
Mar 22, 2011, 12:23:41 PM3/22/11
to sy...@googlegroups.com
Hi.

This would be useful, but would be very easy to implement.

> 2. Implement case wise methods for expressions depending on
> parameters.
> e.g. Solve ODE containing constant parameters
> diff(f(r),r)=a*f(r)+b*r+c
>
> has two significantly different solutions
> f(r)=C1*exp(a*r)-b*r/a-(b+a*c)/a^2 if a != 0
> f(r)=b*r^2/2+c*r+C1 if a = 0
>
> where r - independent variable, f - dependent variable, a, b, c -
> arbitrary constants
> This problems become extremely painful, when we have bunch of more
> complex equations and expressions. Unfortunately there are no
> solutions in commercial CAS, such as Maple, Mathematica and MatLab as
> well as in open source such as Maxima and Sage. Actually Symbolic
> Tools Box (former MuPad) in MatLab tried to solve the second problem,
> but the solution does not work well. Mentioned problems are connected
> with each other and with improvement of pattern matching problem in
> Sympy. I have complete solution for Maple and porting it to
> Mathematica. I think it won't be a problem to implement this algorithm
> in Sympy.

This would be useful, I think, though it's a difficult problem to solve in general. But something like this would allow us to solve Sturm-Liouville problems and hence improve the PDE solver too, I think.

>
> Also I want to concentrate attention on some small problems, solution
> of which can improve usability of Sympy
> e.g. It is possible to simplify usage of dsolve function in case when
> dependent and independent variables are obvious.
> The equation
> eq=diff(y,x)+a*y+b*x+c
> has y as dependent variable and x as independent, so it is better to
> write
> dsolve(eq)
> The solution is complete (as patch for Sage, but it can be easily
> adopt to Sympy).

This would also be easy to implement.

>
> I think that it can be interesting to implement this algorithms in
> Sympy in terms of the GSoC project.
>
> If you are interested in my proposal please contact me and I will send
> you precise plan and if not, I will be glad to participate in one of
> the proposed projects.
>
> Best regards,
> Yuri Karadzhov

The first and third item would be useful to have, but they are not really big enough projects for a summer of code. The second one could be, though. I would need to see a more detailed plan on what you plan to implement to see if it is big enough.

Aaron Meurer

Yuri Karadzhov

unread,
Mar 23, 2011, 8:49:10 AM3/23/11
to sympy
> The first and third item would be useful to have, but they are not really big enough projects for a summer of code. The second one could be, though. I would need to see a more detailed plan on what you plan to implement to see if it is big enough.
>
> Aaron Meurer

Actually it was one idea which include three smaller ones because they
are connected with each other. The rough plan of implementation:

1. Implement pattern matching functionality. Function like Maple
indets which can return the list of subexpressions of given type from
given expression is required.

e.g. indets(f(x)+2*x+sin(y+cos(t)),'function')
should return the list
f(x), sin(y+cos(t)), cos(t)

This immediately give us the solution of the third problem (concerned
with dsolve)

2. Implement function which return minimal list of linearly
independent functions of one variable form given one.

e.g. linind(cos(t+1), sin(t), cos(t))
should return
sin(t), cos(t)

This helps to solve the first problem.

3. Then singular function should be implemented. This function should
return values of parameters which make given expression singular.

e.g. singular(tan(c)*y/(d*(a+b*x)),(a,b,c,d))
should return
(a=0, b=0),(c=Pi/2+Pi*N_1)

This helps to implement parametrizer.

4. Implement parametrizer casemap which do the require operation
parameter-wise

e.g. casemap(dsolve, diff(f(r),r)=a*f(r)+b*r+c, (a, b, c))
should return
(f(r)=C_1*exp(a*r)-b*r/a-(b+a*c)/a^2 , a!=0), (f(r)=b*r^2/2+c*r+C_1,
a=0)
the same method can be used for rank calculation using determinant
method because
A=Matrix((1, x), (1, 1))
casemap(det, Inverse(A), x)
should return
(1/(1-x), x!=1), (infinity, x=1)

This solve the second problem, but it's assumed that ODE module is
able to solve ODE's without checking of parameters. If it's not — the
improvement of ODE module should be done first.

This idea is not obligatory and if you need improvements of ODE or PDE
module or anything else, I will be glad to help.

Mateusz Paprocki

unread,
Mar 23, 2011, 12:33:29 PM3/23/11
to sy...@googlegroups.com
Hi,

On 23 March 2011 13:49, Yuri Karadzhov <yuri.ka...@gmail.com> wrote:
> The first and third item would be useful to have, but they are not really big enough projects for a summer of code.  The second one could be, though.  I would need to see a more detailed plan on what you plan to implement to see if it is big enough.
>
> Aaron Meurer

Actually it was one idea which include three smaller ones because they
are connected with each other. The rough plan of implementation:

1. Implement pattern matching functionality. Function like Maple
indets which can return the list of subexpressions of given type from
given expression is required.

e.g. indets(f(x)+2*x+sin(y+cos(t)),'function')
should return the list
f(x), sin(y+cos(t)), cos(t)

This actually can be solved with SymPy already:

In [1]: var('t')
Out[1]: t

In [2]: (f(x)+2*x+sin(y+cos(t))).atoms(Function)
Out[2]: set(cos(t), f(x), sin(y + cos(t)))
 

This immediately give us the solution of the third problem (concerned
with dsolve)

2. Implement function which return minimal list of linearly
independent functions of one variable form given one.

e.g. linind(cos(t+1), sin(t), cos(t))
should return
sin(t), cos(t)

This helps to solve the first problem.

3. Then singular function should be implemented. This function should
return values of parameters which make given expression singular.

e.g. singular(tan(c)*y/(d*(a+b*x)),(a,b,c,d))
should return
(a=0, b=0),(c=Pi/2+Pi*N_1)

This is interesting. Have you looked into sympy.solvers and checked what was already done in this direction and what more has to be done?
 

This helps to implement parametrizer. 

4. Implement parametrizer casemap which do the require operation
parameter-wise

e.g. casemap(dsolve, diff(f(r),r)=a*f(r)+b*r+c, (a, b, c))
should return
(f(r)=C_1*exp(a*r)-b*r/a-(b+a*c)/a^2 , a!=0), (f(r)=b*r^2/2+c*r+C_1,
a=0)
the same method can be used for rank calculation using determinant
method because
A=Matrix((1, x), (1, 1))
casemap(det, Inverse(A), x)
should return
(1/(1-x), x!=1), (infinity, x=1)

This solve the second problem, but it's assumed that ODE module is
able to solve ODE's without checking of parameters. If it's not — the
improvement of ODE module should be done first.

This idea is not obligatory and if you need improvements of ODE or PDE
module or anything else, I will be glad to help.

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sympy?hl=en.


Mateusz

Yuri Karadzhov

unread,
Mar 23, 2011, 1:55:09 PM3/23/11
to sympy
Great! The pattern matching ability is the basis of any CAS. If it is
done I can do a lot more on parametrization and so on. Than you for
your advise, now I play around with sympy and after it I'm going to
look into code more precisely.

Aaron S. Meurer

unread,
Mar 23, 2011, 3:26:18 PM3/23/11
to sy...@googlegroups.com

On Mar 23, 2011, at 6:49 AM, Yuri Karadzhov wrote:

>> The first and third item would be useful to have, but they are not really big enough projects for a summer of code. The second one could be, though. I would need to see a more detailed plan on what you plan to implement to see if it is big enough.
>>
>> Aaron Meurer
>
> Actually it was one idea which include three smaller ones because they
> are connected with each other. The rough plan of implementation:
>
> 1. Implement pattern matching functionality. Function like Maple
> indets which can return the list of subexpressions of given type from
> given expression is required.
>
> e.g. indets(f(x)+2*x+sin(y+cos(t)),'function')
> should return the list
> f(x), sin(y+cos(t)), cos(t)
>
> This immediately give us the solution of the third problem (concerned
> with dsolve)
>
> 2. Implement function which return minimal list of linearly
> independent functions of one variable form given one.
>
> e.g. linind(cos(t+1), sin(t), cos(t))
> should return
> sin(t), cos(t)

Do you know of an efficient algorithm to compute this? I know that it can be done, since the set is finite and the wronskian will tell you if it a set is linearly independent or not, but it seems that a naive implementation would have poor asymptotic (and actual) performance.

>
> This helps to solve the first problem.
>
> 3. Then singular function should be implemented. This function should
> return values of parameters which make given expression singular.
>
> e.g. singular(tan(c)*y/(d*(a+b*x)),(a,b,c,d))
> should return
> (a=0, b=0),(c=Pi/2+Pi*N_1)
>
> This helps to implement parametrizer.
>
> 4. Implement parametrizer casemap which do the require operation
> parameter-wise
>
> e.g. casemap(dsolve, diff(f(r),r)=a*f(r)+b*r+c, (a, b, c))
> should return
> (f(r)=C_1*exp(a*r)-b*r/a-(b+a*c)/a^2 , a!=0), (f(r)=b*r^2/2+c*r+C_1,
> a=0)
> the same method can be used for rank calculation using determinant
> method because
> A=Matrix((1, x), (1, 1))
> casemap(det, Inverse(A), x)
> should return
> (1/(1-x), x!=1), (infinity, x=1)

This could be a useful function. Probably the new assumptions could help it out (though sadly they are not fully implemented yet).

Aaron Meurer

>
> This solve the second problem, but it's assumed that ODE module is
> able to solve ODE's without checking of parameters. If it's not — the
> improvement of ODE module should be done first.
>
> This idea is not obligatory and if you need improvements of ODE or PDE
> module or anything else, I will be glad to help.
>

Yuri Karadzhov

unread,
Mar 24, 2011, 8:01:34 AM3/24/11
to sympy
The Wronskian method can be avoided so the required test can be
reduced to linear algebra problem Ax=0, where A - is a constant matrix
and x - is unknown vector.

atoms has some problems but seems to work pretty well.

wiki page of the project https://github.com/sympy/sympy/wiki/GSoC-2011-Application-Yuri-Karadzhov

I need some feedback to get started

Aaron S. Meurer

unread,
Mar 24, 2011, 12:22:47 PM3/24/11
to sy...@googlegroups.com
Things look good so far. I would include, for example, a description of how you can reduce it to Ax=0.

Also, you might find that you have to improve some simplification algorithms to solve Ax=0, because the present ones will not always be able to reduce large expressions to 0 (especially ones containing trigonometric functions).

Aaron Meurer

Yuri Karadzhov

unread,
Mar 26, 2011, 10:46:28 AM3/26/11
to sympy
> This actually can be solved with SymPy already:
>
> In [1]: var('t')
> Out[1]: t
>
> In [2]: (f(x)+2*x+sin(y+cos(t))).atoms(Function)
> Out[2]: set(cos(t), f(x), sin(y + cos(t)))

In [97]: var('t')
Out[97]: t

In [98]: (f(x)+2*x+sin(y+cos(t))).atoms(Function)
Out[98]: set(f(x), sin(y + cos(t)))

So it can't

Yuri Karadzhov

unread,
Mar 26, 2011, 10:53:33 AM3/26/11
to sympy
On Mar 24, 6:22 pm, "Aaron S. Meurer" <asmeu...@gmail.com> wrote:
> Things look good so far.  I would include, for example, a description of how you can reduce it to Ax=0.
>
> Also, you might find that you have to improve some simplification algorithms to solve Ax=0, because the present ones will not always be able to reduce large expressions to 0 (especially ones containing trigonometric functions).  
>
> Aaron Meurer
>
> On Mar 24, 2011, at 6:01 AM, Yuri Karadzhov wrote:

A - is constant matrix, x - is constant vector. I there a problem in
linear algebra module???

the idea is simple yet realization is much harder.

by default f1(t),...,fn(t) - linearly dependent if there exist
coefficients x1,...,xn : x1^2+...+xn^2!=0
and x1*f1(t)+...+xn*fn(t)=0

if you choose n good points t0,...,tn you will have linear system Ax=0

the only problem is - to choose "good" points, but it is solvable.

Aaron S. Meurer

unread,
Mar 26, 2011, 2:20:02 PM3/26/11
to sy...@googlegroups.com
This is a bug. Can you open an issue for it?

Aaron Meurer

Aaron S. Meurer

unread,
Mar 26, 2011, 2:20:49 PM3/26/11
to sy...@googlegroups.com
Ah, I see. I didn't know that A would be a constant Matrix. Still, if you are simplifying something containing things like sin(3), that will still require some symbolic simplification.

Aaron Meurer

Yuri Karadzhov

unread,
Mar 26, 2011, 7:07:38 PM3/26/11
to sympy
It works, I made a mistake with sympy version

Yuri Karadzhov

unread,
Mar 26, 2011, 8:41:35 PM3/26/11
to sympy
Do you know about this bug?

a=Symbol('a')

In [47]: integrate(1/(x**2+a**2))
Out[47]: 0

In [48]: integrate(1/(x**2+a**2),x)
Out[48]: 0

Aaron S. Meurer

unread,
Mar 26, 2011, 9:25:07 PM3/26/11
to sy...@googlegroups.com
Yes, see issue 2150. This has been fixed in my integration3 branch:

In [2]: integrate(1/(x**2 + a**2), x)
Out[2]:
⎽⎽⎽⎽ ⎛ ⎽⎽⎽⎽⎞ ⎽⎽⎽⎽ ⎛ ⎽⎽⎽⎽⎞
╱ -1 ⎜ 2 ╱ -1 ⎟ ╱ -1 ⎜ 2 ╱ -1 ⎟
╱ ── ⋅log⎜x + a ⋅ ╱ ── ⎟ ╱ ── ⋅log⎜x - a ⋅ ╱ ── ⎟
╱ 2 ⎜ ╱ 2 ⎟ ╱ 2 ⎜ ╱ 2 ⎟
╲╱ a ⎝ ╲╱ a ⎠ ╲╱ a ⎝ ╲╱ a ⎠
─────────────────────────────── - ───────────────────────────────
2 2

Unfortunately, this fix did not make it to my integration3-backport branch, but I think I will bisect the code and see if I can cherry-pick the correcting commit, since this is a wrong result.

Aaron Meurer

Reply all
Reply to author
Forward
0 new messages