Ask Your Question
1

Error: unsupported operand type for ^ or pow(): 'list' and 'int' (Newbie)

asked 2021-06-24 13:36:44 +0200

Boyko_Bu gravatar image

Hi all,

I want to do a very simple thing: display an equation in Sage:

%display typeset 
var('d, r, mu, c, g_1, g_2')

pi_m = [(1+d)*g_1 + r*(1-d*mu)-c*d^2]^(2)/(4*g_1) + [(1+d)*g_2 - c*d^2]^(2)/(4*g_2)

I receive the following error, which I understood is related to the fact that Python and Sage cannot elevate a list to the power of an integer:

TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'

Unfortunately, from the past answers I understood the problem, not the solution :D.

Can anyone help me? I imagine it's something immediate...

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-06-24 14:02:10 +0200

tmonteil gravatar image

Square brackets are used to define lists, but you can nest parentheses:

sage: pi_m = ((1+d)*g_1 + r*(1-d*mu)-c*d^2)^(2)/(4*g_1) + ((1+d)*g_2 - c*d^2)^(2)/(4*g_2)
edit flag offensive delete link more

Comments

Really!? Well, thanks!!!

Boyko_Bu gravatar imageBoyko_Bu ( 2021-06-24 14:16:17 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2021-06-24 13:36:44 +0200

Seen: 1,604 times

Last updated: Jun 24 '21