Thursday, November 20, 2025
HomeLanguagesPython | sympy.as_independent() method

Python | sympy.as_independent() method

With the help of sympy.as_independent() method, we can separate the mathematical expression independently by the variable passed as parameter in the sympy.as_independent() method.

Syntax : sympy.as_independent(variable)

Return : Return a tuple having separated variables in mathematical expression.

Example #1 :
In this example we can see that by using sympy.as_independent() method, we are able to separate the mathematical function on the basis of independent variable which is passed as parameter.




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.as_independent(variable) method
gfg = (1 + 2 * x + 1 / x).as_independent(x)
    
print(gfg)


Output :

(1, 2*x + 1/x)

Example #2 :




# import sympy
from sympy import * 
  
x, y = symbols('x y')
  
# Use sympy.as_independent(variable) method
gfg = (1 / y**2 + x).as_independent(y)
    
print(gfg)


Output :

(x, y**(-2))

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6780 POSTS0 COMMENTS
Nicole Veronica
11927 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6906 POSTS0 COMMENTS
Ted Musemwa
7164 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS