Re: [sympy] Faster symbolics

2022-04-15 Thread Isuru Fernando
Hi Oscar,

Here's a few things that are different in SymEngine than SymPy.

> As an example it would be trivial in SymPy to make substitutions
involving large expressions and many replacements much faster with a
small redesign. The problem though is backwards compatibility: each
expression class can implement its own _eval_subs method so for
backwards compatibility the subs implementation must recurse in the
same slow way once throughout the whole tree for each replacement that
is to be made. (There are ways to work around this but the design
makes it harder than it should be.)

In SymEngine, classes do not have such a method and therefore cannot
extend for eg: subs function.
However the subs function itself (SubsVisitor class technically) can be
extended.

> This is a small example of a more general problem. Using classes means
you have to use the interfaces of the class which means that efficient
algorithms needing something not provided by that public interface are
impossible. Even worse both SymPy and SymEngine allow the
*constructors* of those classes to do nontrivial work without
providing any good way to override that. This means that you can't
even represent a symbolic expression without allowing arbitrary code
execution: it's impossible to optimize higher-level algorithms if you
have so little control over execution from the outside.

No, SymEngine does not do anything in the constructor of the C++ class
itself. (For eg: class "Add"). We have different functions (For eg:
function "add")
that do complicated functionality to create the C++ class. A user is allowed
to create the C++ class directly and we assume that the data structure that
the
user passed is internally consistent in Release mode and we check user
input in Debug mode. This allows the user to do low level optimizations
when they know that going through the complicated function is unnecessary.

> There are ways that this can be improved in both SymPy and SymEngine
but I also think that for many important operations the basic design
used by these is limiting in a big-O sense: the design constrains what
algorithms can be used. SymEngine is faster than SymPy in a brute
force sense by using C++ rather than Python but it would be possible
to make something both faster and more flexible if a different design
was used at a basic level.

I disagree about this in SymEngine. For eg: SymPy's extensibility
of classes prevents optimizations that SymEngine can do because symengine
doesn't have an equivalence of `_eval_subs` or similar.
Some of the optimizations in SymEngine like Aaron said leads to better
big-O complexities. i.e. the ratio between the two modules is not always a
constant as input size increases.

Isuru



On Thu, Apr 14, 2022 at 1:26 PM Oscar Benjamin 
wrote:

> On Thu, 14 Apr 2022 at 18:16, Tirthankar Mazumder
>  wrote:
> >
> > On Thursday, April 14, 2022 at 10:04:28 PM UTC+5:30 Oscar wrote:
> >>
> >> On Tue, 12 Apr 2022 at 19:26, Matthias Köppe 
> wrote:
> >>
> >> > - status and plans regarding SymEngine
> >>
> >> I don't know about the status of SymEngine. I can't say that I can see
> >> any significant work happening on the SymPy side to integrate
> >> SymEngine any further with SymPy. My personal view is that for faster
> >> symbolics a different approach is needed in general but SymEngine
> >> seems to have the same design flaws as SymPy itself in that respect.
> >
> > Hi, as someone who is relatively new to the SymPy + SymEngine project,
> and wants to work on SymEngine as a part of their GSoC, I would appreciate
> it if you could elaborate a bit on what design flaws you are referring to.
>
> The basic design of the way that symbolic expressions are represented
> in SymPy and SymEngine is through the use of classes to represent
> different types of expression e.g. there is a class Pow and an
> expression like x**y is represented by an instance of that class
> created as Pow(x, y).
>
> Using classes like this makes it hard to extend the system with new
> types of symbolic expression e.g. with SymEngine you can't make a new
> kind of symbolic expression without writing C++ code so if you are
> using SymEngine from Python then it isn't extensible. With SymPy you
> could at least make your own symbolic expression class in Python but
> then it still doesn't work so well because there are so many places in
> the codebase where particular types of expression are special-cased
> meaning that any new symbolic expression type cannot be handled by
> functions like solve, integrate etc.
>
> The other problem with using classes is that it means that the basic
> data structure that is used to represent expressions is fixed from the
> outside. In SymPy and SymEngine that data structure is a tree and all
> algorithms recurse through that tree. More efficient data structures
> for some given operation can't be used because the implementation of
> each symbolic expression type requires that you always use instances
> of the class meaning that 

[sympy] Season of Docs

2022-04-15 Thread Aaron Meurer
SymPy has been accepted into Google's Season of Docs program again this year.

This year, Jeremy Monat will be working with SymPy to improve the
solvers documentation. You can find more information about the project
at 
https://github.com/sympy/sympy/wiki/Season-of-Docs-2022-Organization-Application.

Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6JH2Oam-3CCBWABbpqvDfPNiXRw4LsY0CyeGvsChrpUDQ%40mail.gmail.com.


Re: [sympy] Creating a built in function

2022-04-15 Thread Aaron Meurer
On Fri, Apr 15, 2022 at 5:01 PM David Bailey  wrote:
>
> Thanks again for a near instantaneous reply!
>
> On 15/04/2022 23:39, Aaron Meurer wrote:
> >
> > You are calling arg[0], but arg is already the argument of the
> > function. The [0] is typically only used when you have *args to accept
> > an arbitrary number of arguments and you want to get the first one.
>
> OK - that has fixed it after I corrected another minor error!
>
> Just one possible use for this mechanism would be to  create a function
> gamma() (say) which would contain all the original code from gamma in
> SymPy, and then add calls to print to clarify how it works. I assume
> that the line
>
> import gamma from gamma
>
> would replace the official version with this modification and everything
> would work as expected?

Yes, it ought to.

Aaron Meurer

>
> David
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/b3d0f8e3-95ca-26e1-1021-9e91995fd883%40dbailey.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2B-KZEZjmXg40G4b%3DqzEcuxxKUdRmZ3L62F5jj4S5Dqdw%40mail.gmail.com.


Re: [sympy] Discussion regarding the GSOC project - Benchmarks and performance

2022-04-15 Thread Oscar Benjamin
On Fri, 15 Apr 2022 at 21:46, Aaron Meurer  wrote:
>
> On Fri, Apr 15, 2022 at 6:54 AM Oscar Benjamin
>  wrote:
> >
> > 1. The benchmarks are based on ASV which is awkward to use. It's
> > unnecessarily difficult even just to run a single benchmark. A better
> > framework should be found.
>
> Just a small note on this point. I've done a small bit of research on
> this myself and have come up with nothing. It's possible something
> better does exist out there, but it's also likely that it doesn't and
> if we want something better we will have to write it ourselves.

Indeed. The best alternative I found was pytest-benchmark:
https://pypi.org/project/pytest-benchmark/

I didn't get very far with evaluating it but I can say that at least
it makes it easy to run selected subsets of the benchmarks.

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxQQ23dc%3Dx%3DhJ3JjKkYxOK3XAx-WXTEB_22qGrQ7YYmhpQ%40mail.gmail.com.


Re: [sympy] Creating a built in function

2022-04-15 Thread David Bailey

Thanks again for a near instantaneous reply!

On 15/04/2022 23:39, Aaron Meurer wrote:


You are calling arg[0], but arg is already the argument of the
function. The [0] is typically only used when you have *args to accept
an arbitrary number of arguments and you want to get the first one.


OK - that has fixed it after I corrected another minor error!

Just one possible use for this mechanism would be to  create a function 
gamma() (say) which would contain all the original code from gamma in 
SymPy, and then add calls to print to clarify how it works. I assume 
that the line


import gamma from gamma

would replace the official version with this modification and everything 
would work as expected?


David


--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b3d0f8e3-95ca-26e1-1021-9e91995fd883%40dbailey.co.uk.


Re: [sympy] Creating a built in function

2022-04-15 Thread Aaron Meurer
On Fri, Apr 15, 2022 at 3:40 PM David Bailey  wrote:
>
> Thanks for such an amazingly fast and detailed reply!
>
> On 15/04/2022 21:32, Aaron Meurer wrote:
> >
> > Yes, you can have it separate. The location of a function in the code
> > has no bearing on its behavior.
> That is good!
> > When you run 'import bailey' then 'bailey' will be the module (because
> > you called your file bailey.py). To get the function do
> >
> > from bailey import bailey
>
> I tried that too, but I got:
>
>  >>> bailey(a+3)
> Traceback (most recent call last):
>File "", line 1, in 
>File "C:\PythonSystem\lib\site-packages\sympy\core\cache.py", line
> 70, in wrapper
>  retval = cfunc(*args, **kwargs)
>File "C:\PythonSystem\lib\site-packages\sympy\core\function.py", line
> 476, in __new__
>  result = super().__new__(cls, *args, **options)
>File "C:\PythonSystem\lib\site-packages\sympy\core\cache.py", line
> 70, in wrapper
>  retval = cfunc(*args, **kwargs)
>File "C:\PythonSystem\lib\site-packages\sympy\core\function.py", line
> 288, in __new__
>  evaluated = cls.eval(*args)
>File "C:\SymPyProject\bailey.py", line 9, in eval
>  # Value at zero
> TypeError: 'Add' object is not subscriptable

You are calling arg[0], but arg is already the argument of the
function. The [0] is typically only used when you have *args to accept
an arbitrary number of arguments and you want to get the first one.

Aaron Meurer

>
> >
> >> Alternatively I tried:
> >>
> >>   >>> (a+3).bailey(1)
> >> Traceback (most recent call last):
> >> File "", line 1, in 
> >> AttributeError: 'Add' object has no attribute 'bailey'
> > You can't add new methods to existing SymPy objects. The first way you
> > tried is the correct way to access your bailey function.
> >
> >> I admit to being fairly confused at this level! What I would like to
> >> know is:
> >>
> >> 1)   Can I experiment in this way without actually adding files to
> >> SymPy itself or modifying anything there already?
> >>
> >> 2)   I would expect to get back a function call: bailey(a+3) or
> >> perhaps the answer 1.
> > The function as you've written it will just return 1. If you want a
> > symbolic answer, eval() needs to return None (which is also the same
> > as not returning anything).
> >
> > Since your eval() always returns something, the function will never be
> > symbolic. It is effectively no different from a normal Python function
> >
> > def bailey(x):
> >  if x == 0:
> >  return 0
> >  else:
> >  return 1
>
> To be absolutely clear, the actual content of the function is just junk
> at this point - I am just trying to get the basic mechanism to work.
>
> David
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/2e6860c8-b1dd-fc37-9fa5-5bfa4d74b8d3%40dbailey.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LM1Oeu9oCRJnK5D-j5dyacskkRmiVNacrH9zOGZH1n-w%40mail.gmail.com.


Re: [sympy] Creating a built in function

2022-04-15 Thread David Bailey

Thanks for such an amazingly fast and detailed reply!

On 15/04/2022 21:32, Aaron Meurer wrote:


Yes, you can have it separate. The location of a function in the code
has no bearing on its behavior.

That is good!

When you run 'import bailey' then 'bailey' will be the module (because
you called your file bailey.py). To get the function do

from bailey import bailey


I tried that too, but I got:

>>> bailey(a+3)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\PythonSystem\lib\site-packages\sympy\core\cache.py", line 
70, in wrapper

    retval = cfunc(*args, **kwargs)
  File "C:\PythonSystem\lib\site-packages\sympy\core\function.py", line 
476, in __new__

    result = super().__new__(cls, *args, **options)
  File "C:\PythonSystem\lib\site-packages\sympy\core\cache.py", line 
70, in wrapper

    retval = cfunc(*args, **kwargs)
  File "C:\PythonSystem\lib\site-packages\sympy\core\function.py", line 
288, in __new__

    evaluated = cls.eval(*args)
  File "C:\SymPyProject\bailey.py", line 9, in eval
    # Value at zero
TypeError: 'Add' object is not subscriptable




Alternatively I tried:

  >>> (a+3).bailey(1)
Traceback (most recent call last):
File "", line 1, in 
AttributeError: 'Add' object has no attribute 'bailey'

You can't add new methods to existing SymPy objects. The first way you
tried is the correct way to access your bailey function.


I admit to being fairly confused at this level! What I would like to
know is:

1)   Can I experiment in this way without actually adding files to
SymPy itself or modifying anything there already?

2)   I would expect to get back a function call: bailey(a+3) or
perhaps the answer 1.

The function as you've written it will just return 1. If you want a
symbolic answer, eval() needs to return None (which is also the same
as not returning anything).

Since your eval() always returns something, the function will never be
symbolic. It is effectively no different from a normal Python function

def bailey(x):
 if x == 0:
 return 0
 else:
 return 1


To be absolutely clear, the actual content of the function is just junk 
at this point - I am just trying to get the basic mechanism to work.


David

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2e6860c8-b1dd-fc37-9fa5-5bfa4d74b8d3%40dbailey.co.uk.


Re: [sympy] Discussion regarding the GSOC project - Benchmarks and performance

2022-04-15 Thread Aaron Meurer
On Fri, Apr 15, 2022 at 6:54 AM Oscar Benjamin
 wrote:
>
> On Fri, 11 Mar 2022 at 14:53, praneeth ratna  wrote:
> >
> > Hi all,
> >
> > As mentioned in the project description here , 
> > https://github.com/sympy/sympy/wiki/GSoC-Ideas#benchmarks-and-performance , 
> > the sympy_benchmarks misses some benchmarks which are needed to be shifted 
> > fro the sympy main repo. Also the sympy_benchmarks misses benchmarks for 
> > combinatorics, series , stats and many other modules which can be 
> > added.(Please correct me here)
> > Also I did not have a clear understanding of what the new implementation of 
> > benchmarks do and how it should be done.
>
> I think that with some of the project ideas the intention is not
> necessarily that anyone has a clear idea of exactly what should be
> done but that someone wanting to do a project would do some research
> themselves to come up with an idea.
>
> In relation to benchmarks the immediate issues I see are:
>
> 1. Some old benchmarking code is in the main repo and should be moved
> over to the benchmarks repo.
> 2. The benchmarks repo is currently broken because some test fails so
> no PR can be merged there until that is fixed.
> 3. The benchmarks are affected by caching which means that many of the
> timings reported are completely unrepresentative.
>
> Bigger issues:

For me the biggest issue with the benchmarks right now is that they
aren't very effective towards actually making SymPy faster, and
preventing it from getting slower (which are related but distinct
things). So any ideas suggested for a benchmarking project should, in
my opinion, be somehow linked to this end goal. This includes things
like

- Making the benchmarks easier to run (including running them automatically)
- Making it easier to add benchmarks
- Making it easier to interpret the results of benchmarks
- Making the benchmarks suite itself more likely to catch performance
regressions

>
> 1. The benchmarks are based on ASV which is awkward to use. It's
> unnecessarily difficult even just to run a single benchmark. A better
> framework should be found.

Just a small note on this point. I've done a small bit of research on
this myself and have come up with nothing. It's possible something
better does exist out there, but it's also likely that it doesn't and
if we want something better we will have to write it ourselves.

> 2. The benchmarks mostly only measure things that are already quite
> fast because otherwise they would take too long to run. To guide
> future improvements we really need benchmarks for things that are
> currently slow.
> 3. The benchmarks are too tied up with sympy itself. I would rather
> have an independent benchmark suite that collects good examples and
> can be used by other projects as well. For this you need benchmarks
> that are language agnostic and not simply written in sympy code. (I
> also think it would be better if a lot of the test suite was like this
> as well.)
> 4. The things that are tested in the benchmarks are a bit random. It
> would be better to focus on core features like differentiation,
> integration, linear algebra, polynomials, solvers, numerical
> evaluation.
>
> A big part of the difficulty in making good benchmarks is that it
> really requires having some understanding of what are the core
> operations that should or could be made faster.

This is true, but there's also enough work to be done on the
benchmarking tooling itself that most of the work could focus on that,
rather than necessarily adding too many actual benchmarks, which could
be done later.

Aaron Meurer

>
> --
> Oscar
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAHVvXxRPFjmZBrkJpusB-WER3V%3DMd%2B%2BP_X8HKAuHHJr3PPXe7Q%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BseAxDJQpMOXiubj7c_2sDJFRJp2D_8LVVKE6WOLpOoQ%40mail.gmail.com.


Re: [sympy] Creating a built in function

2022-04-15 Thread Aaron Meurer
On Fri, Apr 15, 2022 at 2:23 PM David Bailey  wrote:
>
> Dear Group,
>
> I would like to understand the workings of SymPy a little better, and to
> that end, I thought it would be instructive to create a trivial 'special
> function' that had some or all of the properties of the SymPy in-built
> functions. The following link was helpful:
>
> https://github.com/Shekharrajak/sympy/wiki/About-implementing-special-functions

This is a link to someone's fork of the wiki. The actual page is here
https://github.com/sympy/sympy/wiki/Development-Tips-:-About-implementing-special-functions

>
> However, I could not tell from that whether I could have the new
> function stored separately from the directory tree holding the SymPy
> software. I'd much prefer it if I could experiment without disturbing
> the SymPy software at all.

Yes, you can have it separate. The location of a function in the code
has no bearing on its behavior.

>
> I decided to call the function bailey, so following the recipe in the
> above link, I created a file bailey.py in a directory outside the SymPy
> tree, and to test it my calling Python from that directory, as follows:
>
> from sympy.core.function import Function
> class bailey(Function):
> """
> The experimental function
> """
> nargs=1
> @classmethod
> def eval(cls, arg):
> # This body does nothing useful at all
>  z=arg[0]
>  if z is S.Zero:
>  return S.Zero
>  else: return 1
>
> Now I tried to use this module:
>
>  >>> import sympy
>  >>> import bailey
>
>  >>> bailey(a+3)
> Traceback (most recent call last):
>File "", line 1, in 
> TypeError: 'module' object is not callable

When you run 'import bailey' then 'bailey' will be the module (because
you called your file bailey.py). To get the function do

from bailey import bailey

>
> Alternatively I tried:
>
>  >>> (a+3).bailey(1)
> Traceback (most recent call last):
>File "", line 1, in 
> AttributeError: 'Add' object has no attribute 'bailey'

You can't add new methods to existing SymPy objects. The first way you
tried is the correct way to access your bailey function.

>
> I admit to being fairly confused at this level! What I would like to
> know is:
>
> 1)   Can I experiment in this way without actually adding files to
> SymPy itself or modifying anything there already?
>
> 2)   I would expect to get back a function call: bailey(a+3) or
> perhaps the answer 1.

The function as you've written it will just return 1. If you want a
symbolic answer, eval() needs to return None (which is also the same
as not returning anything).

Since your eval() always returns something, the function will never be
symbolic. It is effectively no different from a normal Python function

def bailey(x):
if x == 0:
return 0
else:
return 1

>
> 3)   Is there a place where this is described more completely?

I think the best docs right now are at
https://docs.sympy.org/latest/modules/core.html#id55. I will probably
end up writing something better at some point as this an important
thing that is somewhat underdocumented right now.

Aaron Meurer

>
> Thanks,
>
> David
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/04eaf831-b1a1-6f1c-68b7-2ae9a7d60c2e%40dbailey.co.uk.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6LU80JDR7XJBFK%2BVg0eJKeX1BxCLs5LzEfNk2jafhQxVQ%40mail.gmail.com.


[sympy] Creating a built in function

2022-04-15 Thread David Bailey

Dear Group,

I would like to understand the workings of SymPy a little better, and to 
that end, I thought it would be instructive to create a trivial 'special 
function' that had some or all of the properties of the SymPy in-built 
functions. The following link was helpful:


https://github.com/Shekharrajak/sympy/wiki/About-implementing-special-functions

However, I could not tell from that whether I could have the new 
function stored separately from the directory tree holding the SymPy 
software. I'd much prefer it if I could experiment without disturbing 
the SymPy software at all.


I decided to call the function bailey, so following the recipe in the 
above link, I created a file bailey.py in a directory outside the SymPy 
tree, and to test it my calling Python from that directory, as follows:


from sympy.core.function import Function
class bailey(Function):
   """
   The experimental function
   """
   nargs=1
   @classmethod
   def eval(cls, arg):
   # This body does nothing useful at all
    z=arg[0]
    if z is S.Zero:
    return S.Zero
    else: return 1

Now I tried to use this module:

>>> import sympy
>>> import bailey

>>> bailey(a+3)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'module' object is not callable

Alternatively I tried:

>>> (a+3).bailey(1)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'Add' object has no attribute 'bailey'

I admit to being fairly confused at this level! What I would like to 
know is:


1)   Can I experiment in this way without actually adding files to 
SymPy itself or modifying anything there already?


2)   I would expect to get back a function call: bailey(a+3) or 
perhaps the answer 1.


3)   Is there a place where this is described more completely?

Thanks,

David




--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/04eaf831-b1a1-6f1c-68b7-2ae9a7d60c2e%40dbailey.co.uk.


[sympy] GSOC'22 Project Discussion: Bond Graph tools

2022-04-15 Thread Varenyam Bhardwaj
Hello all,

I am Varenyam Bhardwaj, Currently pursing for Btech in Electronics and 
Computer Engineering at Thapar Institute of Engineering and Technology.
I have formulated a proposal for the implementation of Bond Graph tools in 
sympy.

Due to running low on time, I prioritized formulating the proposal before 
making any proper contribution to sympy. I hope it is okay for me to 
complete the patch requirement after the deadline of GSOC. 

I might have missed a lot of things in the milestone section which I would 
like to clarify with the potential mentor for the project. 
Link to Proposal: 
https://docs.google.com/document/d/1uHBSyw9f0uBmVP1gck6D_Ld0j3PP-LktUFHqD6U2WVw/edit?usp=sharing

Suggestions for improvement are appreciated.

Thanking you,
Yours Truly,
Varenyam Bhardwaj

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/6a1dcb3f-33b7-4436-b69e-e57aa8dce785n%40googlegroups.com.


Re: [sympy] Re: GSoC 2022:Simplex method for linear programming.

2022-04-15 Thread Oscar Benjamin
> Den tors 14 apr. 2022 19:54Qijia Liu  skrev:
>>
>> SciPy has simplex method implemented. Do we need to re-implement it in SymPy?
>>
On Fri, 15 Apr 2022 at 07:37, Oscar Gustafsson
 wrote:
>
> There are two (I think, at least one) PRs that are not merged that does this. 
> So it would be better to sort one of those out. Iirc there is limiterd work 
> left, like documentation and testing.

The two PRs are here:

https://github.com/sympy/sympy/pull/22389
https://github.com/sympy/sympy/pull/21687

The first PR adds Fourier-Motzkin elimination which is potentially
more powerful than linear programming because you could use it to do
some reductions in a system of inequalities that is not entirely
linear i.e. you could use it to eliminate a few symbols that appear
linearly even if others appear nonlinearly. It has extremely bad
asymptotic complexity for large systems of linear inequalities though
(and in the PR only linear inequalities can be handled).

The other PR adds linear programming based on a simplex method. It
seems to be reasonably efficient but can be optimised. A suggestion I
made there makes it about 30x faster for large inputs and I think it
could be faster still if implemented at the DomainMatrix level. I'd
like to see that PR finished but it looks as if the author
underestimated how much more work is needed beyond getting together a
basic working implementation.

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxQuy%3DLnU5TEdphK2Nm_VSCXtrvY845rk251V_Tw5Tiipw%40mail.gmail.com.


Re: [sympy] Re: Classical Mechanics : Forces and Torques

2022-04-15 Thread praneeth ratna
Hi Jason,

I have made a draft of my proposal 
https://docs.google.com/document/d/13hmPNM2JdEhnMhctH5hsbuTOnA0916WUvrFOzvb98ig/edit?pli=1,
 
Most of examples were added from here:   
https://github.com/moorepants/learn-multibody-dynamics/pull/57, could you 
please provide your feedback on my proposal since there is only 4 days left 
for deadline.

Thanks,
Praneeth

On Monday, April 11, 2022 at 10:51:13 AM UTC+5:30 praneeth ratna wrote:

> Jason,
>
> I'm sorry for mailing again but I am not yet sure of the implementation - 
> 'We need valid mathematical descriptions of a variety of common forces that 
> will work nicely with our code generators for efficient numerical 
> implementations'. I do not have a clear understanding of how force should 
> be implemented as mentioned by you, could you please help me out here?
>
> Thanks,
> Praneeth
>
> On Saturday, April 9, 2022 at 2:44:50 PM UTC+5:30 praneeth ratna wrote:
>
>> Jason,
>>
>> Thanks for the reply,
>>
>> I have started writing my proposal, But have some queries regarding the 
>> implementation.
>> I have created a new submodule forces.py in sympy.mechanics module and 
>> create force definitons in forces.py. I have included code for one of the 
>> model here:
>> def linear_hooke_contact_model(stiffness, penetration):
>> stiffness = sm.sympify(stiffness)
>> penetration = sm.sympify(penetration)
>> force = stiffness * penetration
>> return [force]
>>
>> Is this the write way of creating the force models, or do we need to 
>> create classes for individual force model? Please correct me here if I'm 
>> wrong
>>
>> Thanks, 
>> Praneeth
>>
>> On Wednesday, April 6, 2022 at 2:09:17 PM UTC+5:30 moore...@gmail.com 
>> wrote:
>>
>>> Praneeth,
>>>
>>> We volunteer our time and will reply when and if we can.
>>>
>>> Your list of forces looks interesting and useful. I recommend reading 
>>> the force related sections of Kane & Levinson 1985, as those would be 
>>> obvious places to take forces ideas from. I'm currently writing a force 
>>> chapter in my book that has some examples (these are still in draft form 
>>> and likely incorrect): 
>>> https://github.com/moorepants/learn-multibody-dynamics/pull/57
>>>
>>> There should be no need for a system or anything from pydy. We need 
>>> valid mathematical descriptions of a variety of common forces that will 
>>> work nicely with our code generators for efficient numerical 
>>> implementations.
>>>
>>> Jason
>>> moorepants.info
>>> +01 530-601-9791 <(530)%20601-9791>
>>>
>>>
>>> On Tue, Apr 5, 2022 at 3:48 PM praneeth ratna  
>>> wrote:
>>>
 Hi jason,

 Could you please provide your feedback on my previous two emails, So 
 that I can start writing my proposal and since there isn't much time left 
 for proposal deadline.

 Thanks,
 Praneeth

 On Monday, April 4, 2022 at 11:38:48 AM UTC+5:30 praneeth ratna wrote:

> Jason,
>
> Regarding the implementation, do you suggest similar to pydy engine? 
> So we also need to  create a System 
>  class similar to 
> the one pydy has? Also could you suggest any sources for some trivial 
> cases 
> of muscle force, actuator force and aerodynamic force models, could you 
> provide feedback on whether the model specified in my previous mail are 
> useful or not, so that i can include them in my proposal.
>
> Thanks,
> Praneeth
> On Monday, March 28, 2022 at 4:22:26 PM UTC+5:30 praneeth ratna wrote:
>
>> Hi jason,
>>
>> I have at present written down the following models:
>>
>>1. Linear hooke contact model 
>>2. Non linear hertz model
>>3. Linear Kelvin-Voigt Contact Model 
>>4. Nonlinear Hunt and Crossley Contact Model 
>>5. Nonlinear Hunt and Crossley Contact Model 
>>6. Nonlinear Flores et al. Contact Model
>>7. multi_mass_spring_damper() 
>>
>> 
>>8. n_link_pendulum_on_cart() 
>>
>> 
>>
>> 7 and 8 are taken from pydy, are they non trivial cases? Also could 
>> you suggest any resources for muscle force, actuator force and 
>> aerodynamic 
>> force models which are useful for the user?
>> I have taken 1 to 6 from the here 
>> https://www.researchgate.net/publication/299604992_Contact_Force_Models_for_Multibody_Dynamics,
>>  
>> are they useful cases?
>>
>> Thanks,
>> Praneeth
>>
>> On Saturday, March 26, 2022 at 1:08:09 PM UTC+5:30 moore...@gmail.com 
>> wrote:
>>
>>> Praneeth,
>>>
>>> Yes we should have a linear spring and damper force that is premade, 
>>> but that is really just a trivial case. The GSoC project should be 
>>> focused 
>>> 

Re: [sympy] Discussion regarding the GSOC project - Benchmarks and performance

2022-04-15 Thread Oscar Benjamin
On Fri, 11 Mar 2022 at 14:53, praneeth ratna  wrote:
>
> Hi all,
>
> As mentioned in the project description here , 
> https://github.com/sympy/sympy/wiki/GSoC-Ideas#benchmarks-and-performance , 
> the sympy_benchmarks misses some benchmarks which are needed to be shifted 
> fro the sympy main repo. Also the sympy_benchmarks misses benchmarks for 
> combinatorics, series , stats and many other modules which can be 
> added.(Please correct me here)
> Also I did not have a clear understanding of what the new implementation of 
> benchmarks do and how it should be done.

I think that with some of the project ideas the intention is not
necessarily that anyone has a clear idea of exactly what should be
done but that someone wanting to do a project would do some research
themselves to come up with an idea.

In relation to benchmarks the immediate issues I see are:

1. Some old benchmarking code is in the main repo and should be moved
over to the benchmarks repo.
2. The benchmarks repo is currently broken because some test fails so
no PR can be merged there until that is fixed.
3. The benchmarks are affected by caching which means that many of the
timings reported are completely unrepresentative.

Bigger issues:

1. The benchmarks are based on ASV which is awkward to use. It's
unnecessarily difficult even just to run a single benchmark. A better
framework should be found.
2. The benchmarks mostly only measure things that are already quite
fast because otherwise they would take too long to run. To guide
future improvements we really need benchmarks for things that are
currently slow.
3. The benchmarks are too tied up with sympy itself. I would rather
have an independent benchmark suite that collects good examples and
can be used by other projects as well. For this you need benchmarks
that are language agnostic and not simply written in sympy code. (I
also think it would be better if a lot of the test suite was like this
as well.)
4. The things that are tested in the benchmarks are a bit random. It
would be better to focus on core features like differentiation,
integration, linear algebra, polynomials, solvers, numerical
evaluation.

A big part of the difficulty in making good benchmarks is that it
really requires having some understanding of what are the core
operations that should or could be made faster.

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxRPFjmZBrkJpusB-WER3V%3DMd%2B%2BP_X8HKAuHHJr3PPXe7Q%40mail.gmail.com.


[sympy] Re: Discussion regarding the GSOC project - Benchmarks and performance

2022-04-15 Thread praneeth ratna
Hi all,

I have already mailed regarding my interest in the project -  Benchmarks 
and performance but have not recieved a reply , could the potential mentor 
please guide me on this project?

Thanks,
Praneeth

On Friday, March 11, 2022 at 8:23:10 PM UTC+5:30 praneeth ratna wrote:

> Hi all,
>
> As mentioned in the project description here , 
> https://github.com/sympy/sympy/wiki/GSoC-Ideas#benchmarks-and-performance 
> , the sympy_benchmarks misses some benchmarks which are needed to be 
> shifted fro the sympy main repo. Also the sympy_benchmarks misses 
> benchmarks for combinatorics, series , stats and many other modules which 
> can be added.(Please correct me here)
> Also I did not have a clear understanding of what the new implementation 
> of benchmarks do and how it should be done.
>
> I'm not sure of the potential mentors for this project since it is not 
> mentioned in Ideas page, so i would request the mentors to guide me on how 
> to move forward in this project.
>
> Thanks,
> Praneeth
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/7dc39bce-c5ad-4ff5-86d1-c49e3c2c5f57n%40googlegroups.com.


Re: [sympy] Re: GSoC 2022:Simplex method for linear programming.

2022-04-15 Thread Oscar Benjamin
On Thu, 14 Apr 2022 at 18:54, Qijia Liu  wrote:
>
> SciPy has simplex method implemented. Do we need to re-implement it in SymPy?

The SciPy implementation only works for floats. It should be possible
to solve linear programming problems at least using exact rational
numbers. Something like this is needed to be able to solve systems of
linear inequalities. That in turn is needed to be able to answer
assumptions queries involving linear inequalities.

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxR6RLHiWCXFhVXRd8ZrAr2rW3diecnT%2BTm8oXoB1XO7tQ%40mail.gmail.com.


Re: [sympy] Re: GSoC 2022:Simplex method for linear programming.

2022-04-15 Thread Oscar Gustafsson
There are two (I think, at least one) PRs that are not merged that does
this. So it would be better to sort one of those out. Iirc there is
limiterd work left, like documentation and testing.

BR Oscar

Den tors 14 apr. 2022 19:54Qijia Liu  skrev:

> SciPy has simplex method implemented. Do we need to re-implement it in
> SymPy?
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/057e821d-03be-40bd-9c20-2f44875a1f55n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAFjzj-%2BcEuLByD0ySYr2ZjCB_0DkUQXbTFgnt32zJhKCi%2BdmQQ%40mail.gmail.com.