Talks

Simplify Challenging Software Problems with Rocket Science

Simplify Challenging Software Problems with Rocket Science

by Bradley Grzesiak

In the video titled "Simplify Challenging Software Problems with Rocket Science," Bradley Grzesiak shares insights from his experience in aerospace engineering to address complex software engineering challenges. Grzesiak argues that both aerospace engineering and software programming, while often perceived to be mystical fields, utilize structured approaches to problem-solving.

Key points covered in the presentation include:
- Reducing Cognitive Load: Grzesiak emphasizes the importance of higher levels of abstraction in simplifying tasks. In aerospace, engineers often work with matrices and vectors, which can streamline complex calculations. In programming, using libraries like Ruby's matrix can similarly ease the burden of mathematical operations.

  • Visualization of Simulations: Visual graphics are crucial for understanding complex systems that exhibit high sensitivity to initial conditions. Grzesiak illustrates how visual simulations are employed to predict behaviors (e.g., vibration of rockets under different loads) and understand the effects on structures during launches. This parallels software testing, where recognizing patterns in complex systems is essential to avoid failures.

  • Controlling Real-World Processes: The video discusses the significance of feedback control systems. Grzesiak explains how using PID controllers allows for real-time adjustment of outputs based on input variations. This concept is vital in systems like meat curing or rocket thrust control, where environmental factors can significantly impact performance.

Throughout the talk, Grzesiak provides relatable examples, such as the complexities faced by NASA in thermal management and illustrations of gravitational interactions in simulations with celestial bodies. He concludes by encouraging engineers to leverage the structured problem-solving techniques from aerospace to enhance their software engineering practices.

00:00:24.720 Good morning, everyone. My name is Bradley Grzesiak, and I am the CEO of Bendyworks. Today, I'm going to share a few ways to simplify your challenging software problems using rocket science, of all things. You can find me on the internet as "bradgrzesiak" pretty much everywhere. I'm going to start off by sharing a quote from my friend Ash, who said, 'Whenever Brad is drinking, you want to make sure you're sitting next to him, because instead of being obnoxious, he teaches you orbital mechanics.' The thing Ash doesn't know is that you don't actually have to feed me beer to learn that.
00:00:37.920 So after my talk, at any time during the conference, if you want to learn all about rocket science, feel free to ask me. Just a quick note for anyone who has visual issues: there will be one animated GIF; it's pretty mild, so hopefully, it won't cause any issues. Today's agenda consists of three parts. First, I'm going to teach you how we in the aerospace industry reduce cognitive load. Second, we'll see how to visualize simulations with graphics, and lastly, we will discuss how to control and respond to real-world processes.
00:01:07.840 I worked for an aerospace company for a bit over five years, and during that time, nothing I worked on ever went to space. Then, five years after I left that company, something I worked on finally did go to space, so I do have some basis here. Let's begin by discussing how to reduce cognitive load. The main thing to understand is that we, as rocket scientists, are not actual superheroes. We just followed a structured path in school that taught us bit by bit what we needed to learn. Just like you in your programming careers have done the same, we learned tricks and techniques to tackle really difficult problems.
00:01:44.000 One of the main ways we do that is by using higher levels of abstraction. If that sounds familiar at all to you, in programming, we typically use higher-level abstractions for dealing with things that are engineering-like or graphics-like. For instance, in programming, we'll often use simple primitives such as x, y, z for position. If we need to find the magnitude of a vector, we might use square root and Pythagoras' theorem. When we need to add two positions together, we might use zip plus map.
00:02:09.760 When it comes to rocket science, we've solved these issues mathematically, so instead we use matrices and vectors. You can simply find the magnitude, which is built into the Ruby standard library, if you require the right library. On the third line, you can see vector one plus vector two. If you use regular Ruby arrays, that will just concatenate them, resulting in a six-element array instead of an array of three, which is completely useless if you're trying to add vectors. Similarly, multiplying a matrix by a vector is really hard with just standard Ruby. But if you use the right libraries, you can just perform the multiplication.
00:02:59.200 The interesting thing about the multiplication of matrices and vectors is that the term 'times' is actually one of the most complicated terms in this context because it is overloaded in mathematics. A vector is essentially an array, and a matrix is an array of arrays. Now, let's discuss why we would ever want to use matrices and vectors in computer science problems. They are primarily used for linear transformations, which we see frequently but are simplified for our use to be more easily accessible as programmers.
00:03:55.920 For example, in CSS3, you have the transform key and can apply scale, rotate, and skew. Under the covers, these transformations are actually using a matrix times a vector. In rocket science, we often utilize this concept in kinematics and kinetics. I'm going to show you how a matrix interacts with a vector. To make it easier to understand, I'll simplify it to two-element vectors and matrices instead of three, which we would typically use.
00:04:28.000 The way I remember manually multiplying a matrix by a vector is to take the vector, rotate it up, and pass through the multiplication and vector addition as you proceed through the matrix. It's actually very simple. Fortunately, we use higher levels of abstraction, so we never have to implement this manually. If you were trying to do this from scratch in Ruby, you might implement it on the left; however, the standard library has a library called 'matrix.' You can just pull that in, which includes both matrices and vectors.
00:04:55.920 The nice thing is you don't even need a matrix times vector method because you can literally just multiply them together. This functionality takes care of dimensions for you. If your dimensions don't match up and you try to multiply them, your solution on the left might accidentally multiply them together without raising an error, while on the right it will notify you of a mismatch. One example of a linear transformation is the rotation matrix. Although it includes some trigonometry, you do not actually have to implement it manually; it's integrated into the libraries.
00:05:51.600 If you take the rotation matrix and set theta for a 30-degree rotation times a vector of (1,0), it converts the coordinates to approximately (0.866, 0.5). You can see the results if you have a 90-degree rotation. In summary, if you want to rotate something by 30 degrees, you can think of it as treating an image as a long vector. This is how we reduce cognitive load by utilizing tools provided by mathematics and maintaining higher-level abstractions.
00:06:06.240 Whenever you transform something in the domain of the real world and want to simulate it on a screen, you can utilize linear transformations, matrices, and vectors. Moving on, we're going to talk about visualizing simulations with graphics. Why would we want to do this? The main reasons I can think of, which I used back in my days as an aerospace engineer, include dealing with complex systems where there is high sensitivity to inputs. If you change one parameter slightly, it can lead to catastrophic failures.
00:06:56.000 For example, consider a screw hole close to the edge of a plate: if you shift it just a bit too far, the whole assembly could fail. Another reason is that there is often a need for pattern recognition, which computers are terrible at, while humans are good at it. Additionally, we typically look for solutions that are 'good enough.' It doesn't have to be perfect, but we want to avoid critical failures. In software engineering, you can equate this to testing: we operate with complex systems that have high sensitivity, and one mistake in your code can lead to test failures.
00:07:28.960 In aerospace engineering, we used graphical simulations to implement all these concepts. When launching an object into space, it faces numerous frequencies at various magnitudes, with the engines producing significant noise that affects the entire structure. As speed increases within the atmosphere, the craft experiences 'max q,' which refers to the point of highest aerodynamic load that can lead to significant shaking of the vehicle due to vibrations.
00:08:00.880 Rocket designers have established spectral analyses. If you place an object on a rocket, you can predict what to expect in terms of stress and vibration. This highlights the importance of simulations in understanding how things will behave under real-world conditions, such as zero-gravity conditions, where simple actions like kicking can produce significant effects.
00:08:32.239 NASA faced thermal equilibrium challenges early on with satellites. Typically, one side faces the sun while the opposite side cools down, leading to heat management issues, which NASA notably addressed using innovative heat pipe technology. The goal is always to account for safety factors, ensuring that structures can endure stress beyond normal limits. Lastly, the 'n-body' orbital mechanics, studying how bodies interact via gravitational forces, is academically fascinating. The n-body problem is driven by Newton's three laws, with most practical solutions deriving from a binary basis.
00:09:30.480 Closed-form solutions exist only for two-body systems. As you introduce more bodies, the complexity increases, and very few predictable motions arise unless specific conditions apply. Thus, the n-body problem poses challenging questions that even experienced mathematicians find hard to resolve. The fundamental components needed to evaluate the n-body problem include understanding the force of gravity and how various laws of motion intertwine to define acceleration, velocity, and position. Each concept must consider vector representation, as highlighted earlier.
00:10:27.920 To simplify these systems for better comprehension, we focus on the basics surrounding derivatives and calculus. In essence, derivatives help assess changes in position and velocity over defined time intervals. We can assume small time increments yield insightful approximations regarding velocity and position adjustments over time. This approach makes complex understanding more manageable, with division at the forefront of most calculations.
00:11:08.000 Let's illustrate this with Ruby, a programming language where clear-cut representations make handling these mathematical components far easier. The key takeaway is focusing on the 'gravity' aspect of these algorithms. Although the physics might seem daunting due to the complexities of instantaneous force build-up, ultimately, implementing these lines in a program can appear quite straightforward to those familiar with the language.
00:12:14.000 I'm going to demonstrate this with a simulation that features celestial bodies interacting in real-time. Using graphical representations as physical analogies offers tangible representations of our theoretical computations. Beyond merely computational, these examples yield a visual understanding of how celestial mechanics function so elegantly, even while adhering to relatively simple mathematical equations governing their interactions.
00:13:13.600 As I demonstrate the simulation, you’ll see the sun, Jupiter, and a comet traveling through space. You will observe interactions play out in real-time, visualizing how gravitational forces affect the trajectories as the comet approaches Jupiter. This demonstration highlights how math manifests itself through computer simulations into visual displays of gravitational behavior.
00:14:00.000 Next, we’ll shift our focus to controlling and responding to real-world processes. The reality of the world presents complexity that often challenges control systems. Within physics courses, idealized conditions allow us to neglect factors like air resistance. However, in real-world scenarios, all these perturbations must be considered for effective control mechanisms. This is where reacting to the environment rather than attempting to solve problems ahead of time becomes critical. It’s akin to feedback systems: if you want a desired output, you’d set a controller that interprets sensory data and adjusts actions accordingly.
00:15:45.760 For example, if you're curing meat, you'd write code to keep track of humidity levels—should you turn the dehumidifier on or off based on current metrics—or if you're managing rocket thrust control, assessing thrust requirements dynamically builds a layer of complexity. Using PID (Proportional, Integral, and Derivative) controllers helps manage this by continually adjusting outputs in response to input variations.
00:16:15.760 This feedback loop minimizes error margins, ensuring the essential outputs are maintained in stable ranges. Despite its complexity, these controls can be effectively codified in straightforward programming structures. Through iterative testing, developers can simply refine settings and algorithms until the necessary performance is achieved.
00:17:06.080 Let’s end with a brief demonstration incorporating controller functionality, similar to the well-known Kerbal Space Program, which employs similar feedback principles. By connecting Ruby scripts to manage altitudes and throttle settings, the program showcases automated ascent based on feedback systems. Through live simulation, we can see how a rocket manages its throttle to achieve a stable altitude, showcasing not just computational precision but also the beauty of real-time physics in play.
00:18:20.560 The culmination of these principles offers impactful insight into bridging aerospace concepts with everyday software challenges. Similar to the way we monitor rocket fuel consumption and adjust thrust in flight simulations, these lessons mirror our need to adapt effectively in software environments, ensuring optimal performance while gracefully handling the complexities surrounding various engineering challenges.
00:19:06.560 Thank you for your attention. The code related to this presentation will be available on GitHub and shared via Twitter. I hope you find valuable insights throughout, especially how aerospace engineering and rocket science principles can be utilized to tackle challenging software problems. Remember, behind every problem you encounter, there's often a simplified solution waiting to be discovered.