Closed jlperla closed 6 years ago
Sure, I’m working on something else now. I’ll take a look at it tonight or tomorrow morning. Can I get it back to you tomorrow?
On Tue, May 29, 2018 at 3:20 PM Jesse Perla notifications@github.com wrote:
@stevenzhangdx https://github.com/stevenzhangdx
The current transition_dynamics_example.jl is now calculating something with a time-varying payoff and plotting it to see what is happening. It does it with 2 separate approaches: First, it uses the backwards tspan approach, and the second it does a change of variables (i.e. t_tilde = T
- t) and solves the resulting function of t_tilde from t_tilde = 0 to t_tilde = T.
You will see that the only time-varying thing in the PDE is the c_tilde function which is increasing with time. What I don't understand about this solution, is that it seems to me that the u(t,x) function should be increasing over time, since the payoff is increasing. Instead, unless I am missing something it seems to be decreasing.... Can you go carefully through this to see if the results make sense or if we setup a sign incorrectly? For example, if we swap the sign of the composition of the du, at least the u(t,x) seems to be increasing in t, as I would expect. Or maybe my prior that u(t,x) should be increasing is wrong itself?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JuliaDiffEq/PDERoadmap/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/AdUH1wWWQYBtunnzJUJNg_YRauGJsiY0ks5t3cmcgaJpZM4UST4H .
-- Dongxiao Zhang (Steven) Ph.D Student Vancouver School of Economics The University of British Columbia
Absolutely, thanks! And take your time to make sure things make sense in terms of the basic asset pricing example.
I went through the code and everything looks good to me. Both plots look similar and the only difference is the order of t grids. If we reverse the horizontal axis in the second plot, the u(x, t) is increasing over time.
Yes, but do the results make any sense? In particular, do the signs on the system of ODEs we are solving match everything correctly, and is the equation (and the sign of the du/dt capital gains) make sense given the time direction in both cases?
Note for the 2nd one, the reason the horizontal axis is flipped is that time is running backwards, but it is worth carefully going through that to make sure the interpretation of all of them is correct. Is this running backwards from T - 0.2 to T, etc.
To see the underlying results rather than just looking at the graphs, you can go
sol.t
and then see sol[1]
and sol[end]
to see how the solution. In particular,
julia> sol.t'
1×6 RowVector{Float64,Array{Float64,1}}:
0.2 0.199993 0.178176 0.113822 0.0494682 0.0
julia> sol[1]'
1×20 RowVector{Float64,Array{Float64,1}}:
70.1644 70.3013 70.4967 70.7148 70.9389 … 72.8202 72.9058 72.9723 73.0182 73.0419
julia> sol[end]'
1×20 RowVector{Float64,Array{Float64,1}}:
69.1168 69.2537 69.4491 69.6672 69.8913 … 71.7726 71.8582 71.9247 71.9705 71.9943
Does that make sense? The u(t)
function is larger when t=0.0
than when t=T=0.2
? Or is there an interpretation issue here missing.
Lookign at manually changed equation going backwards in time,
julia> sol_reversed.t'
1×6 RowVector{Float64,Array{Float64,1}}:
0.0 6.86452e-6 0.022158 0.0862929 0.150428 0.2
julia> sol_reversed[1]'
1×20 RowVector{Float64,Array{Float64,1}}:
70.1644 70.3013 70.4967 70.7148 70.9389 … 72.8202 72.9058 72.9723 73.0182 73.0419
julia> sol_reversed[end]'
1×20 RowVector{Float64,Array{Float64,1}}:
71.1236 71.2604 71.4559 71.674 71.898 72.1201 … 73.7793 73.865 73.9314 73.9773 74.001
i.e. increasing as it goes back in time?
OK, now that we fixed the f_reversed
bug and better understand things: To summarize the results of the analysis: for a system of ODEs
du/dt = f(t, u)
where u(T)
is given as the terminal condition from the solution to f(T, u(T)) = 0
and we are interesting in solving the system for t = 0, ... T
When using the ODE framework
tspan = (T, 0.0)
f(du,u,p,t)
to match the reversal of time. The DiffEq libraries seems to take care of itt_tilde = T - t
and solve the initial value problem from t_tilde= 0
to t_tilde = T
then
tspan = (0,0, T)
which is now for the t_tilde
variable instead of the t
.f_tilde
where the sign gets swapped since d/dt u(t) = - d/dt_tilde u_tilde(t_tilde)
for the u_tilde(t_tilde) := u(T - t_tilde)
function.
@stevenzhangdx
The current
transition_dynamics_example.jl
is now calculating something with a time-varying payoff and plotting it to see what is happening. It does it with 2 separate approaches: First, it uses the backwardstspan
approach, and the second it does a change of variables (i.e.t_tilde = T - t
) and solves the resulting function oft_tilde
fromt_tilde = 0
tot_tilde = T
.You will see that the only time-varying thing in the PDE is the
c_tilde
function which is increasing with time. What I don't understand about this solution, is that it seems to me that theu(t,x)
function should be increasing over time, since the payoff is increasing. Instead, unless I am missing something it seems to be decreasing.... Can you go carefully through this to see if the results make sense or if we setup a sign incorrectly? For example, if we swap the sign of the composition of thedu
, at least theu(t,x)
seems to be increasing int
, as I would expect. Or maybe my prior thatu(t,x)
should be increasing is wrong itself?