the question I need to solve is:

t x'[t] == -x[t] + y[t],  
t y'[t] == -5 t^2/x[t]^2 + x[t] - y[t],       
x[1] == 4, x[b] == 1

in order to solve the coupled equations, I need 2 boundaries for x[1] and y[1], so I can convert the question into shooting method

{xsoln, ysoln} = {x, y} /. ParametricNDSolve[{  t x'[t] == -x[t] + y[t], 
 t y'[t] == -5 t^2/x[t]^2 + x[t] - y[t],
x[1] == 4, y[1] == a}, {x, y}, {t, 1, b}, {a,b}]

for each specific value of b, I can find the value of a which satisfies x[b]==1 manually. But if there is any possibility that I can find the value of a for any value of b instead of plugging the value of b and repeating the above process.

the way I am getting the value of a is as follows:

first I set b=100, then I plot xsoln[a][100], then I can locate the region of a which satisfies x[100]==1, so I use findroot to find the exact value of a.

I naively set f[b_?NumericQ]:=a/.FindRoot[xsoln[a][b]==1,{a,0}], so for any b, I have the value of a. But xsol[a][b] is not well behaved. I can not set FindRoot at a around 0, the starting point differs for different b, which can only be seted by plotting the profile and detect the starting point.

my another idea is by adding WhenEvent into NDSolve, which is like WhenEvent[xsoln[a][b] does not equal to 1, change the value of a, and do the calculation again]

Thanks folks


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.