solving the differential equation

Hi.
I have a differential equation of a function f(x,y) wrt "x". I can solve this equation using the "dsolve" and obtain the solution. Now I again want to differentiate the solution obtained wrt to other variable "y". Can anyone please help me in writing the code for differentiating the solution thus obtained. Here is the code attached:
syms f(x) y
ode = diff(f,x) == -(2/x)*f + (4*x^3*y^2 + 2*x*y + 6*x)/x^2;
sol = dsolve(ode);
%-------------------------------------------------%
val =
C3/x^2 + (x^2*(y + 3) + x^4*y^2)/x^2
In this code, I want to differentiate the "sol" wrt variable "y". Note that the constant "C3" in the solution is a function of "x & y".

5 Comments

If C3 is an arbitrary function of y, then the differentiation wrt y can be also arbitrary. So you have to determine what C3 is (perhaps with other conditions) before you can do the differentiation to y.
Hey, the only difficulty I am having is writing the code (perhaps one line) so that I obtain the differential equation when I differentiate the "sol" wrt variable "y".
If I use the function "diff" to differentiate "sol" I get the following result:
ode_2 = diff(sol,y)
ans : ode_2 =
(2*y*x^4 + x^2)/x^2
Here it treats "C3" as a constant and therefore on differentiating, the whole term "C3/x^2" becomes 0.
Alternatively, can you help me to solve this PDE in matlab
Boundary condition:
syms f(x,y)
ode = diff(f,x) + diff(f,y) + (2/x)*f == (4*x^3*y^2 + 2*x*y + 6*x)/x^2 + 2*x^2*y + 1
ode(x, y) = 
syms f(x) y C(y)
ode = diff(f,x) == -(2/x)*f + (4*x^3*y^2 + 2*x*y + 6*x)/x^2;
sol = simplify(expand((dsolve(ode))))
sol = 
vars = symvar(sol);
soly = subs(sol, vars(1), C)
soly = 
Dsoly = diff(soly,y)
Dsoly = 

Sign in to comment.

Answers (0)

Asked:

on 15 Dec 2021

Commented:

on 15 Dec 2021

Community Treasure Hunt

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

Start Hunting!