1 | initial version |
Sure, you can do it that way. You can omit the lines
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)
because the subsequent lines just redefine u0
,u1
,u2
using Sage syntax for function definition.
You could also replace the functions u0
,u1
,u2
by their values (since you only use the values):
var('w,tau_t0,tau_t1,s_t0,s_t1,r,n')
u0 = w*(1-tau_t0) - s_t0
u1 = w*(1-tau_t1) - s_t1
u2 = (1+n)^2 * w * tau_t0 + (1+n) * w * tau_t0 + (1+r)^2 * s_t0 + (1+r) * s_t1
a = diff(u0, s_t0)
b = diff(u1, s_t0)
c = diff(u2, s_t0)
U = a + b + c
U
2 | No.2 Revision |
Sure, you can do it that way. You can omit the lines
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)
because the subsequent lines just redefine u0
,u1
,u2
using Sage syntax for function definition.
You could also replace the functions u0
,u1
,u2
by their values (since you only use the values):
var('w,tau_t0,tau_t1,s_t0,s_t1,r,n')
u0 = w*(1-tau_t0) - s_t0
u1 = w*(1-tau_t1) - s_t1
u2 = (1+n)^2 * w * tau_t0 + (1+n) * w * tau_t0 + (1+r)^2 * s_t0 + (1+r) * s_t1
a = diff(u0, s_t0)
b = diff(u1, s_t0)
c = diff(u2, s_t0)
U = a + b + c
U
Since partial differentiation is linear, you can also define U
in terms of u0
,u1
,u2
in one step:
U = diff(u0+u1+u2, s_t0)