(1/(x^2)) d/dx [(x^2)(dy/dx)] + y^n = 0

  • Thread starter Void123
  • Start date
In summary: Then use the Euler method to solve the resulting system of differential equations and plot the solution.In summary, the conversation discusses a second order differential equation and a corresponding code template in MATLAB. The individual is attempting to plot a graph using the Euler method, but is not getting any output for their specific equation. Suggestions are made to substitute x=exp(t) and use the resulting simplified equation to solve the system of differential equations and plot the solution.
  • #1
Void123
141
0
I have the following second order differential equation:

(1/(x^2)) d/dx [(x^2)(dy/dx)] + y^n = 0

which I am trying to put into the following code [matlab] template:

Code:
function euler2

tspan(1)=0;tspan(2)=15;          % Interval on which to integrate
h=.01;N=round((tspan(2)-tspan(1))/h);
t = tspan(1);                    % used for numerical solution
u = 1;                % initial data for u=y and initializes do loop
v = 0;                % initial data for v=y'and initializes do loop

%%%%%%%%  main do loop for Euler Method %%%%%%%%
    for n=1:N
     f1      = feval(@rsu,t,u,v);
     f2      = feval(@rsv,t,u,v);
     u       = u+h*f1;
     v       = v+h*f2; 
     t       = t+h;
     uout(n) = u;
     vout(n) = v;
     tt(n)   = t;
    end
%%%%%%%%  main do loop for Euler Method %%%%%%%%

%%%%%%%%%%%% plotting details %%%%%%%%%%%%%%%
hold on;
  plot(tt,uout,'b-','LineWidth',1.5);axis tight;

%%%%%% function definitions %%%%%%%%%%%%%%%
function p=p(t)           % defines function p(t)
p=t;

function q=q(t)           % defines function q(t)
q=1;

function g=g(t)         % defines forcing function 
g=cos(t);

function dudt=rsu(t,u,v)    % defines function for forward Euler
dudt=v;
function dvdt=rsv(t,u,v)    % defines function for forward Euler
dvdt=g(t)-p(t)*v-q(t)*u;

For some reason, when I put my equation in (of course for assumed values of 'n'), the graph window pops up but there is no plot on it.

When I try other equations its works, but the one I want doesn't give me any graphical output.

Does anybody have an idea of what's going on?
 
Physics news on Phys.org
  • #2


Try substituting x=exp(t) to simplify the equation.
 

FAQ: (1/(x^2)) d/dx [(x^2)(dy/dx)] + y^n = 0

What is the meaning of the equation (1/(x^2)) d/dx [(x^2)(dy/dx)] + y^n = 0?

This equation is a differential equation that describes the relationship between the rate of change of a function, represented by dy/dx, and the function itself, represented by y. The term (1/(x^2)) d/dx [(x^2)(dy/dx)] represents the second derivative of y with respect to x, and the term y^n represents y raised to the power of n. The equation states that the sum of these two terms must equal zero.

Why is this equation important in science?

This equation is important because it is a fundamental tool in describing many natural phenomena and physical laws. It is commonly used in physics, chemistry, engineering, and other scientific fields to model and predict the behavior of systems and processes.

What is the significance of the term (1/(x^2)) in the equation?

The term (1/(x^2)) represents the inverse square relationship between two variables, which is a common relationship in many scientific phenomena. It is also important in this equation because it allows for the inclusion of the second derivative of y, which is necessary for accurately describing the behavior of certain systems.

How is this equation solved?

This equation can be solved using various mathematical techniques, such as separation of variables, substitution, or integration. The specific method used depends on the form of the equation and the desired solution. In some cases, it may also require numerical methods to find an approximate solution.

What are some real-world applications of this equation?

This equation has many real-world applications, such as in modeling the motion of objects under the influence of a force, predicting the behavior of electrical circuits, and describing the behavior of chemical reactions. It is also used in fields such as fluid mechanics, thermodynamics, and population dynamics. Essentially, any system or process that involves rates of change can be described by this equation.

Back
Top