Solving differential equation with a constant

In summary, the conversation discussed solving a simple differential equation using DSolve and plotting the solution in terms of a constant k. It was also mentioned that a similar equation can be solved using NDSolve and the final solution can be plotted in terms of k as well. It was suggested to choose different initial conditions to get a unique solution.
  • #1
zarei
8
0
Hi,
I am working with mathematica. I have a simple differential equation as follows:
y''[t]+k^2y[t]+(1/t^2)y[t]=0
where k is a constant between 1<k<20.
How can solve this equation and then plot y in terms of k?
thanks
 
Physics news on Phys.org
  • #2
You can solve it using

Code:
DSolve[y''[t] + k^2 y[t] + (1/t^2) y[t] == 0, y[t], t]

which gives the answer in terms of Bessel functions. To plot it though, you will need to choose some initial conditions, which you would insert like

Code:
DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]

and to plot with [itex]k[/itex] on the horizontal axis you will need to choose [itex]t[/itex] (or just make a three-dimensional plot). The plot may be done like


Code:
sol=DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]
Plot[y[t]/.sol/.t->t0 , {k,1,20}]

where [itex]t0[/itex] is the [itex]t[/itex] you are choosing.
 
  • #3
16180339887 said:
Code:
sol=DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0,y[0]==0,y'[0]==0}, y[t], t]
Plot[y[t]/.sol/.t->t0 , {k,1,20}]

Just a note: if you choose y(0), y'(0) = 0, the unique solution for this initial condition is y(t) = 0, so I suggest choosing something different for the initial conditions!
 
  • #4
Thanks for reply,
I have a similar equation where cannot be solved with DSolve. It can be solved just by NDSolve. Could you please guide me how the final solution can be plotted in terms of constant k when we use the NDSolve?
 
  • #5


Hi there,

To solve this differential equation, you can use the built-in function in Mathematica called DSolve. This function allows you to find the general solution for a given differential equation. In your case, the syntax would be:

DSolve[{y''[t] + k^2 y[t] + (1/t^2) y[t] == 0, y[1] == a, y'[1] == b}, y[t], t]

where a and b are arbitrary constants. This will give you the general solution in terms of k.

To plot y in terms of k, you can use the Plot function in Mathematica. The syntax would be:

Plot[y[t] /. sol, {k, 1, 20}]

where sol is the output from the DSolve function. This will give you a plot of y vs. k for the range of k values specified.

I hope this helps! Let me know if you have any further questions.
 

1. What is a differential equation with a constant?

A differential equation with a constant is an equation that involves a function and its derivatives, with the addition of a constant term. The constant term can be a number, a variable, or a function.

2. Why is it important to solve differential equations with a constant?

Solving differential equations with a constant is important because it helps in understanding and predicting the behavior of systems in various fields such as physics, engineering, and economics. It also allows us to model and analyze real-world situations.

3. What are the different methods to solve a differential equation with a constant?

There are several methods to solve a differential equation with a constant, including separation of variables, integrating factors, substitution, and using differential equations solvers such as Euler's method or Runge-Kutta method.

4. How do you check if a solution to a differential equation with a constant is correct?

To check the correctness of a solution to a differential equation with a constant, you can substitute the solution into the original equation and see if it satisfies the equation. You can also plot the solution and see if it matches the behavior of the system.

5. Are there any applications of solving differential equations with a constant?

Yes, there are many applications of solving differential equations with a constant, including predicting the motion of objects under the influence of forces, modeling population growth, and understanding electrical circuits. It is also used in various fields of engineering, such as control systems and heat transfer.

Similar threads

  • Differential Equations
Replies
1
Views
752
  • Differential Equations
Replies
2
Views
992
  • Differential Equations
Replies
5
Views
653
  • Differential Equations
2
Replies
52
Views
819
  • Differential Equations
Replies
1
Views
1K
  • Differential Equations
Replies
6
Views
2K
  • Differential Equations
Replies
3
Views
2K
  • Differential Equations
Replies
4
Views
1K
  • Differential Equations
Replies
3
Views
1K
  • Differential Equations
Replies
3
Views
1K
Back
Top