Ask Your Question

sbac's profile - activity

2021-12-15 12:12:18 +0200 received badge  Famous Question (source)
2020-11-01 12:36:12 +0200 received badge  Notable Question (source)
2020-11-01 12:36:12 +0200 received badge  Popular Question (source)
2018-07-04 16:22:49 +0200 commented answer Partial differentiation

You're right. I didn't express it well. Now the result is what I expected. Thank you.

2018-07-04 12:28:43 +0200 received badge  Scholar (source)
2018-07-04 12:28:05 +0200 commented answer Partial differentiation

Thank you for your answer. I think I have a problem here with the chain rule, that's why I defined u0, u1 and u2 as (utility) functions. For example, the right answer to diff(u0, s_t0) is not -1 but -u0' (w*(1-tau_t0) - s_t0). How can I take this into account in Sage?

2018-07-03 20:32:09 +0200 asked a question Partial differentiation

I am trying to compute a partial differentiation of the sum of 3 utility functions (u0 + u1 + u2) with respect to s_t0. Is this the right way to do that in SageMath?

w = var('w'); 
tau_t0 = var('tau_t0'); tau_t1 = var('tau_t1'); 
s_t0 = var('s_t0'); s_t1 = var('s_t1')
r = var('r'); n = var('n')
u0 = function ('u0')(w, tau_t0, s_t0)
u1 = function ('u1')(w, tau_t1, s_t1)
u2 = function ('u2') (n, w, tau_t0, r, s_t0, s_t1)

u0(w, tau_t0, s_t0) = w*(1-tau_t0) - s_t0
u1(w, tau_t1, s_t1) = w*(1-tau_t1) - s_t1
u2(n, w, tau_t0, r, s_t0, s_t1) = (1+n)^2 * w * tau_t0 + (1+n) * w * tau_t0 + (1+r)^2 * s_t0 + (1+r) * s_t1

a = diff(u0 (w, tau_t0, s_t0), s_t0)
b = diff(u1 (w, tau_t1, s_t1), s_t0)
c = diff(u2 (n, w, tau_t0, r, s_t0, s_t1), s_t0)

U = a + b + c
U