Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. NDSolve[{-x^2 f'[x] + f[x] (a[x] - x/(1 - x)) == 0, f[x]^2 - x^2 a'[x] + a[x] x/(1 - x) == 1,
  2. f[0] == 1, f[1] == 0}, {f,a}, {x, 0, 1}]
  3.  
  4. NDSolve[{f[x]^2 + x^4 (f'[x]/f[x])^2 - x^4 f''[x]/f[x] + x^3 (1/(1 - x) - 2) f'[x]/f[x] - 1 == 0,
  5. f[0] == 1, f[1] == 0}, f, {r, 0, 1}]
  6.  
  7. eq = {-f[x]^2 + f[x]^4 +
  8. x^4 Derivative[1][f][x]^2 + (x^3) /(-1 + x)
  9. f[x] ((1 - 2 x) f'[x] - (-1 + x) x f''[x]) == 0, f[1/10] == 1,
  10. f'[1/10] == -1/10};
  11. eq // Column // TraditionalForm
  12.  
  13. s = NDSolve[eq, f, {x, 1/10, 9/10}];
  14. Plot[Evaluate[f[x] /. s], {x, 1/10, 9/10}, PlotRange -> All]
  15.  
  16. eq1 = D[f[r], r] + f[r] (a[r] - 1/r);
  17. eq2 = f[r]^2 + D[a[r], r] + a[r]/r - 1;
  18.  
  19. arule = Solve[eq1 == 0, a[r]][[1, 1]];
  20. darule = D[%, r] // Simplify;
  21. eq3 = -f[r] (eq2 /. {arule, darule}) // Simplify
  22. (* f[r] - f[r]^3 + Derivative[1][f][r]/r - Derivative[1][f][r]^2/f[r] +
  23. Derivative[2][f][r] *)
  24.  
  25. Series[eq3 /. Thread[Rule[#, # /. f -> Function[{r}, Sum[c[i] r^i, {i, 4}]]] & /@
  26. {f[r], Derivative[1][f][r], Derivative[2][f][r]}], {r, 0, 2}] // Normal
  27. (* c[2] + r (c[1] - c[2]^2/c[1] + 4 c[3]) +
  28. r^2 (c[2] + c[2]^3/c[1]^2 - (4 c[2] c[3])/c[1] + 9 c[4]) *)
  29.  
  30. r0 = 10^-5; r1 = 50;
  31. sEvent = ParametricNDSolveValue[{eq3 == 0, f[r0] == f'[r0] r0,
  32. f'[r0] == b, WhenEvent[f'[r] < 0, "StopIntegration"],
  33. WhenEvent[f[r] > 1, "StopIntegration"]}, f, {r, r0, r1}, {b}, WorkingPrecision -> 45];
  34. dist[b_?NumericQ] := sEvent[b]["Domain"][[1, 2]]
  35. FindMaximum[dist[b], {b, 8529/10000}, WorkingPrecision -> 45];
  36. {dmax, b0} = {First@%, b /. Last[%]}
  37. (* {19.7939826947595284038626883012992096669595719,
  38. 0.853177865433588923966572213040425596262318851} *)
  39.  
  40. Plot[sEvent[b0][r], {r, r0, dmax}, PlotRange -> All, AxesLabel -> {r, f}]
  41.  
  42. arule[[2]] // Apart
  43. (* 1/r - Derivative[1][f][r]/f[r] *)
  44.  
  45. Plot[1/r - sEvent[b0]'[r]/sEvent[b0][r], {r, r0, dmax}, AxesLabel -> {r, a}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement