>>solve returns a list, so you need to use optimal_x[0] to get the first element.
Thanks a lot Aaron. This was helpful. On Sunday, July 2, 2017 at 8:19:12 AM UTC+5:30, Aaron Meurer wrote: > > solve returns a list, so you need to use optimal_x[0] to get the first > element. > > But anyway, since you are solving for x, the result from solve does > not contain x, so the subs would do nothing. > > Aaron Meurer > > On Sat, Jul 1, 2017 at 8:14 AM, Zing <[email protected] <javascript:>> > wrote: > > Hi, > > > > I am not able to do substitution of one expression into another. Can > anyone > > tell me why. The last line of the code is throwing an error. > > > > Thanks. > > > > Ankur Sinha > > > > P.S. I posted this message a while ago but am not able to see it in the > > topics. Apologies if this attempt leads to two posts. > > > > from IPython.display import display, Math > > from sympy import * > > > > #Production > > x = symbols('x') > > #Tax > > t = symbols('t') > > #Level of automation (varies between 0 and 1) > > l = symbols('l') > > > > #Parameters > > a,b,c,d,e,f,g,h = symbols('a b c d e f g h') > > k,m,alpha = symbols('k m alpha') > > > > #Solving firm's problem with automation tax > > priceF = a - b*x > > #Cost without automation > > costWoutAutomation = d*x**2 + e*x + f > > > > #Firm's profit > > profitF = (1-alpha)*(priceF*x - costWoutAutomation) > > > > #Solving > > foc_x = diff(profitF,x) > > optimal_x = solve(foc_x,x) > > > > print(optimal_x) > > > > print(optimal_x.subs(x,k)) > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at https://groups.google.com/group/sympy. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/sympy/7fe6b265-dc97-401f-aefc-86419c04164b%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4c66b8b7-a2f1-49af-a4eb-e9ed0c24bc55%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
