SymPy can print Exponentiation base and exponent?
up vote
0
down vote
favorite
Thank you in advance and sorry for the bad english!
I want
1.x : how to Determination of Exponentiation , Determination possible?
2.print : base=b ,exponent=n
WrongScript.py
from sympy import *
var('x y z a b n')
x=b**n
y=3**n
z=a
# output 1.---------------------------------
print("x=",x) # x= b**n,**
print("y=",y) # y= 3**n,**
print("z=",z) # z= a, not **
# output 2.---------------------------------
print(MyBaseOut(x),MyExponentOut(x)) # b,n
print(MyBaseOut(y),MyExponentOut(y)) # 3,n
def MyBaseOut(p):
# ans=?
return ans
def MyExponentOut(q):
# ans=?
return ans
2018-11-26------------------------------
FullScript.py
from sympy import *
var('b n')
def MyBaseOut(p):
return p.as_base_exp()[0]
def MyExponentOut(q):
return q.as_base_exp()[1]
x=b**n
y=3**n
print(MyBaseOut(x),MyExponentOut(x))
print(MyBaseOut(y),MyExponentOut(y))
# b n
# 3 n
sympy
add a comment |
up vote
0
down vote
favorite
Thank you in advance and sorry for the bad english!
I want
1.x : how to Determination of Exponentiation , Determination possible?
2.print : base=b ,exponent=n
WrongScript.py
from sympy import *
var('x y z a b n')
x=b**n
y=3**n
z=a
# output 1.---------------------------------
print("x=",x) # x= b**n,**
print("y=",y) # y= 3**n,**
print("z=",z) # z= a, not **
# output 2.---------------------------------
print(MyBaseOut(x),MyExponentOut(x)) # b,n
print(MyBaseOut(y),MyExponentOut(y)) # 3,n
def MyBaseOut(p):
# ans=?
return ans
def MyExponentOut(q):
# ans=?
return ans
2018-11-26------------------------------
FullScript.py
from sympy import *
var('b n')
def MyBaseOut(p):
return p.as_base_exp()[0]
def MyExponentOut(q):
return q.as_base_exp()[1]
x=b**n
y=3**n
print(MyBaseOut(x),MyExponentOut(x))
print(MyBaseOut(y),MyExponentOut(y))
# b n
# 3 n
sympy
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Thank you in advance and sorry for the bad english!
I want
1.x : how to Determination of Exponentiation , Determination possible?
2.print : base=b ,exponent=n
WrongScript.py
from sympy import *
var('x y z a b n')
x=b**n
y=3**n
z=a
# output 1.---------------------------------
print("x=",x) # x= b**n,**
print("y=",y) # y= 3**n,**
print("z=",z) # z= a, not **
# output 2.---------------------------------
print(MyBaseOut(x),MyExponentOut(x)) # b,n
print(MyBaseOut(y),MyExponentOut(y)) # 3,n
def MyBaseOut(p):
# ans=?
return ans
def MyExponentOut(q):
# ans=?
return ans
2018-11-26------------------------------
FullScript.py
from sympy import *
var('b n')
def MyBaseOut(p):
return p.as_base_exp()[0]
def MyExponentOut(q):
return q.as_base_exp()[1]
x=b**n
y=3**n
print(MyBaseOut(x),MyExponentOut(x))
print(MyBaseOut(y),MyExponentOut(y))
# b n
# 3 n
sympy
Thank you in advance and sorry for the bad english!
I want
1.x : how to Determination of Exponentiation , Determination possible?
2.print : base=b ,exponent=n
WrongScript.py
from sympy import *
var('x y z a b n')
x=b**n
y=3**n
z=a
# output 1.---------------------------------
print("x=",x) # x= b**n,**
print("y=",y) # y= 3**n,**
print("z=",z) # z= a, not **
# output 2.---------------------------------
print(MyBaseOut(x),MyExponentOut(x)) # b,n
print(MyBaseOut(y),MyExponentOut(y)) # 3,n
def MyBaseOut(p):
# ans=?
return ans
def MyExponentOut(q):
# ans=?
return ans
2018-11-26------------------------------
FullScript.py
from sympy import *
var('b n')
def MyBaseOut(p):
return p.as_base_exp()[0]
def MyExponentOut(q):
return q.as_base_exp()[1]
x=b**n
y=3**n
print(MyBaseOut(x),MyExponentOut(x))
print(MyBaseOut(y),MyExponentOut(y))
# b n
# 3 n
sympy
sympy
edited Nov 26 at 12:05
asked Nov 22 at 12:59
mrrclb48z
356
356
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The attribute is_Pow
will tell you if it has an exponent other than 1 and the method as_base_exp()
will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:
>>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
[(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The attribute is_Pow
will tell you if it has an exponent other than 1 and the method as_base_exp()
will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:
>>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
[(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]
add a comment |
up vote
1
down vote
accepted
The attribute is_Pow
will tell you if it has an exponent other than 1 and the method as_base_exp()
will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:
>>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
[(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The attribute is_Pow
will tell you if it has an exponent other than 1 and the method as_base_exp()
will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:
>>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
[(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]
The attribute is_Pow
will tell you if it has an exponent other than 1 and the method as_base_exp()
will tell you what the base and exponent are -- select element 0 for the base and element 1 for the exponent:
>>> [(i.is_Pow, i.as_base_exp()) for i in (y,1/y,y**2,y**z)]
[(False, (y, 1)), (True, (y, -1)), (True, (y, 2)), (True, (y, z))]
answered Nov 22 at 13:26
smichr
3,368810
3,368810
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431596%2fsympy-can-print-exponentiation-base-and-exponent%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown