Tried the following -

class f(Function):
    is_real = True

x = symbols('x',real=True)

F = f('F',x)

print f
print re(f)
print im(f)

df = F.diff(x)

print re(df)
print im(df)

and got -

f
f
0
re(D{x}f)
im(D{x}f)

Again it works for the function, but not the derivatives of the function.


On Sat, Sep 19, 2015 at 7:37 PM, Alan Bromborsky <[email protected]>
wrote:

> Then how do I instanciate a real function of several variables as in
>
> X = symbols('x y z',real=True)
>
> F = Function('F')(*X)
>
> On Sat, Sep 19, 2015 at 6:34 PM, Christophe Bal <[email protected]>
> wrote:
>
>> Hello.
>>
>> Have you tried this ?
>>
>>
>> *from sympy import **
>>
>> *class f(Function):*
>> *    is_real = True*
>>
>> *x = Symbol('x',real=True)*
>>
>> *df = f.diff(x)*
>>
>> *print(re(df))*
>> *print(im(df))*
>>
>>
>>
>>
>> *Christophe BAL*
>> *Enseignant de mathématiques en Lycée **et développeur Python amateur*
>> *---*
>> *French math teacher in a "Lycée" **and **Python **amateur developer*
>>
>> 2015-09-20 0:22 GMT+02:00 brombo <[email protected]>:
>>
>>> Could you elucidate further or give me a link.  I  don't have a clue to
>>> implement what you suggested.
>>>
>>> On Saturday, September 19, 2015 at 6:00:11 PM UTC-4, Aaron Meurer wrote:
>>>>
>>>> The only way to do it presently is to subclass Function manually:
>>>>
>>>> class f(Function):
>>>>     is_real = True
>>>>
>>>> Aaron Meurer
>>>>
>>>> On Sat, Sep 19, 2015 at 2:47 PM, brombo <[email protected]> wrote:
>>>> > Your method works for a function, but not the derivative of a
>>>> function -
>>>> >
>>>> > x = Symbol('x',real=True)
>>>> >
>>>> > f = RealFunction('f')(x)
>>>> >
>>>> > print re(f)
>>>> > f
>>>> > print im(f)
>>>> > 0
>>>> >
>>>> > df = f.diff(x)
>>>> > print re(df)
>>>> > re(df)
>>>> > print im(df)
>>>> > im(df)
>>>> >
>>>> > What should happen is that re(df) = df and im(df) = 0, but is doesn't
>>>> > happen.  Any suggestions?
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > On Saturday, September 19, 2015 at 12:58:53 PM UTC-4, brombo wrote:
>>>> >>
>>>> >> How do I define a real function of a real variable?
>>>> >>
>>>> >> X = symbols('x y z',real=True)
>>>> >>
>>>> >> f = Function('f',real=True)(*X)
>>>> >>
>>>> >> "real=True" in Function doesn't do anything.
>>>> >
>>>> > --
>>>> > 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.
>>>> > To view this discussion on the web visit
>>>> >
>>>> https://groups.google.com/d/msgid/sympy/6a732f8b-c09a-440e-b524-145343e1a499%40googlegroups.com.
>>>>
>>>> >
>>>> > For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sympy/0c906880-41fe-41bb-82ea-ae6ddcb3848f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/sympy/0c906880-41fe-41bb-82ea-ae6ddcb3848f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/CAAb4jGkWNoXAbu5_-HJ1bDVhnnK_Esi6eDQbqGvnBYxz42HpMA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/sympy/CAAb4jGkWNoXAbu5_-HJ1bDVhnnK_Esi6eDQbqGvnBYxz42HpMA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CALOxT-naJ7unWN3qqO62Ntak%2Br1nv9yo5%3DOJx8N2CGtMu2m6Wg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to