Leanpub Header

Skip to main content

Orbital Mechanics with R

Simulating Planets, Binary Stars, Chaotic Systems, and the N-Body Problem with orbitr

Orbital Mechanics with R
This book is 100% completeLast updated on 2026-10-16

What keeps planets locked in graceful ellipses instead of spiraling into space? Orbital Mechanics with R takes readers beyond formulas and into a hands-on universe where every law of motion is derived, tested, and visualized through simulations they can run themselves.

Blending physics, astronomy, and computation, the book explores everything from Kepler's laws and binary stars to chaotic triple-star systems and retrograde motion. Rather than treating orbital mechanics as abstract mathematics, it turns the subject into a laboratory where readers can watch gravity unfold, measure its consequences, and discover where simple Newtonian models succeed, fail, and reveal deeper truths.

Whether you're an R user curious about physics or a physics student eager to compute, this book offers a rare combination of rigorous derivation, real astronomical applications, and fully reproducible code that brings the mechanics of the cosmos to life.

Free With Membership

With Membership

Free!

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
About

About

About the Book

Orbital Mechanics with R is a physics book that uses a simulation the way a lab course uses a bench. It is built on orbitr, an R package for simulating gravity: give it masses, positions, and velocities, and it steps Newton's laws forward and returns a tidy table of where everything went. The package's documentation shows you how to drive it. This book is about everything the documentation leaves out.

Every result is derived on paper and then checked against a simulation you can run yourself. Why does the Velocity Verlet integrator keep a planet on a closed ellipse for a million years when the textbook Euler method spirals it away? Where does the circular-orbit speed (GM/r}^(1/2) come from, and how does that one formula, pushed a little further, give you Kepler's three laws and the velocity formulas that build a binary star? What does gravitational softening actually do to the force law, and when should you use it? What makes three bodies chaotic when two are not?

The second half turns the physics loose on real astronomy: verifying Kepler's third law across the solar system and weighing the Sun with it, building the circumbinary planet Kepler-16b from conservation of momentum, watching Mars go retrograde from Earth's point of view, measuring how fast a chaotic triple star forgets its initial conditions, resolving a comet's perihelion passage, and reading a simulation's conservation laws to decide whether to trust it. The last part looks under the hood at the C++ engine and at the places where a point-mass Newtonian model stops being enough.

Who it is for. R users who want to understand the physics, and physics and astronomy students who want to compute. You need calculus and vectors; you do not need to know R. An appendix takes you from nothing to running the book's code, and another collects every piece of mathematics the derivations assume. Every figure in the book was produced by the code printed beside it.

About this edition. The full text is free to read online at book.orbit-r.com, and always will be. This edition is for readers who want a PDF of their own, priced at whatever you think it is worth. The book is written for orbitr 1.0.0, which is on CRAN.

Share this book

Author

About the Author

David Rosenman

I'm a software engineer and data scientist with a B.S. in Physics from The College of New Jersey, and I'm currently working toward an M.S. in Computer Science at Georgia Tech, specializing in artificial intelligence. By day I'm an Infrastructure and Operations Engineer at Optum.

I started my career in R at the New Jersey Department of Environmental Protection, where I was the lead programmer on the state's 2016 Integrated Water Quality Assessment Report and built the R application that downloaded and assessed the water quality data behind it. Since then most of my work has combined SQL Server with R and Python.

I'm the author of orbitr, an R package for simulating gravity — planets, binary stars, and the N-body problem — and of other open-source packages on CRAN and PyPI. Orbital Mechanics with R is the book that explains what the package does and why: the physics behind every function, derived and then checked against the simulation. The full text is free to read at book.orbit-r.com; this edition is for readers who want a copy of their own.

I live in Newtown, Pennsylvania, with my wife, Kerry.

Package documentation: orbit-r.com

Code: github.com/DRosenman

Everything else: daverosenman.com.

Contents

Table of Contents

Learn orbital mechanics through physics, simulation, and R. Derive Kepler's laws, model planets and stars, and test every result with code.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub