New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sympy plot using log #12635

Open
alabrazi opened this Issue May 12, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@alabrazi

alabrazi commented May 12, 2017

The code below work with cos(t) but not with ln(t) or log(t) -> TypeError: can't convert expression to float

from sympy import *
########################################################################
P,t,phi,r,lambda_e, lambda_tot\
= symbols('P,t,phi,r,lambda_e, lambda_tot')
plot((2.5-(t/8760), (t, 0, 8760)), (-1348.8*ln(t)+12692, (t, 0, 8760)))

@alabrazi alabrazi changed the title from TypeError: can't convert expression to float to Sympy plot using log May 12, 2017

@jksuom

This comment has been minimized.

Member

jksuom commented May 12, 2017

It looks like t = 0, where the logarithm is not well defined, is included in the computation. This is what I get:

>>> float(ln(0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy/core/expr.py", line 238, in __float__
    raise TypeError("can't convert complex to float")
TypeError: can't convert complex to float
@alabrazi

This comment has been minimized.

alabrazi commented May 12, 2017

Seems so.
Extending the range to start from -1 instead of 0 is one option to make sympy plot the graph.
plot((2.5-(t/8760), (t, 0, 8760)), ((-1348.8*ln(t)+12692)/1000, (t, -1, 8760)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment