Hi Ondrej,

Thank you very much for the reply. As you have seen by now, I fixed the bug
and added some
tests. I'll make a commit using the functions from Pernici's work.

I'll try to prepare a small report about the work currently pushed into
Github so everyone can
get some idea and come up with suggestions for the final tweaks or
cosmetics.

The highest level API for the Diophantine module is the diophantine()
function which was added
somewhat recently. I think we should expose that.

Thank you very much for the efforts taken to review the module.

Regards,
Thilina



On Thu, Aug 29, 2013 at 10:19 PM, Ondřej Čertík <[email protected]>wrote:

> On Thu, Aug 29, 2013 at 12:42 AM, Thilina Rathnayake
> <[email protected]> wrote:
> > Hi Onderj,
> >
> > I hope to work on improving documentation during this week. I added some
> > docstrings
> > to the Sphinx but they need to be improved.
>
> Great plan, thanks.
>
> >
> > I tried to find the bug with 7 and 9. For 7, I did this,
> >
> > In [3]: find_DN(1+2*x+2*x**2+2*y+x*y-2*y**2)
> > Out[3]: (17, -1768)
> >
> > So the original equation can be transformed to the form x**2 - Dy**2 = N
> > with D = 17 and N = -1768
> > We can try to solve this equation by using diop_DN().
> >
> > In [4]: diop_DN(17, -1789)
> > Out[4]: [(298, 73), (-94, -25)]
> >
> > So, internally, diop_DN() return results, I think the problem arises
> when we
> > try to recover
> > the solutions for original equation. I'll give a try to fix this.
>
> Excellent, great job. Please ping me if you either get stuck or
> once the PR is up.
>
> >
> > Mathematica provides lots of results because, they split a given
> solution to
> > two other solutions.
> > Suppose we have (5 + sqrt(3))**n - (5 - sqrt(3))**n, they try to simplify
> > this considering the cases
> > where n is even and odd. After that they add the two simplified
> solutions to
> > the list. Since the
> > solutions returned by the diop_solve() can be complex sometimes, I think
> we
> > will have to go for
> > this approach too.
>
> I see. Very good. I merged Mario's PR, so let's get your #2303 in.
>
> Once everything is in, I'll test your code some more and see how it works.
> In particular I'll test that we can do everything from
> http://reference.wolfram.com/mathematica/tutorial/DiophantineReduce.html.
> I.e. that we get equivalent results for things that we support.
>
> I think we should expose the highest level API to the sympy module itself.
> Should we expose the diop_solve() function or something else?
>
> Ondrej
>
> >
> > I'll try to fix these issues asap.
> >
> > Regards,
> > Thilina
> >
> >
> >
> > On Thu, Aug 29, 2013 at 12:21 AM, Ondřej Čertík <[email protected]
> >
> > wrote:
> >>
> >> Hi Thilina,
> >>
> >> On Wed, Aug 28, 2013 at 1:44 AM, Thilina Rathnayake
> >> <[email protected]> wrote:
> >> > Hi Ondrej,
> >> >
> >> > I finished the last two deliverables(generalized pythagorean equation
> >> > and
> >> > general sum of squares)
> >> > of my project over the weekend and I think now the project is almost
> >> > complete. But before pulling
> >>
> >> Excellent, great work!
> >>
> >> > those new code we have to merge the current PR first. Below is it's
> link
> >> >
> >> > https://github.com/sympy/sympy/pull/2303
> >> >
> >> > To merge this PR we have to merge pernici's PR. Below is the link of
> his
> >> > PR.
> >> >
> >> > https://github.com/sympy/sympy/pull/2307
> >>
> >> Ok, let's get this one in first.
> >>
> >> >
> >> > I reviewed it during the last week and since he has made some
> >> > improvements,
> >> > I am going through it
> >> > once again. I don't think it will take a long time. We can merge it
> >> > afterwards.
> >>
> >> Ok.
> >>
> >> >
> >> > Meanwhile I am looking for new types of equations to add to the
> >> > Diophantine
> >> > module and possible
> >> > improvements in the algorithms used. I found a good book which
> contains
> >> > various types of equations.
> >> >
> >> >
> >> >
> http://books.google.lk/books/about/Diophantine_equations.html?id=QugvF7xfE-oC&redir_esc=y
> >> >
> >> > But it contains only a general introduction for each type of
> equation. I
> >> > have to find another resource to
> >> > look for the algorithms.
> >>
> >> We should also write some Sphinx documentation documenting the module,
> >> types of equations it can solve
> >> and put there some examples. So that when people want to learn about
> >> diophantine equations in SymPy,
> >> then can just read it.
> >>
> >> I just played with what is in the master:
> >>
> >> In [1]: from sympy.solvers.diophantine import diop_solve
> >>
> >> In [2]: diop_solve(4*x + 3*y -4*z + 5)
> >> Out[2]: {x: 3⋅t + 4⋅z - 5, y: -4⋅t - 4⋅z + 5, z: z}
> >>
> >> In [3]: diop_solve(4*x**2 + 3*y + 5)
> >> Out[3]:
> >>    ⎛⎡⎛                2          ⎞  ⎛                2           ⎞⎤⎞
> >> set⎝⎣⎝-3⋅t + 1, - 12⋅t  + 8⋅t - 3⎠, ⎝-3⋅t + 2, - 12⋅t  + 16⋅t - 7⎠⎦⎠
> >>
> >> In [4]: diop_solve(x**2 + y**2 - 9)
> >> Out[4]: set([(-3, 0), (0, -3), (0, 3)])
> >>
> >> Looks great.
> >>
> >> So I tried to reproduce other people's work. I started with:
> >>
> >> https://www.wolframscience.com/reference/notes/1164b
> >>
> >> here is how to do the table at the beginning of the article:
> >>
> >> In [5]: diop_solve(1+x+x**2+y-x*y)
> >> Out[5]: set([(-2, -1), (0, -1), (2, 7), (4, 7)])
> >>
> >> In [7]: diop_solve(1+2*x+2*x**2+2*y+x*y-2*y**2)
> >> Out[7]: set([])
> >>
> >> In [8]: diop_solve(2+2*x+3*x**2+3*y+x*y-y**2)
> >> Out[8]:
> >>    ⎛⎡⎛                                          78⋅n
> >>    ⎜⎢⎜⎛        ____       ⎞ ⎛        ____      ⎞       ⎛
> ____⎞
> >> ⎛
> >>    ⎜⎢⎜⎝- 653⋅╲╱ 13  + 2353⎠⋅⎝- 180⋅╲╱ 13  + 649⎠       ⎝2353 + 653⋅╲╱ 13
> >> ⎠⋅⎝18
> >> set⎜⎢⎜────────────────────────────────────────────── +
> >> ───────────────────────
> >>    ⎝⎣⎝                     156
> >> 156
> >>
> >>                78⋅n          ⎛
> >> 78⋅n
> >>     ____      ⎞         ____ ⎜  ⎛        ____       ⎞ ⎛        ____
>  ⎞
> >> 0⋅╲╱ 13  + 649⎠       ╲╱ 13 ⋅⎝- ⎝- 653⋅╲╱ 13  + 2353⎠⋅⎝- 180⋅╲╱ 13  +
> 649⎠
> >> ─────────────────── +
> >> ────────────────────────────────────────────────────────
> >>
> >> 2028
> >>
> >>                                          78⋅n⎞                ⎛
> >>    ⎛             ____⎞ ⎛      ____      ⎞    ⎟           ____ ⎜  ⎛
> >> ____
> >>  + ⎝2353 + 653⋅╲╱ 13 ⎠⋅⎝180⋅╲╱ 13  + 649⎠    ⎠   7     ╲╱ 13 ⋅⎝- ⎝-
> 653⋅╲╱
> >> 13
> >> ────────────────────────────────────────────── - ──, -
> >> ───────────────────────
> >>                                                  13
> >>
> >>                              78⋅n
> >> 78⋅n
> >>        ⎞ ⎛        ____      ⎞       ⎛             ____⎞ ⎛      ____
>  ⎞
> >>  + 2353⎠⋅⎝- 180⋅╲╱ 13  + 649⎠     + ⎝2353 + 653⋅╲╱ 13 ⎠⋅⎝180⋅╲╱ 13  +
> 649⎠
> >>
> >>
> ──────────────────────────────────────────────────────────────────────────────
> >>                           338
> >>
> >> ⎞     ⎞  ⎛                    78⋅n
> >> ⎟     ⎟  ⎜⎛        ____      ⎞     ⎛        ____      ⎞   ⎛
> >> ____⎞ ⎛
> >> ⎠   16⎟  ⎜⎝- 180⋅╲╱ 13  + 649⎠    ⋅⎝- 146⋅╲╱ 13  + 520⎠   ⎝520 + 146⋅╲╱
> 13
> >> ⎠⋅⎝
> >> ─ + ──⎟, ⎜───────────────────────────────────────────── +
> >> ────────────────────
> >>     13⎠  ⎝                     156
> >> 1
> >>
> >>                  78⋅n          ⎛                      78⋅n
> >>       ____      ⎞         ____ ⎜  ⎛        ____      ⎞     ⎛        ____
> >> 180⋅╲╱ 13  + 649⎠       ╲╱ 13 ⋅⎝- ⎝- 180⋅╲╱ 13  + 649⎠    ⋅⎝- 146⋅╲╱ 13
>  +
> >> 520
> >> ───────────────────── +
> >> ──────────────────────────────────────────────────────
> >> 56
> >> 2028
> >>
> >>                                          78⋅n⎞                ⎛
> >> ⎞   ⎛            ____⎞ ⎛      ____      ⎞    ⎟           ____ ⎜  ⎛
> >> ____
> >> ⎠ + ⎝520 + 146⋅╲╱ 13 ⎠⋅⎝180⋅╲╱ 13  + 649⎠    ⎠   7     ╲╱ 13 ⋅⎝- ⎝-
> 180⋅╲╱
> >> 13
> >> ────────────────────────────────────────────── - ──, -
> >> ───────────────────────
> >>                                                  13
> >>
> >>        78⋅n
> >> 78⋅n⎞
> >>       ⎞     ⎛        ____      ⎞   ⎛            ____⎞ ⎛      ____      ⎞
> >> ⎟
> >>  + 649⎠    ⋅⎝- 146⋅╲╱ 13  + 520⎠ + ⎝520 + 146⋅╲╱ 13 ⎠⋅⎝180⋅╲╱ 13  + 649⎠
> >> ⎠
> >>
> >>
> ─────────────────────────────────────────────────────────────────────────────
> >>                          338
> >>
> >>     ⎞⎤⎞
> >>     ⎟⎥⎟
> >>   16⎟⎥⎟
> >> + ──⎟⎥⎟
> >>   13⎠⎦⎠
> >>
> >> In [9]: diop_solve(-4-x+4*x**2-y-3*x*y-4*y**2)
> >> Out[9]: set([])
> >>
> >>
> >>
> >> [5] seems correct. [7] and [9] can't find any solution, but there
> >> seems to be a solution, so that looks like a bug?
> >>
> >> Finally [8] seems pretty complicated. Do you know a way to get integer
> >> solutions out of it?
> >> I am attaching Mathematica's notebook for the last two equations. It
> >> seems that SymPy's
> >> result in [8] is correct --- though Mathemtica seems to provide more
> >> solutions. We should check this.
> >> SymPy's result in [9] is incorrect, as shown in the notebook.
> >>
> >>
> >> Btw, there is plenty of additional examples for example here:
> >>
> >>
> http://reference.wolfram.com/mathematica/tutorial/DiophantineReduce.html
> >>
> >> I'll think about more applications and test your module more.
> >>
> >> Ondrej
> >>
> >> --
> >> 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 [email protected].
> >> To post to this group, send email to [email protected].
> >> Visit this group at http://groups.google.com/group/sympy.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
> > --
> > 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 [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at http://groups.google.com/group/sympy.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to