New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve() returns all roots of polynomial eqs #400

Merged
merged 6 commits into from Jan 27, 2017

Conversation

1 participant
@skirpichev
Collaborator

skirpichev commented Jan 11, 2017

  • prove that default order is stable for quadratic equation
  • for other, solvable with radicals?
  • support unevaluated RootOf
  • evaluate kwarg for RootOf
  • fix unrad tests
  • adapt solve docstring (make test!)
  • RootOf.poly coeffs should be finite?
  • NotImplementedError if LC is not nonzero?
  • fix assumptions for symbolic roots
  • fix evalf for symbolic roots
  • roots() output should be full?
  • or use all_roots() in polynomial solvers?
  • cleanup & rebase
  • fix related issues
  • check tests

See also

  1. this and this maillist threads.

  2. Right now RootOf is very similar to Mathematica's Root. Maple RootOf looks to be more generic, indexed roots - only a special case.

@skirpichev skirpichev added this to the 0.9.0 milestone Jan 11, 2017

@skirpichev skirpichev force-pushed the skirpichev:uneval-RootOf branch from 79fe691 to b38dd7b Jan 26, 2017

@skirpichev skirpichev changed the title [wip] solve returns all roots of polynomial eqs solve returns all roots of polynomial eqs Jan 26, 2017

@skirpichev skirpichev changed the title solve returns all roots of polynomial eqs solve() returns all roots of polynomial eqs Jan 26, 2017

@skirpichev skirpichev force-pushed the skirpichev:uneval-RootOf branch from ca6ab19 to 1bc6bf9 Jan 26, 2017

@skirpichev skirpichev added the testing label Jan 26, 2017

@skirpichev skirpichev referenced this pull request Jan 26, 2017

Closed

polys todo #66

13 of 13 tasks complete

skirpichev added some commits Jan 11, 2017

Support unevaluated RootOf
We can't do too much for generic case with complex,
symbolic coefficient.  But RootOf already now
could be used for bookeeping in solve().

If LC().is_nonzero is False - raise NotImplementedError.
Perhaps, this should be even more strict - there must
be exactly Poly.degree() of roots (modulo multiplicity).

Adapt RootOf.free_symbols, RootOf._eval_is_real and
RootOf._eval_evalf; poly.gen was added to RootOf.args.

Add small workarounds for checkodesol and unrad
to deal with symbolic RootOf's.

There is a little performance regression for checksol,
so in some solve() tests we now use check=False.
Drop wrong comment in docstring
I believe, there is only two solutions.  Here is also
Mathematica's 7 output:

```
    In[1]:= Solve[-x^(1/5) + x^(1/3) + 1/7 == 0, x]

    Out[1]= {{x ->
       Root[1 - 48706 #1 + 1367434327 #1^2 - 2107426771968 #1^3 +
          10242552528740 #1^4 + 4747561509943 #1^5 &, 2]}, {x ->
       Root[1 - 48706 #1 + 1367434327 #1^2 - 2107426771968 #1^3 +
          10242552528740 #1^4 + 4747561509943 #1^5 &, 3]}}
```
Change generic solution in roots_quadratic
Be like Mathematica here:

    In[1]:= Root[a #^2 + b # + c &, 1]
                        2
                       b  - 4 a c
                  Sqrt[----------]
                            2
            -b             a
    Out[1]= --- - ----------------
            2 a          2

Now we have stable (i.e. same for both numeric and symbolic
coefficients) sorting of roots for quadratic expressions.

    In[2]:= P = #^2 + p # + q &
              2
    Out[2]= #1  + p #1 + q &

    In[3]:= Root[P, 2] - Root[P, 1]
                  2
    Out[3]= Sqrt[p  - 4 q]

    In[4]:= FullSimplify[(Re[%] /. {p^2 - 4 q -> a + I b}) >= 0,
                          Assumptions -> Element[{a, b}, Reals]]
    Out[4]= True

Fixes sympy/sympy#7789
Fixes sympy/sympy#8255

@skirpichev skirpichev force-pushed the skirpichev:uneval-RootOf branch from 23fe5a7 to a6ff1e9 Jan 27, 2017

@skirpichev skirpichev merged commit 4f06fc4 into diofant:master Jan 27, 2017

3 checks passed

codecov/patch 100% of diff hit (target 100%)
Details
codecov/project Absolute coverage decreased by -<1% but relative coverage increased by +8% compared to e14f4fb
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@skirpichev skirpichev deleted the skirpichev:uneval-RootOf branch Jan 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment