Help understanding this extrapolation technique

  • Context: Graduate 
  • Thread starter Thread starter lostinphysics44
  • Start date Start date
  • Tags Tags
    Extrapolation
Click For Summary

Discussion Overview

The discussion revolves around understanding an extrapolation technique used in numerical methods, particularly in the context of solving differential equations related to bubble dynamics. Participants explore the implications of this technique on stability and accuracy, as well as its application in MATLAB for plotting radius changes over time as pressure varies.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related
  • Debate/contested

Main Points Raised

  • Some participants explain the Taylor expansion of a function in time, showing how the extrapolation technique can achieve accuracy to ##\mathcal{O}(h^3)##.
  • Others argue that while the method improves stability compared to forward difference methods, accuracy remains dependent on the sample rate.
  • A participant questions how to implement the technique in MATLAB to plot the radius change over time, seeking clarification on the steps involved.
  • Some participants discuss the need to approximate derivatives and the potential loss of accuracy when doing so.
  • There is mention of a specific equation from a paper that relates bubble size to various factors, prompting a discussion on how to integrate this into the extrapolation technique.
  • Participants share a MATLAB code snippet for approximating the radius and its derivative, emphasizing the importance of initial conditions.
  • Some participants express uncertainty about how to calculate derivatives for the averaging formula and seek clarification on the MATLAB implementation.

Areas of Agreement / Disagreement

Participants generally agree on the technical aspects of the extrapolation technique and its implications for stability and accuracy. However, there are multiple competing views regarding the best approach to implement this in MATLAB, and the discussion remains unresolved on certain specifics of the calculations and assumptions required.

Contextual Notes

Participants note that assumptions about initial conditions, such as the starting bubble radius, are necessary for the calculations. There is also mention of potential limitations in accuracy when approximating derivatives.

lostinphysics44
Messages
36
Reaction score
0
upload_2016-5-20_8-15-57.png

upload_2016-5-20_8-16-25.png
upload_2016-5-20_8-13-49.png

upload_2016-5-20_8-14-5.png


Trying to understand what is going on here, and how this technique removes the dependence of sample rate from the solution.
 
Physics news on Phys.org
If you Taylor expand out the function in time, you get for time step h:
##r(t+h) = r(t) + h r'(t) + \frac{h^2}{2} r''(t) + \frac{h^3}{3!} r'''(t)...\\
r(t - h) = r(t) - h r'(t) + \frac{h^2}{2} r''(t) -\frac{h^3}{3!} r'''(t)... \\
r(t-2h) = r(t) - 2h r'(t) + \frac{4h^2}{2} r''(t) -\frac{8h^3}{3!} r'''(t)... ##
##3r(t) - 3r(t-h) + r(t-2h) = r(t) +h r'(t) + \frac{h^2}{2} r''(t) -\frac{5h^3}{6} r'''(t)... ##
So you can see this scheme is accurate to ##\mathcal{O}(h^3). ##

The benefit of this method is that it looks like an semi-implicit method, which should become stable regardless the sample rate. The accuracy will still be dependent on sample rate, but the stability is much improved compared to forward difference methods.
 
RUber said:
If you Taylor expand out the function in time, you get for time step h:
##r(t+h) = r(t) + h r'(t) + \frac{h^2}{2} r''(t) + \frac{h^3}{3!} r'''(t)...\\
r(t - h) = r(t) - h r'(t) + \frac{h^2}{2} r''(t) -\frac{h^3}{3!} r'''(t)... \\
r(t-2h) = r(t) - 2h r'(t) + \frac{4h^2}{2} r''(t) -\frac{8h^3}{3!} r'''(t)... ##
##3r(t) - 3r(t-h) + r(t-2h) = r(t) +h r'(t) + \frac{h^2}{2} r''(t) -\frac{5h^3}{6} r'''(t)... ##
So you can see this scheme is accurate to ##\mathcal{O}(h^3). ##

The benefit of this method is that it looks like an semi-implicit method, which should become stable regardless the sample rate. The accuracy will still be dependent on sample rate, but the stability is much improved compared to forward difference methods.
Would it be possible to plot the radius change over time in matlab? How would I go about doing that?
 
In the attachment, the equation marked (6.46) says
##\frac{dr_1}{dt} = f(\hat r _1, t_1).##
Do you know that function? If not, you can approximate the derivatives simply, but you lose some accuracy.Here is a rough code for the approximation:
-------------------------------------------------------------

function R = bubble(r0,r1,r2, N, dt)
% the output of will be a Nx2 matrix with the first column as the radius
% and the second column the first derivative in time. Inputs are the radius
% at three known times (r1,r2,r3), the number of timesteps (N),
% the step size (dt), and the function f.

%initialize with initial conditions
rnow = r2;
rnowless1 = r1;
rnowless2 = r0;

R = zeros(N+3,1);
R(1) = r0;
R(2) = r1;
R(3) = r2;
%timestep routine
for step = 1:N
% guess at rnext.
rhat = 3*rnow -3*rnowless1 + rnowless2; %eq 6.46 from text
rbardot = (rhat-rnowless1)/(2*dt); %this is the same as [(rhat-rnow)/dt + (rnow-rnowless1)/dt]/2
rnext = rnow + rbardot*dt;
R(step+3) = rnext; %save radius data.
% reset for new step
rnowless2 = rnowless1;
rnowless1 = rnow;
rnow = rnext;
end

plot(0:dt:(N+2)*dt,R);
end
 
  • Like
Likes   Reactions: lostinphysics44
RUber said:
In the attachment, the equation marked (6.46) says
##\frac{dr_1}{dt} = f(\hat r _1, t_1).##
Do you know that function? If not, you can approximate the derivatives simply, but you lose some accuracy.

The function is the overall bubble size as it relates to a variety of factors (pressure, time, viscosity, tissue tension, etc) I am trying to understand how to plot the radius over time as pressure changes. From what you explained it seems that at each dt there is a pressure (which I can set based on my ascent or descent rate) that I can plug into the equation and get a new radius of bubble. Am I supposed to calculate the output of that equation using the extrapolation technique you just explained?
upload_2016-5-24_8-30-43.png


So my steps in MATLAB as far as I can tell would be:
  1. Set dt timestep
  2. set pressure rate (PT in the equation, Po is the initial pressure)
  3. plug that into the 6.46 equation and solve to get a radius value
  4. use that radius value as the new initial radius and repeat until the time or pressure ends.
The paper I am reading says that dr/dt is a first order non linear differential equation solved using the trapezoid rule. Is that separate from what you described with your previous response?
 
That seems to work, remember that you are using the approximation ##\hat r_1 ## to approximate the derivative, so plug that estimate (based on prior r data) into the formula for dr/dt.
Once you have that estimate for dr/dt, you apply the averaging and approximation in 6.48 and 6.49.

Assuming you know the previous time data ##r_{i-1},r_{i-2},r_{i-3}##:
1. Set dt timestep.
2. Set pressure rate.
3. Calculate approximation ##\hat r_i## based on previous r information.
4. Use formula with pressure and ##\hat r_i## or ## r_{i-1}## to get ##\frac{dr_i}{dt}## and ##\frac{dr_{i-1}}{dt}##
5. Use equation 6.48 to get average rate of change for the timestep.
6. Use equation 6.49 to approximate ##r_i##.
 
RUber said:
That seems to work, remember that you are using the approximation ##\hat r_1 ## to approximate the derivative, so plug that estimate (based on prior r data) into the formula for dr/dt.
Once you have that estimate for dr/dt, you apply the averaging and approximation in 6.48 and 6.49.

Assuming you know the previous time data ##r_{i-1},r_{i-2},r_{i-3}##:
1. Set dt timestep.
2. Set pressure rate.
3. Calculate approximation ##\hat r_i## based on previous r information.
4. Use formula with pressure and ##\hat r_i## or ## r_{i-1}## to get ##\frac{dr_i}{dt}## and ##\frac{dr_{i-1}}{dt}##
5. Use equation 6.48 to get average rate of change for the timestep.
6. Use equation 6.49 to approximate ##r_i##.
In order for this to work I have to assume a starting bubble radius yes? This is probably not the right forum for this, but think if i took a shot at a MATLAB script you could look it over for me?
 
Based on the example, it looks like you would want to have the radius at the first 3 times. You can surely assume that r = 0 or r = r0 for times prior to start.
Yes, I can look at a script for you.
 
RUber said:
Based on the example, it looks like you would want to have the radius at the first 3 times. You can surely assume that r = 0 or r = r0 for times prior to start.
Yes, I can look at a script for you.

Quick question:

upload_2016-5-24_8-30-43-png.101199.png


in this equation, how do I solve it to get the dr_i/dt and dr_i-1/dt so that I can plug them into the averaging formula? I know everything and all the constants but what is the MATLAB way to solve this?
 
  • #10
If you know ##r_{i-1}##, you just plug it in. There is nothing to solve.
For the current (i) timestep, you don't know ##r_i##, so you use the ##\hat r_i## that you already computed.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 65 ·
3
Replies
65
Views
9K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
944
  • · Replies 12 ·
Replies
12
Views
2K