0

I am making a syntax error, some how my syntax is leading python to think I am writing +.log some where?
Please take a look at the code and let me know. Can any one suggest, a function that can be used instead to solve this Algorithm

import numpy as np

import sympy as sp

answer = 0

x = sp.Symbol('x')

y = sp.Symbol('y')

W = sp.Symbol('W')

R = sp.Symbol('R')

a = sp.Symbol('a')

n = sp.Symbol('n')

m = sp.Symbol('m')

O = sp.Symbol('O')

'''
answer = sp.solve(((((-1* (np.log(1+(x/R))))/(np.log(1+((10**6)/R))))+1)*(Os/((np.log(np.exp(1)+(x/a)**n))**m)))-W,x)
'''

answer = sp.solve(((((-1* (sp.log(1+(x/R))))/(sp.log(1+((10**6)/R))))+1)*(O/((sp.log(np.exp(1)+(x/a)**n))**m)))-W,x)

print(answer)

Results: OLD

line 15, in <module>
    answer = sp.solve(((((-1* (np.log(1+(x/R))))/(np.log(1+((10**6)/R))))+1)*(Os/((np.log(np.exp(1)+(x/a)**n))**m)))-W,x)
AttributeError: 'Add' object has no attribute 'log'

Process finished with exit code 1

Results: New

 Continuum\Anaconda3\lib\site-packages\sympy\solvers\solvers.py", line 1414, in _solve
    "\nNo algorithms are implemented to solve equation %s" % f)
NotImplementedError: multiple generators [log((x/a)**n + 54365636569181/20000000000000)**m, log(1 + x/R)]
No algorithms are implemented to solve equation O*(1 - log(1 + x/R)/log(1 + 1000000/R))*log((x/a)**n + 54365636569181/20000000000000)**(-m) - W

Process finished with exit code 1
3
  • It seems you are getting confused with the parenthesis. Try to separate them in multiple lines and do step-by-step first Commented Apr 24, 2015 at 7:13
  • I can give that a try. Commented Apr 24, 2015 at 7:44
  • Can any one suggest, a function that can be used instead to solve this Algorithm. Commented Apr 24, 2015 at 8:13

1 Answer 1

2

I think you should use sp.log instead of np.log. I run your code but it seems like the equation is too complex and no algorithms are implemented to solve it.

Sign up to request clarification or add additional context in comments.

5 Comments

I am just trying to solve for x. Can you share more about no algorithms being implemented to solve the equation.
@SDS You want to solve a symbol equation, so you need to use log function given by sympy. Change all np.log in your code to sp.log. Usually this works but for your equation, I get an error NotImplementedError: multiple generators [log((x/a)**n + 54365636569181/20000000000000)**m, log(1 + x/R)]. Often this means that the solutions cannot be represented symbolically. See docs.sympy.org/dev/tutorial/solvers.html
I wasnt sure if sp.log = ln or log10, since I want to use ln.
Thanks!, I will try to use an alternate syntax to solve the equation.
@SDS it is ln. You can accept my answer if it gives a hand :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.