Created
October 16, 2019 12:47
-
-
Save bamford/094a34cc9c9ef53b8f77b3eb7efcc2ef to your computer and use it in GitHub Desktop.
Test whether a given function is a valid w(z)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy import Symbol, sympify | |
def test(w): | |
"""Test if w is valid | |
Argument w should be a string expression containing the symbol z. | |
Returns True if w is real and positive, for all real and positive z, otherwise False. | |
Example: | |
>>> test('z + 1') | |
True | |
>>> test('z - 1') | |
False | |
""" | |
ns = dict(z=Symbol('z', real=True, positive=True)) | |
w = sympify(w, ns) | |
return (w.is_real is True) and (w.is_positive is True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment