transcribe

Chapter 8.5 - Implementation of Shooting and Convergence Studies

Nathan Kutz · 19m · transcribed Jul 2026
More from Nathan Kutz Business
𝕏 Share ▶ YouTube 📥 PDF 🤖 .md

Section Insights

# 0:00

Introduction to the Shooting Method

What is the shooting method and its application?

The shooting method is introduced as a technique to find eigenfunctions and eigenvalues for boundary value problems, specifically applied to the Schrödinger equation in quantum mechanics.

  • The shooting method constructs an algorithm for boundary value problems.
  • It is particularly useful for solving the Schrödinger equation related to quantum mechanics.
  • The method involves finding eigenvalues and eigenfunctions.
# 0:01

Understanding the Potential and Boundary Conditions

What are the potential and boundary conditions in the problem?

The potential is described as an upside-down parabola, with boundary conditions set to zero at x = 1 and x = -1, simplifying the problem for practical solutions.

  • The potential function is crucial for defining the problem.
  • Boundary conditions significantly influence the solution approach.
  • Simplifying boundary conditions aids in practical problem-solving.
# 0:03

Formulating the First Order System

How do we convert the second order differential equation?

The second order differential equation is rewritten as a system of first order equations, which allows for easier implementation of boundary conditions.

  • Transforming to first order equations is essential for numerical methods.
  • Boundary conditions must be specified in the new variable system.
  • This transformation is a standard approach in differential equations.
# 0:04

Exploring Eigenvalue Solutions

What is the significance of varying the parameter beta?

Varying the parameter beta changes the shape of the function, leading to different eigenvalue solutions, which can be visualized through simulations.

  • Beta is a key parameter that influences the solution's shape.
  • Simulations help visualize the impact of changing beta.
  • Multiple eigenvalue solutions exist for varying beta values.
# 0:07

Algorithm Structure for Finding Solutions

What is the structure of the algorithm to find eigenvalues?

The algorithm consists of nested loops to iterate through beta values, with conditional statements to check for solutions and update beta accordingly.

  • A clear algorithm structure is crucial for coding success.
  • Nested loops and conditional statements form the backbone of the solution-finding process.
  • Understanding the algorithm before coding is essential.
# 0:10

Flowchart for the Algorithm

How does the flowchart aid in programming the algorithm?

The flowchart visually represents the logic structure of the algorithm, guiding the programming process and ensuring clarity in the steps involved.

  • Flowcharts help visualize the logic before coding.
  • They clarify the sequence of operations in the algorithm.
  • Using flowcharts can prevent programming errors.
# 0:12

Defining the Differential Equation

What are the initial conditions and parameters for the differential equation?

The right-hand side of the differential equation is defined, including parameters like beta and tolerance, which are crucial for solving the equation accurately.

  • Defining initial conditions is critical for accurate solutions.
  • Tolerance levels determine the precision of the solution.
  • Parameter selection impacts the behavior of the differential equation.
# 0:15

Implementing the Code

What are the key components of the code implementation?

The code includes loops for modes and beta values, conditional checks for solutions, and logic for updating beta based on the results of the differential equation.

  • Code implementation requires careful structuring of loops and conditions.
  • Updating parameters based on results is essential for convergence.
  • Understanding the logic behind the code enhances programming effectiveness.
# 0:18

Normalizing the Solutions

How are the solutions normalized?

The solutions are normalized by ensuring the area under the curve of the function is equal to one, which is a standard practice in quantum mechanics.

  • Normalization is a key step in obtaining valid solutions.
  • It ensures that the solutions meet physical requirements.
  • Understanding normalization is important in quantum mechanics.

Transcript

0:07 So now I'm going to proceed to implementing the shooting method and talk about how we would actually construct an algorithm to find for instance IGEN functions and IGEN values of a boundary value problem. So this code is going to walk us through the different structures for how to do this based upon the last lecture and the last problem that we solved. So this is what we were looking at. We were looking at solving the Schroinger equation. The Schroinger equation again emerges out of quantum mechanics as well as electronamics for what are called guided waves and waveguides. So we have here two derivatives in x. We have some function n of x. So if if you look at it from the quantum mechanics point of view this is what's called the potential and then and this is your igen value and notice I've already placed these here beta n f event these are different values and igen functions and what we're going to find is the first five so beta 1 beta 2 beta 3 beta 4 beta 5 along with the corresponding functions okay the potential itself is this upside down parabola so it's zero outside of one but This thing here has a maximum of one at the origin and then it's a parabola that drops down to zero at plus and minus one and zero everywhere else. The boundary conditions are stated right here.

1:30 Boundary conditions as I go to plus and minus infinity are going to be zero. So this becomes important. We talked quite a bit about this last time. It's like this actually has how do you impose boundary condition like this because obviously we're not going to go out to infinity or minus infinity. We're going to solve this on a finite domain. And we talked about in the last lecture how you would actually impose these kind of boundary conditions in practice. But we're going to actually simplify this even further for now for the ex for the examples we want to do, which is we're going to take very simple boundary conditions. Not that the boundary conditions are going to zero, but let's actually for now simplify it to make that the boundary conditions at x= 1 and x= -1 are in fact zero. Okay. So, if we write this as a system of first order equations, remember that's always going to be something you're going to have to do. If we go back here, go back here, we're going to write the second order differential equation as two first order differential equations. And then we're going to have to specify the boundary conditions in those new variables. So, this is what it looks like in this new coordinate system. X dot equals 2. Here is the first order system of equations for fi1 and fi2 which are or x1 and x2 which are the the function and its derivative. Here are the boundary conditions at x= to 1. You that's x1 at one is zero. Here's the second boundary condition which leads to x1 at minus1 is zero. So I'm solving is this differential equation with these boundary conditions here. So first order differential equation these two boundary conditions. And so normally what we did in the shooting method is we change the launch angle to see how does it land on the other side. Except for now this is an igen value problem. And it turns out if you change the launch angle if you just simply double the amplit double the angle from let's say some angle a to 2 a it basically produces the same shape just twice as big. So it turns out we're not going to change the angle of the launch essentially. What we're actually going to change instead is the parameter beta here. The iggonite. That's the thing that really changes the shape of the function we're going to get out. And what we're trying to do is launch from one side, get to the other side. Launch from zero, land at zero. Okay? And have a non-trivial solution. I mean, the trivial solution is easy to this. Put x equals z. It's a solution. But we're trying to find non-trivial solutions.

4:01 Solutions whose area under the curve are normalized. So in other words, area one. And so let's play around with the parameter beta right here. So I'm going to show you some examples where of solving this OD where I launch at zero and see what happens as I change beta. So here's a couple pictures. Let me walk through what these are. And this helps guide the intuition of how we should building our our our launch algorithms or our search algorithms for these functions. So let me start here. There's two simulations done for beta is 98 and beta is 95. The beta is 98. Notice what it does. It comes up and over and it lands above zero. So when I go over to the other side, I'm above zero, but beta is 95. When I launch, it's below zero.

4:50 So somewhere between beta is 95 and 98. I was above I was below. So somewhere in between there is the right value of beta. So you might say, well, look, I've got one possible solution. Turns out there's many possible solutions because I'm going to show you over here what happens between beta is 95 and 85. When I launch across and beta is is 95. I'm below. But notice what happens. Beta's 85 now does a little it comes over, turns, and comes back up and it's above zero again. So this is this curve right here, the dotted line. Notice I'm above zero again. So somewhere between beta's 85 and 95 there's a second solution but this one the first solution comes up and over and lands. Second one comes up down comes back up. And in fact here is sort of a precursor to what we're looking for. Solutions that look like this. The first solution comes up and over. There are in fact no zeros or no zero points on the way over. The second solution goes up down and up again. There's one zero crossing. Okay. That's this solid line here. The third solution comes up, down, up. So, it's two crossings and over to zero. So, there's a multitude of solutions for different beta values. So, the first thing we have to think about is when I start lowering the beta values, at first I start here, I get to one solution. As I keep lowering them, they come down and then back up. That's a second solution. I keep lowering it, comes back up. Third solution, fourth solution. So we're going to have a multitude of solutions to go after for us. And so when we do this search algorithm, we're going to look for the first five functions and IGEN values.

6:32 And we're going to have to write a routine to do this. So first of all, let's count what or let's estimate what's going to have to happen in this algorithm. I'm going to have to walk through beta values. That's the first thing. So that's going to be an iteration loop. I have one for loop that's going to walk through beta values. Keep changing beta to find the solution. I'm going to have two if statements in there. The first if statement is going to ask, did I actually find a solution? In other words, am I within some tolerance? I launched over there. I landed on the boundary within 10us 5 or 6 or 4, whatever I want to pick. First thing I should ask is, did I find the solution?

7:13 If so, get out of the loop. So, I'm in this loop changing beta. I have an if statement to say if I have a solution, stop. And then I have to have a second if statement to tell me how do I change beta to find the solution. So notice what happens in this first set here, the first solution. I keep lowering beta till I get through zero. And if I go too far, I have to come back up and then I have to essentially we're going to do a bisection to zoom in on the value of the beta. So right away I have an algorithm for how to change beta.

7:50 Okay. So I have two if statements within the for loop. Now the reason I mention this is because part of your job in this is to create the logic structure that's going to get you these solutions. So you have to know ahead of time even before you start programming anything. What does the logic structure have to look like? There's a for loop. Okay. And by the way, there's actually two for loops because I'm I ask you to find the first five solutions. So I do the first one, second one. So there's a for loop with to go through five to try and find five solutions. There's a for loop with the beta inside of it. So there's a for loop, which is the through the betas. Inside of that, I look through the betas. Inside of that, there's two if statements. One to tell me stop if I find solution. One to update the value of beta. So I know all of this. ahead of time. Okay. And part of how you get this knowledge is by actually simulating the system to see what the behavior is like and then you'll have a good idea of the logic structure you have to create. It's very difficult to write a code or a program if you don't even know what you're trying to find or how many for loops and if statements and where they should be.

9:05 So first thing you have to do is have some enough understanding of your code and what you're trying to do to be able to build that. Okay. Okay, so now we have that or at least this is a a way to think about it. Let's actually get to this kind of diagram here, right? Which is kind of our flow structure, right? So this is we're going to start off here with some initial setup here. We're going to pick a launch angle A. Once we choose that, we're going to choose beta. So right here is the beta loop. In that beta loop, we're going to walk through and keep updating the updating the beta value. So, first thing we're going to do is choose a beta, solve the differential equation.

9:44 In other words, start from the left, march it to the right side of the domain, have an if statement, say, did we actually get this correct, the correct beta? If we did, and if we got it right, we can get out of this loop, come back out here, and we're going to pick, for instance, a different value of beta. Okay? Alternatively, if it's not converged, we didn't find a solution, you update the beta. So you stay in the beta loop until you find a solution.

10:12 Once you find one, now you come back up. Then you redo it. Look for the next value of beta. So it's often really important to have a flowchart like this done before you start programming. Don't just start programming. You have to know what you're actually trying to do and set up the logic structure. This is the logic structure of what we're trying to do. I explained it in words. You can draw it out in something like this.

10:35 So let's start off then build up some of the basic architecture. So first of all we're going to start defining our right hand side. This is just defining our our differential equation right here. Right? So this is our first order system of differential equations. There's the beta and we're picking the n instead of it being a parabola. We're just going to pick it to be a constant and not which is I think we picked it to be 100. Okay.

10:59 We define a tolerance. The tolerance here is how do I know I have the right solution when I hit the other side? Well, you're never going to hit it exactly, but you're going to hit it within some some tolerance. And that tolerance here is picked to be 10 - 4. You can make it smaller, bigger, whatever you like. We're also going to pick some colors to plot some things. So once we get all five solutions, we're going different colors. I picked the n to be 100. Here's my boundary conditions here. So my a value, my launch angle is going to just be one. I can actually it's pretty easy to show that you can pick it to be anything because it's it's a linear system. So if I double this, you get the same solution that you did if you have a= 1= 2. It's all the same, just different area under the curve. So we just pick it to be one as a generic way to do it. Here's your launch condition.

11:51 You start off at zero with angle A and you're going to go on the domain 1 to one. Okay? Okay. And then we're going to define a linear space. So I'm going to go across this domain with a th00and points. So when I get my solution out have a,000 points in that solution. Now we come to the code. The code itself is start off with a start value beta is knot. And so we're going to start our beta value. Remember when we showed you that picture? We're going to start off with 100. We're going to keep lowering the beta value.

12:23 Remember it was I showed you that at 98 it was above, at 95 it was below. So I just keep going to keep lowering it. So what I'm started at some value 100 is the starting point for this. And notice what I have here. The first for loop is the modes loop for one to six. So what we're going to go through here is going to go through it. And remember it's Python. So it's going to go 1 2 3 4 5. I want five functions.

12:50 That's what this first modes loop is going to do. So I'm going to walk through. That's the first for loop. Within that for loop, I pick the the beta value that I'm going to start with, which originally started with 100. And then I'm going to decide how I'm going to change beta. That's what the db beta parameter is here. And I picked it to be one initially. So I start off at 100. I then 99 98. I just keep 97. I just keep walking it down. That's what I'm going to do here with the d beta. And it's going to be done in this loop here. So let's walk through and do this thing. So now here's the for loop that's inside that's going to update the beta values.

13:27 So first thing is I go call the differential equation solver which is start off that launch condition get it to the other side. That's what this thing does here. Now once I'm in the other side I'm going to ask a couple questions. First of all when I get to the other side did I end up at zero or with am I close enough to zero within the tolerance to stop? If I am here's the break. So there's the first if statement is did I get the solution to within 10 - 4 because we picked tone to be 10 - 4. So that's the first if statement right here.

14:00 If I take off with a beta value and I land at zero within 10 - 4, that's a solution and I should stop. That's the first solution. And I'm going to come back out and then go look for the next beta value. But for right now, that's what I start with. If I didn't hit it with 104, how do I update the beta value? And here's how you would do it. So if I'm above this thing, I'm going to lower debt. So I'm start off beta's 100, 99, 98, 97, 96. Once I go below zero, I have to come back up. But I go back to where I was and start cutting the debate in half. So this is what I do here. The beta beta is going to come halfway back up. I'm going to cut the debate the the beta, which was one, to a half. So I'm just bicting the deba. So as I come down, I go past, I come back up and I zero in. And the way I zero in is I keep having to cut the deba down to refine it so that I get across here and I satisfy this condition to get out of the loop.

15:02 This condition means I got over to the other side and hit zero. So there's the first statement. Did I hit it? Second statement. Here's how I update the beta values to do this. Now once I find one of the solutions, okay, so in other I go down down down down, I hit one of the solutions, I'm going to go look for the next solution, which means if my solution was at a value, let's say 97, then I'm going to go look for the next one, which is below it. So I start off here after I've done this, I start off here and I say my beta start now is going to be whatever the beta value I found here and I'm going to lower it by 0.1. I'm going to redo the d beta back up to one. So remember, you kept cutting your deba down, but now when you're going to go look for the next mode, you're going to bring your deba back up to one and you start with your new beta start value. And then you go through this process again to find the second mode, then the third mode.

15:54 One last piece of this is this minus one to the modes plus one. I want to talk about this little piece of code which is right there. So when I look for the first mode, I'm lowering beta to find it. So I'm coming as I lower beta I'm coming down on the solution. But in the second mode I'm going the opposite direction. So now I'm coming back up. So as I lower beta I come up on the solution. So what this is doing here is telling me am I coming up or down on the solution? And the sign changes. I'm coming down or I'm coming up. And so you need to have this here to tell you whether you should be above or below. So in other words, if I'm below the solution on the second mode, I should lower the beta. If I'm above on the second on the first solution, I lower the beta. And so you see there's a sign switch there. And that's how you take care of that sign switch with that piece of code right there. So this little code, if you you can get it off the git, play around with it. But this is a really nice code because if you can understand this logic structure, it not only will teach you a lot about coding, it'll teach you a lot about kind of the infrastructure you need. The two for loops with two if statements embedded within them. And at the very end, you normalize the solution by just making sure that the area under the square of that function is one across the domain.

17:21 And that's all I've done here for the normalization. And here's what the solutions look like. These are the first igen functions of if you want to call this a particle in a box if you're in quantum mechanics. This is what the first five look like. The first one is this cyan looking one. The yellow one is the second mode. And each mode you add does another zero crossing that's there. And that's also well understood from quantum mechanics and stomal theory. But we get this just from simulation. So now what you end up doing is you can do very sophisticated boundary value problems with this architecture and very sophisticated function value solves. So instead of just I have to you know maybe there's some somebody worked this out for very simple cases this particle in the box you can actually analytically find these solutions but for most more complex systems or more complex igen value problems you won't be able to write down an analytic solution. So you have to have recourse to a simulation engine like this to get you the solution. So this piece of code again it's on the git. You can download it and it's a first implementation. But the main thing you have to understand is you're responsible for creating an architecture, a logic structure and a flow that will actually go and recursively look for this thing. So that before you start writing the code, make sure you sketch that out. Make sure you sketch out the logic and then build your code around that logic. Okay, so that's how you would do this. We implemented the shooting routine and did some convergence studies on it.

19:06 >>

Summary

The lecture discusses the implementation of the shooting method to find eigenfunctions and eigenvalues of a boundary value problem, specifically focusing on the Schrödinger equation. The approach involves constructing an algorithm that iteratively adjusts parameters to find non-trivial solutions while adhering to specified boundary conditions.

- The Schrödinger equation is used to model quantum mechanics and guided waves in waveguides.
- The potential is represented as an upside-down parabola, with boundary conditions set to zero at x = ±1.
- The second-order differential equation is transformed into a system of first-order equations.
- The shooting method is employed by varying the eigenvalue parameter (beta) instead of changing the launch angle.
- Multiple solutions exist, with the first solution having no zero crossings and subsequent solutions exhibiting one or more crossings.
- The algorithm consists of nested loops to iterate through beta values and check for solutions within a defined tolerance.
- A flowchart is recommended to visualize the logic structure before coding, ensuring clarity in the algorithm's design.
- The final output includes the first five eigenfunctions, demonstrating the ability to solve complex boundary value problems through simulation.

Questions Answered

What is the shooting method and its application?

The shooting method is introduced as a technique to find eigenfunctions and eigenvalues for boundary value problems, specifically applied to the Schrödinger equation in quantum mechanics.

What are the potential and boundary conditions in the problem?

The potential is described as an upside-down parabola, with boundary conditions set to zero at x = 1 and x = -1, simplifying the problem for practical solutions.

How do we convert the second order differential equation?

The second order differential equation is rewritten as a system of first order equations, which allows for easier implementation of boundary conditions.

What is the significance of varying the parameter beta?

Varying the parameter beta changes the shape of the function, leading to different eigenvalue solutions, which can be visualized through simulations.

What is the structure of the algorithm to find eigenvalues?

The algorithm consists of nested loops to iterate through beta values, with conditional statements to check for solutions and update beta accordingly.

How does the flowchart aid in programming the algorithm?

The flowchart visually represents the logic structure of the algorithm, guiding the programming process and ensuring clarity in the steps involved.

What are the initial conditions and parameters for the differential equation?

The right-hand side of the differential equation is defined, including parameters like beta and tolerance, which are crucial for solving the equation accurately.

What are the key components of the code implementation?

The code includes loops for modes and beta values, conditional checks for solutions, and logic for updating beta based on the results of the differential equation.

How are the solutions normalized?

The solutions are normalized by ensuring the area under the curve of the function is equal to one, which is a standard practice in quantum mechanics.

© transcribe · For agents Built with care and craft by Gokul Rajaram