2023-12-07 01:06:54 +0100 received badge ● Famous Question (source) 2023-10-21 12:53:01 +0100 received badge ● Popular Question (source) 2023-10-21 12:53:01 +0100 received badge ● Notable Question (source) 2023-09-09 04:46:11 +0100 received badge ● Famous Question (source) 2023-05-02 18:46:06 +0100 received badge ● Popular Question (source) 2023-04-25 23:51:45 +0100 received badge ● Popular Question (source) 2023-03-20 22:00:53 +0100 received badge ● Popular Question (source) 2023-02-21 03:20:21 +0100 received badge ● Notable Question (source) 2022-06-04 20:09:25 +0100 received badge ● Notable Question (source) 2022-01-24 22:14:09 +0100 received badge ● Popular Question (source) 2022-01-03 17:09:58 +0100 received badge ● Popular Question (source) 2021-11-11 08:42:10 +0100 received badge ● Notable Question (source) 2021-11-05 00:40:07 +0100 received badge ● Notable Question (source) 2021-09-08 23:36:30 +0100 received badge ● Popular Question (source) 2021-06-23 12:51:07 +0100 received badge ● Popular Question (source) 2020-11-11 20:04:03 +0100 commented answer Plotting multiple functions in Sage from a for loop Would you know how to reset the color if I were to say do 10 iteration instead of 5? 2020-11-11 20:01:06 +0100 commented answer Plotting multiple functions in Sage from a for loop Wow this is so simple its crazy 2020-11-10 23:20:18 +0100 asked a question Plotting multiple functions in Sage from a for loop A while back I asked about simulating the cake eating problem in sage and the algorithm seems like an excellent way to work with things. So far the code looks as follows for obtaining a soloution to the cake eating problem: #Step1: Name variables k,k1,v0,beta,vk,vk1=var('k,k1,v0,beta,vk,vk1') #Step2: Initialize your values beta=0.6 v0=log(k) #Step 3: The Loop to Obtain Policy function for n in range(5): vk = log(k-k1) + beta*v0(k=k1) FOC = vk.diff(k1) k1star = solve(FOC==0, k1) print(n, k1star) v0 = (vk).subs(k1=k1star[0].rhs())  The results I get are as follows: 0 [k1 == 3/8*k] 1 [k1 == 24/49*k] 2 [k1 == 147/272*k] 3 [k1 == 816/1441*k] 4 [k1 == 4323/7448*k]  Im interested in plotting each instance of k1 from my loop. how would I go about doing this? 2020-11-10 20:50:02 +0100 received badge ● Popular Question (source) 2020-11-10 19:54:30 +0100 received badge ● Popular Question (source) 2020-11-08 04:39:49 +0100 commented answer Issues with Cake Eating Problem My code is as follows: #Step 3: The Loop to Obtain Policy function for n in range(5): vk = log(k-k1) + beta*v0(k=k1) FOC = vk.diff(k1) k1star = solve(FOC==0, k1) print(n, klstar.subs(k1==100).n()) v0 = (vk).subs(k1=k1star[0].rhs()) 2020-11-06 19:23:54 +0100 commented answer Issues with Cake Eating Problem Hey I tried your print command and I got nothing. Could you direct me to a resource where I could learn how to collect successive values? 2020-11-06 18:35:31 +0100 asked a question Issues with Cake Eating Problem A while back I asked about simulating the cake eating problem in sage and the algorithm seems like an excellent way to work with things. So far the code looks as follows for obtaining a soloution to the cake eating problem: #Step1: Name variables k,k1,v0,beta,vk,vk1=var('k,k1,v0,beta,vk,vk1') #Step2: Initialize your values beta=0.6 v0=log(k) #Step 3: The Loop to Obtain Policy function for n in range(5): vk = log(k-k1) + beta*v0(k=k1) FOC = vk.diff(k1) k1star = solve(FOC==0, k1) print(n, k1star) v0 = (vk).subs(k1=k1star[0].rhs())  The results I get are as follows: 0 [k1 == 3/8*k] 1 [k1 == 24/49*k] 2 [k1 == 147/272*k] 3 [k1 == 816/1441*k] 4 [k1 == 4323/7448*k]  Initially I thought that it would be a matter of just setting k to some value however this breaks the loop. If I wanted to obtain values for k1 (and then plot them) how would I go about doing this? 2020-07-20 21:39:53 +0100 commented answer Recursive problems in Sage I'm genuinely surprised how little code is needed for this problem. Thank you! 2020-07-20 21:15:30 +0100 commented question The Cake Eating Problem in Sage @jaydfox I have a video which goes through the pen and paper work on solving a planners problem here:https://www.youtube.com/watch?v=Bv_tP3GP5Qg&list=PLLAPgKPWbsiQ0Ejh-twYC3Fr8_WA9BKCc&index=4. Its pretty much the same problem for a cake eating problem except the production function changed. 2020-07-20 21:12:31 +0100 commented question Recursive problems in Sage @EmmanuelCharpentier I see the issue with my approach. Though I actually made a video on solving a planners problem which is similar to this that uses value function iteration, https://www.youtube.com/watch?v=Bv_tP.... I just want to be able to code something like this. 2020-07-20 21:12:31 +0100 received badge ● Commentator 2020-07-20 05:13:05 +0100 marked best answer Unable to simplify variable completely In solving the following hicksian demands in this problem and so far the proceedure works great. x1, x2, l, p1, p2, a, b, R= var('x1, x2, l, p1, p2, a, b, R') U = x1^a*x2^b m = p1*x1+p2*x2; L = m+ l * (R-U); dLdx = L.diff(x1); dLdy = L.diff(x2); dLdl = L.diff(l); step1=solve([dLdx == 0, dLdy == 0, dLdl == 0], p1, p2, R) step2=solve((p1/p2).subs(step1)==p1/p2, x1) good2step3 = solve((U/R).subs(step2).log().log_expand()==0, x2) good1step4=solve(step2[0].subs(good2step3).canonicalize_radical(),x1)  however I note that I dont get such a clean result for good2step3, though algebraically correct its not completely simplified. I've tried simplify_rational() and simplify_log but that ends up ruining my clean solution for x1 in good1step4. Is there more I can do to clean up my solutions? 2020-07-19 19:38:18 +0100 asked a question Recursive problems in Sage I've been trying to figure out how to run a basic recursive problem in sage. The basic structure of the problem I have figured out, its just a matter of putting it in terms of a for/ while loop. #Initializing values k,k1,vk,beta,vk1=var('k,k1,vk,beta,vk1') vk= log(k-k1)+beta*log(k1) #I want to loop this procedure FOC=vk.diff(k1) k1star=solve(FOC==0,k1) vk=(vk).subs(k1star) vk  Any help is appreciated. 2020-07-19 09:16:17 +0100 asked a question The Cake Eating Problem in Sage Im interested in running a basic cake eating problem in sage. In its recursive formulation we have to solve the following bellman equations: $$v(k_t)=ln(k_t-k_{t+1})+\beta v(k_{t+1}), \ \ \ \beta\in(0,1)$$ The algorithm for solving this problem is as follows: Step 1: Take an initial guess of $v(k_{t+1})=0$ Step 2: Solve for the maximum of $v(k_t)$ (in the first iteration this is $v(k_t)=ln(k_t-k_{t+1})$, the maximum here is simply where $k_{t+1}=0$ thus $v(k_t)=ln(k_{t})$ ) Step 3: Using our maximum for $v(k_t)$ iterate it forward and update our bellman (in this case we have $v(k_t)=ln(k_t-k_{t+1})+\beta [ln(k_{t+1}]$) Step 4: Maximize this updated equation and repeat until convergence. Any help is appreciated. 2020-07-17 23:00:20 +0100 asked a question Running the Solow Model in Sage and Plotting it. As some of the regulars on this forum could tell I've really gotten into sage for its appications to economics problems. I came up withthe following code for the Solow growth model in sage. k,k1, alpha, A, delta, s, c=var('k,k1, alpha, A, delta, s, c') #Initial Values k=10 s=0.5 A=5 alpha=0.6 delta=0.8 #Equations of Interest f(k)=A*k^alpha k1=f(k)-(1-delta)*k invest=s*f(k) #Visualizing the Solow Model prod=plot(f(k),(k,1,100),color='blue') lom=plot(delta*k,(k,1,100),color='red') savings=plot(invest,(k,1,100),color='green') prod+lom+savings  I'm interested to see if I can make a dotted line from the x-axis and y-axis to show where the green and red lines intersect or even better display a number. To visualize what I want I've used microsoft paint to aid my graphics below. However this isn't the prettiest visualization and I'm wondering if I could get better graphics in sage. Any help is appreciated. 2020-07-17 22:41:55 +0100 asked a question equation does not simplify due to fractional exponent The following equation does not seem to simplify due to the fact there is a fractional power in one of the variables im seeking to solve for. The code I have is: k=var('k') solve(k == 50*k^(3/5),k) Out: [k == 50*k^(3/5)]  is there anyway to fix this? 2020-07-17 22:35:05 +0100 asked a question All the simplify() commands Is there a source where I can view all the variants of simplify? I know about simplify(),simplify_full(),canonicalize_radical() and simplify_rational(). However I dont know many more than that. this is useful because often times the expressions I deal with are unpredictable and I will have to use a number of commands to simplify my results. Is there orderd list of these commands or a cheat sheet?