Sovling Bernoulli's differential equation in matlab?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 5K views
Eswin Paul T
Messages
6
Reaction score
0
I have a first order bernoullis differential equation. I need to solve this in matlab. Can anyone help me?
 
on Phys.org
Eswin Paul T said:
I have a first order bernoullis differential equation. I need to solve this in matlab. Can anyone help me?
What is the context of the question? Is this for schoolwork?

What is your level of experience with MATLAB? What is the DE (and the initial conditions), and which numerical method do you have in mind for solving it?
 
berkeman said:
What is the context of the question? Is this for schoolwork?

What is your level of experience with MATLAB? What is the DE (and the initial conditions), and which numerical method do you have in mind for solving it?
I am working on lidars to retrieve extinction coefficient. I have to solve the lidar equation using Klett method which involves reducing the lidar eqn to a first order bernoullis equation.
 
I can't provide specific help since you didn't provide the equation, so instead I'll show you some ways to solve one of the Bernoulli equations in the Wikipedia article on Bernoulli differential equation.

The differential equation is,
[tex]x \frac{dy}{dx} + y = x^2 y^2[/tex]
Bernoulli equations have the standard form
[tex]y' + p(x) y = q(x) y^n[/tex]
So the first equation in this standard form is
[tex]\frac{dy}{dx} + \frac{1}{x} y = x y^2[/tex]

Initial Value Problem
If you want to calculate a numerical solution to the equation by starting from a known initial state and simulating forward to a predetermined end point, then you have an initial value problem. The main ODE solver in MATLAB is ode45, and it only takes a few lines in a script to solve this equation for some initial condition y0 over a period of time tspan (I picked some random values):

Code:
y0 = 0.1;
tspan = [0.5 20];

[x,y] = ode45(@bernoulli1, tspan, y0);
plot(x,y)

function dydx = bernoulli1(x,y)
% This function codes the equations and
% is called at each time step by ode45 to
% advance the integration.
dydx = x*y^2 - y*(1/x);
end

bernoulli1.png


Symbolic Solution
Instead of simulating the system, you can express it as a linear differential equation and solve it using known techniques (see here). This doesn't really require MATLAB, but if the expressions are complicated you can use Symbolic Math Toolbox to perform some of the integrations.

Hopefully this general information is helpful. If you post more info on the equation you need to solve then maybe we can see about which technique is best.
 

Attachments

  • bernoulli1.png
    bernoulli1.png
    11 KB · Views: 2,614
  • Like
Likes   Reactions: Greg Bernhardt and berkeman