2-order linear differential equation with paramaters
Mostra commenti meno recenti
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);
Risposte (2)
Shoresh Shokoohi
il 8 Set 2023
1 voto
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 Commenti
John D'Errico
il 8 Set 2023
Modificato: John D'Errico
il 8 Set 2023
+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
il 8 Set 2023
Modificato: Antonino Roccaforte
il 8 Set 2023
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)
S2 = dsolve(x^3*diff(y,2) + (2*k + 1 - 2*x^2)*diff(y) + (E - 2*(1 + k))*x*y)
Categorie
Scopri di più su Equation Solving in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

