Problems with the diff function

9 visualizzazioni (ultimi 30 giorni)
Borja Esteve Molner
Borja Esteve Molner il 31 Mar 2022
Modificato: Stephen23 il 31 Mar 2022
Hello everyone. I am trying to calculate the following exact differential equation:
(2y-2xy^3 + 4x +6)dx + (2x -3x^2y^2 -1) = 0
First, I divide the equation into two parts, M and N. Then, I try to calculate their derivatives to see if both coincide in order to see if it is an exact equation. I do this with the diff function and this is where the problem arises. When I run the following code:
syms x y
M = '2 * y - 2 * x * y^3 + 4* x + 6';
N = '2*x - 3*x^2*y^2 -1 '
cond = diff(M,y) - diff(N,x)
I get the following error: Difference order N must be a positive integer scalar
Does anyone know how to solve this problem? Thank you very much.

Risposte (2)

Stephen23
Stephen23 il 31 Mar 2022
Modificato: Stephen23 il 31 Mar 2022
syms x y
M = 2 * y - 2 * x * y^3 + 4* x + 6
M = 
N = 2*x - 3*x^2*y^2 -1
N = 
cond = diff(M,y) - diff(N,x)
cond = 
0
Note:
diff(M,y)
ans = 
diff(N,x)
ans = 

Torsten
Torsten il 31 Mar 2022
syms x y
M = 2*y - 2*x*y^3 + 4*x + 6;
N = 2*x - 3*x^2*y^2 - 1 ;
cond = diff(M,y) - diff(N,x)

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by