2-order linear differential equation with paramaters

조회 수: 1 (최근 30일)
Antonino Roccaforte
Antonino Roccaforte 2023년 9월 8일
답변: Sam Chak 2023년 9월 9일
I have to solve the following differential equation with parameters but I don't know how to declare the parameters. The differential equation is the following: diff(y,x,2)x+diff(y,x)(2k+1-2x^2)+y(E-2k-2)x == 0 where E and k are paramaters. Any help?
This code doesn't work because the constants E and k are not defined.
syms y(x)
ode = x*diff(y,x,2)+(1+2*k-2*x^2)*diff(y,x)+(E-2*(1+k))*y*x == 0;
ySol(x) = dsolve(ode);

답변 (2개)

Shoresh Shokoohi
Shoresh Shokoohi 2023년 9월 8일
To solve the given differential equation with parameters E and k in MATLAB, you need to declare these parameters as symbolic variables using the syms function. Here's how you can modify your code to define E and k as symbolic variables:
% Define symbolic variables E and k
syms E k
% Define the function y(x) as a symbolic function
syms y(x)
% Define the differential equation with the parameters E and k
ode = x*diff(y,x,2) + (1 + 2*k - 2*x^2)*diff(y,x) + (E - 2*(1+k))*y*x == 0;
% Solve the differential equation
ySol(x) = dsolve(ode);
With these modifications, you've declared E and k as symbolic variables, and you can now solve the differential equation with respect to these parameters using the dsolve function.
  댓글 수: 2
John D'Errico
John D'Errico 2023년 9월 8일
편집: John D'Errico 2023년 9월 8일
+1 of course. I would add only that because these parameters are essentially unknowns, you cannot use a numerical solver like ODE45. Only a tool like dsolve can now apply. This should be no problem of course, since you wanted to use dsolve in the first place. But there will then always be someone down the line hoping to use ODE45.
Antonino Roccaforte
Antonino Roccaforte 2023년 9월 8일
편집: Antonino Roccaforte 2023년 9월 8일
I tried to compile the code but in this way there is no output! How is it possible? The solution should be a linear combination of confluent hypergeometric functions...

댓글을 달려면 로그인하십시오.


Sam Chak
Sam Chak 2023년 9월 9일
I'm unfamiliar with your ODE, but I tested it with dsolve, and there are some results, and one of them returns with the Confluent hypergeometric Kummer U function. By the way, I'm just curious: How does your ODE describe the physical real-world phenomenon?
syms t x y(x) E k
S1 = dsolve(x^1*diff(y,2) + (2*k + 1 - 2*x^2)*diff(y) + (E - 2*(1 + k))*x*y)
S1 = 
S2 = dsolve(x^3*diff(y,2) + (2*k + 1 - 2*x^2)*diff(y) + (E - 2*(1 + k))*x*y)
S2 = 

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by