MATLAB: How to numerically determine parameters to make solution of differential equation equal to zero at a certain point

MATLAB: How to numerically determine parameters to make solution of differential equation equal to zero at a certain point

2 parameter searchdifferential equationsnumerical

So I have a 3rd order differential equation that includes two parameters b & C. I am trying to find the value of b & C such that at a certain point (e.g. at x=100) f”(x)+a*C^3*f(x) = 0, where a is a constant. Some parameters in the differential equation include randomly varying values at different values of x, so the equation must be solved numerically.
I have been able to solve for the appropriate b & C using a brute force method, which involves solving the differential equation for different values of b & C, choosing the values that minimize f”(x)+a*C^3*f(x) and then repeating the process with more precision around the chosen b & C to determine their values to more significant figures.
The problem with this brute force method is that it is computationally expensive and takes too much time, up to 2 minutes per solution. I have to run at least 1000 samples at a time to obtain good statistics. I was hoping that someone could suggest some other type of numerical method or function in MATLAB that could allow me to solve my problem in a smaller time frame
I would be happy to clarify any issues you may have with my explanation or give more detail if necessary. Thank you very much!

Best Answer

  • The part with “Some parameters in the differential equation include randomly varying values at different values of x” sounds a bit scary, but if it isn’t varying in too discontinuous ways (whatever too discontinuous means here) you might refine your brute-force method with some ideas from the shooting method for boundary value problems, or you could simply turn it into a minimization problem where you try to minimize the square of (f”(100)+a*C^3*f(100)). Here your error-function has the parameters [b, C] as input and integrate your ode from your start-point with those parameters.
    function err = err_ode_bC_integration(pars,y0,tspan,f_ode,f_ygoal,f_goal)
    %comments here
    y = ode45(@(t,y) f_ode(t,y,pars),tspan,y0);
    err = sum((f_goal(y(:,end),pars)-f_ygoal).^2);
    Then call it something like this:
    tspan = [0 100];
    y0 = [12;34;pi*2^.5];
    f_goal = @(x,pars) x(3) - 123*pars(3)^3*x(1);
    f_ygoal = 0;
    pars0 = [1,2,3,4];
    bestPars = fminsearch(@(pars)err_ode_bC_integration(pars,y0,tspan,f_ode,f_ygoal,f_goal),pars0)
    Nothing tested, but this should give you an idea.
    HTH
  • Add a Comment

    Your email address will not be published. Required fields are marked *