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

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 close merge delete

Sort by » oldest newest most voted

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)

more
{"ft_lang_label":"__label__en","ft_lang_prob":0.82730186,"math_prob":0.9037673,"size":633,"snap":"2022-05-2022-21","text_gpt3_token_len":192,"char_repetition_ratio":0.08426073,"word_repetition_ratio":0.02,"special_character_ratio":0.3349131,"punctuation_ratio":0.15714286,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98635525,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-21T00:31:25Z\",\"WARC-Record-ID\":\"<urn:uuid:31527e56-ed1e-4578-80f4-0489dcb32367>\",\"Content-Length\":\"54139\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:20dc55b5-f3fa-4b12-8b00-d334ede28f21>\",\"WARC-Concurrent-To\":\"<urn:uuid:9007e16c-f6ac-4458-9699-4653935e2543>\",\"WARC-IP-Address\":\"194.254.163.53\",\"WARC-Target-URI\":\"https://ask.sagemath.org/question/57728/error-unsupported-operand-type-for-or-pow-list-and-int-newbie/\",\"WARC-Payload-Digest\":\"sha1:T5KBSZOFTX4OYXRQU2YUDBFZOVZBG5GY\",\"WARC-Block-Digest\":\"sha1:E24S22KGX64DFM2VACLO3O55QGACCPEF\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662534693.28_warc_CC-MAIN-20220520223029-20220521013029-00052.warc.gz\"}"}