On Mar 6, 1:46 pm, johannct <[email protected]> wrote:
> Hello, how can I make use of mpmath.besselj(n,x) with w a symbol?
> as in result = r[a]*mpmath.sqrt(mpmath.pi/2)*(Symbol("C0")
> *mpmath.besselj(0.5,x) + Symbol("C1")*mpmath.bessely(0.5,x))/
> mpmath.sqrt(x)
> where x = Symbol("x")
> I get the follwoing error:
> /home/cohen/data1/sources/python/sympy/sympy/mpmath/mptypes.pyc in
> mpmathify(x, strings)
>      99     if hasattr(x, '_mpmath_'):
>     100         return mpmathify(x._mpmath_(*prec_rounding))
> --> 101     raise TypeError("cannot create mpf from " + repr(x))
>     102
>     103 def try_convert_mpf_value(x, prec, rounding):
>
> TypeError: cannot create mpf from x
>
> thanks
> Johann
>
> On Mar 5, 4:05 pm, Ondrej Certik <[email protected]> wrote:
>
> > 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
>
>

mpmath can handle numerical stuff only (so it fails to convert a
symbol to a floating-point number). As far as I know, symbolical
Bessel functions are not yet implemented.

Vinzent
--~--~---------~--~----~------------~-------~--~----~
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