@@ -1941,16 +1941,17 @@ function ^(a::SN, b)
1941
1941
a = unwrap_const (a)
1942
1942
b = unwrap_const (unwrap (b))
1943
1943
T = promote_symtype (^ , symtype (a), symtype (b))
1944
- ! issafecanon (^ , a, b) && return Term {T} (^ , ArgsT ((a, b )))
1944
+ ! issafecanon (^ , a, b) && return Term {T} (^ , ArgsT ((a, maybe_const (b) )))
1945
1945
if b isa Number
1946
1946
iszero (b) && return 1
1947
1947
isone (b) && return a
1948
1948
end
1949
1949
if b isa Real && b < 0
1950
1950
return Div {T} (1 , a ^ (- b), false )
1951
1951
end
1952
- if b isa Number && iscall (a) && operation (a) === (^ ) && arguments (a)[2 ] isa Number
1952
+ if b isa Number && iscall (a) && operation (a) === (^ ) && isconst ( arguments (a)[2 ]) && unwrap_const ( arguments (a)[ 2 ]) isa Number
1953
1953
base, exp = arguments (a)
1954
+ exp = unwrap_const (exp)
1954
1955
return base ^ (exp * b)
1955
1956
end
1956
1957
@match a begin
@@ -1966,7 +1967,7 @@ function ^(a::SN, b)
1966
1967
_ => return Polyform {T} (MP. polynomial (basicsymbolic_to_polyvar (a) ^ Int (b), T))
1967
1968
end
1968
1969
end
1969
- return BSImpl. Term {T} (^ , ArgsT ((a, b )))
1970
+ return BSImpl. Term {T} (^ , ArgsT ((a, maybe_const (b) )))
1970
1971
end
1971
1972
1972
- ^ (a:: Number , b:: SN ) = Term {promote_symtype(^, symtype(a), symtype(b))} (^ , ArgsT ((a , b)))
1973
+ ^ (a:: Number , b:: SN ) = Term {promote_symtype(^, symtype(a), symtype(b))} (^ , ArgsT ((closest_const (a) , b)))
0 commit comments