Guest User

Untitled

a guest
Jul 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. M = 1; G = 1;h = 0.1; T = 1; n = T/h; (*steps*)
  2.  
  3. NewtonGrav[{vx_, vy_, vz_, x_, y_, z_}] :=
  4. {vx + (-G M x)/Sqrt[x^2 + y^2 + z^2]*h,
  5. vy + (-G M y)/Sqrt[x^2 + y^2 + z^2]*h,
  6. vz + (-G M z)/Sqrt[x^2 + y^2 + z^2]*h,
  7. x + vx*h, y + vy*h, z + vz*h}
  8.  
  9. DataNewton = NestList[NewtonGrav, {1, 1, 1, 1, 1, -1}, IntegerPart[n]];
  10. DataPlot = Table[Drop[DataNewton[[i]], 3], {i, 1, Length[DataNewton]}]
  11.  
  12. {{1, 1, -1}, {1.1, 1.1, -0.9}, {1.19423, 1.19423, -0.794226},
  13. {1.28233, 1.28233, -0.683445}, {1.36404, 1.36404, -0.568408},
  14. {1.43913, 1.43913, -0.449845}, {1.50744, 1.50744, -0.328455},
  15. {1.56884, 1.56884, -0.204907}, {1.62326, 1.62326, -0.0798366},
  16. {1.67063, 1.67063, 0.0461538}, {1.71094, 1.71094, 0.172492}}
  17.  
  18. Show[Graphics3D[Point[DataPlot[[1]]]],
  19. Graphics3D[Point[DataPlot[[2]]]], Graphics3D[Point[DataPlot[[3]]]],
  20. Graphics3D[Point[DataPlot[[4]]]], Graphics3D[Point[DataPlot[[5]]]],
  21. Graphics3D[Point[DataPlot[[6]]]], Graphics3D[Point[DataPlot[[7]]]],
  22. Graphics3D[Point[DataPlot[[8]]]], Graphics3D[Point[DataPlot[[9]]]],
  23. Graphics3D[Point[DataPlot[[10]]]], Graphics3D[Point[DataPlot[[11]]]]]
  24.  
  25. Show[Graphics3D[Line[{DataPlot[[2]], DataPlot[[1]]}]] ,
  26. Graphics3D[Line[{DataPlot[[3]], DataPlot[[2]]}]] ,
  27. Graphics3D[Line[{DataPlot[[4]], DataPlot[[3]]}]] ,
  28. Graphics3D[Line[{DataPlot[[5]], DataPlot[[4]]}]] ,
  29. Graphics3D[Line[{DataPlot[[6]], DataPlot[[5]]}]] ,
  30. Graphics3D[Line[{DataPlot[[7]], DataPlot[[6]]}]] ,
  31. Graphics3D[Line[{DataPlot[[8]], DataPlot[[7]]}]] ,
  32. Graphics3D[Line[{DataPlot[[9]], DataPlot[[8]]}]] ,
  33. Graphics3D[Line[{DataPlot[[10]], DataPlot[[9]]}]],
  34. Graphics3D[Line[{DataPlot[[11]], DataPlot[[10]]}]]]
Add Comment
Please, Sign In to add comment