Changes between Initial Version and Version 12 of Ticket #3745


Ignore:
Timestamp:
11/21/14 10:17:02 (6 years ago)
Author:
jdemeyer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3745

    • Property Milestone changed from sage-5.11 to sage-6.4
    • Property Report Upstream changed from to N/A
    • Property Summary changed from calculus -- bug in solve to calculus -- bugs in solve
  • Ticket #3745 – Description

    initial v12  
     1We get a "solution" from `solve()` that isn't actually a solution:
     2
    13{{{
    2 On Tue, Jul 29, 2008 at 6:05 PM, jamlatino <medrano.antonio@gmail.com> wrote:
    3 >
    4 > While working on the video tutorial for Sage I tried the following
    5 > equation:
    6 >
    7 > (sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) - (2*cos(x)*sin(x) -
    8 > sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))
    9 >
    10 > if I use find_root in the interval 1,2 I get the following answer:
    11 > 1.9106332362490561
    12 >
    13 > but when I use solve to find the solution I get
    14 > [x == pi, x == pi/2, x == 0]
    15 >
    16 > pi/2 is 1.57, but when I try find_root in the interval 1.5,1.6 it
    17 > tells me that the equation has no zero in that interval, can someone
    18 > explain??
    19 
    20 This appears to me to be a bug as pi/2 is not a solution.
    21 If you do the following it is pretty clear that the 0's are
    22 at 0, 1.9..., etc. and not at pi/2:
    23 
    24 sage: f = (sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) -
    25 (2*cos(x)*sin(x) - sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x))
     4sage: f(x) = sin(x) - 8*cos(x)*sin(x))*(sin(x)^2 + cos(x)) - (2*cos(x)*sin(x) - sin(x))*(-2*sin(x)^2 + 2*cos(x)^2 - cos(x)
     5sage: solve(f(x), x)
     6[x == pi, x == 1/2*pi, x == 0]
    267sage: f(pi/2)
    278-1
    28 sage: f.plot(-1,4)
    29 
    30 Sage finds the numerical 0's using a numerical root
    31 finder (from scipy).
    32 
    33 Sage finds the exact solutions by calling the computer
    34 algebra system Maxima, which indeed strangely claims that pi/2 is a solution:
    35 
    36 (%i1) solve((sin(x)-8*cos(x)*sin(x))*(sin(x)^2+cos(x))-(2*cos(x)*sin(x)-sin(x))*(-2*sin(x)^2+2*cos(x)^2-cos(x))=0,
    37 x);
    38 
    39 `solve' is using arc-trig functions to get a solution.
    40 Some solutions will be lost.
    41                                         %pi
    42 (%o1)                      [x = %pi, x = ---, x = 0]
    43                                          2
    44 
    45 It looks like this might be a bug in Maxima's solve function.
    46 
    47 There's not much for me to do besides:
    48   * report this to the maxima folks (I've cc'd Robert Dodier
    49 in this email),
    50   * completely rewrite Sage's solve to not use Maxima.
    51 
    52 From Robert Dodier:
    53 
    54 
    55 Yup, that's a bug, all right ... I'll make a bug report.
    56 
    57 >    * completely rewrite Sage's solve to not use Maxima.
    58 
    59 Well, if you do that, please write it in pure Python so it is easier
    60 to translate to Lisp.
    61 
    62 Maxima's code for solving equations has more than a few bugs,
    63 and it's not clear what classes of problems it can handle, nor is
    64 it clear what method is used for each class, and there certainly
    65 are interesting and useful equations which it just can't handle.
    66 All of this motivates a complete rewrite. Not that I'm volunteering;
    67 not yet, anyway.
    68 
    69 FWIW
    70 
    71 Robert Dodier
    729}}}
    73 
    74 I think we need to rewrite solve for Sage.  Any volunteers?  It will have to wait until we change to use either "Gary's symbolics" or "Sympy" for Sage's symbolics, since the current symbolics likely don't support enough to make implementing solve practical.