On Thu, Mar 5, 2009 at 9:55 AM, johannct <[email protected]> wrote:
>
> ok I looked at the code in solvers.py, l.606:
>    r = eq.match(a*f(x).diff(x,x) + b*diff(f(x),x) + c*f(x))
>    if r:
>        r1 = solve(r[a]*x**2 + r[b]*x + r[c], x)
>        if r1[0].is_real:
>            if len(r1) == 1:
>                return (Symbol("C1") + Symbol("C2")*x)*exp(r1[0]*x)
>            else:
>                return Symbol("C1")*exp(r1[0]*x) + Symbol("C2")*exp(r1
> [1]*x)
>        else:
>            r2 = abs((r1[0] - r1[1])/(2*S.ImaginaryUnit))
>            return (Symbol("C2")*C.cos(r2*x) + Symbol("C1")*C.sin
> (r2*x))*exp((r1[0] + r1[1])*x/2)
>
> where:
> In [19]: r
> Out[19]:
> ⎧         2      ⎫
> ⎨a: 1, b: ─, c: 1⎬
> ⎩         x      ⎭
>
> I guess the characteristic second order test is completely irrelevant,
> as it assumes that a,b, and c are constants, and not functions of x.
> What is the best way to check for that?

Ah, you have found a bug in Wild. These lines:

    a = Wild('a', exclude=[x])
    b = Wild('b', exclude=[x])
    c = Wild('c', exclude=[x])

should assure, that a,b and c never contain "x". Please report it into
a separate issue.

To check, that "a" doesn't contain "x", just use:

a.has(x)

where x was defined on the line 593:

    x = f.args[0]


example usage:

In [1]: sin(x).has(x)
Out[1]: True

In [2]: sin(x).has(y)
Out[2]: False


Ondrej

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

Reply via email to