Feat(compute): Write powers of fraction
This commit is contained in:
parent
78e781be62
commit
ddf15e4276
@ -32,6 +32,15 @@ Generate and compute like a student!
|
|||||||
4 / 2 + 3 / 2
|
4 / 2 + 3 / 2
|
||||||
(4 + 3) / 2
|
(4 + 3) / 2
|
||||||
7 / 2
|
7 / 2
|
||||||
|
>>> e = Expression.from_str("(2/3)^4")
|
||||||
|
>>> e_simplified = e.simplify()
|
||||||
|
>>> print(e_simplified)
|
||||||
|
16 / 81
|
||||||
|
>>> for s in e_simplified.explain():
|
||||||
|
... print(s)
|
||||||
|
(2 / 3)^4
|
||||||
|
2^4 / 3^4
|
||||||
|
16 / 81
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -80,8 +80,17 @@ def mofraction_monumber(left, right):
|
|||||||
>>> a = MOFraction(3, 2)
|
>>> a = MOFraction(3, 2)
|
||||||
>>> b = MOnumber(2)
|
>>> b = MOnumber(2)
|
||||||
>>> print(power(a, b))
|
>>> print(power(a, b))
|
||||||
|
/
|
||||||
|
> ^
|
||||||
|
| > 3
|
||||||
|
| > 2
|
||||||
|
> ^
|
||||||
|
| > 2
|
||||||
|
| > 2
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
num = Tree("^", left.numerator, right)
|
||||||
|
denom = Tree("^", left.denominator, right)
|
||||||
|
return Tree("/", num, denom)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user