first order PDE , verification of one solution

Hello
the solution of the PDE:
df(x,y)/dx + df(x,y)/dy =0
should be f= f(x-y) , with f an arbitrary function of the argument which is the compound variable (x-y).
Wanting to verify this symbolic solution I would like to execute these commands
1) syms x y real
2) syms f(x-y)
and then do the calculation
3) ver=diff(f(x-y),x)+diff(f(x-y),y)
and simplifying it should give
ver=zero
but unfortunately on the second line it
gives me an error :
---------------------------------------------------------------------
Error using symfun.parseString (line 101)
Invalid variable name.
Error in syms (line 276)
[name, vars] = symfun.parseString(x,'allowPercent');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-----------------------------------------------------------------------
I was kindly asking
how to proceed and be able to do this
symbolic verification
thankyou very much !
Valerio

Réponses (3)

syms x y real
syms f(x_minus_y)
v1 = diff(f(x-y),x)
v1 = 
v2 = diff(f(x-y),y)
v2 = 
ver = v1 + v2
ver = 
simplify(ver)
ans = 
Which is not zero.
I do not understand why you think it should be 0. Surely df(x,y)/dx + df(x,y)/dy = 0 is a condition, rather than a truism.

5 commentaires

Val
Val le 23 Juin 2025
Thankyou
I corrected the line 2) , and now i get
>> syms x y real
>> syms f(x_minus_y)
>> v1 = diff(f(x-y),x)
v1 =
diff(f(x - y), x)
>> v2 = diff(f(x-y),y)
v2 =
-D(f)(x - y)
ok I'm on the right track, but now I don't understand why deriving with respect to y i.e.
v2 = diff(f(x-y),y)
give
v2 =
-D(f)(x - y)
instead deriving with respect to x i.e.
v1 = diff(f(x-y),x)
i did not obtained
v1 =
+D(f)(x - y)
Val
Val le 23 Juin 2025
"while deriving with respect to x " .. sorry
It looks like diff() is happening to create two different notations that are not immediately compatible. But substitute in any actual function and you can see that the two parts are negatives of each other.
syms x y real
syms f(x_minus_y)
F(x_minus_y) = tan(x_minus_y)^3 + exp(-x_minus_y)
F(x_minus_y) = 
v1 = diff(f(x-y),x); char(v1)
ans = 'diff(f(x - y), x)'
v2 = diff(f(x-y),y); char(v2)
ans = '-D(f)(x - y)'
simplify(v1 == -v2)
ans = 
V1 = subs(v1, f, F)
V1 = 
V2 = subs(v2, f, F)
V2 = 
simplify(V1 == -V2)
ans = 
symtrue
Val
Val le 24 Juin 2025
"It looks like diff() is happening to create two different notations that are not immediately compatible"
That is the point
I think that the right answer to the command:
v1 = diff(f(x-y),x)
should be
D(f)(x - y)
not "diff(f(x - y), x)" , which is a repetition of the command line.
Consider this workaround:
----------------------------------------
>> syms a positive
>> v1 = diff(f(a*x-y),x)
v1 =
a*D(f)(a*x - y)
>> v1=subs(v1,a,1)
v1 =
D(f)(x - y)
-----------------------------------------
that get the right form of the answer, so may immediately verify the solution f(x-y)...
...may be that is a bug to be fixed ?
Thankyou very much Mr Roberson for interest in this matter
Valerio
Val
Val le 25 Juin 2025
Dear Mr Roberson , let me have Your opinion
is a bug to be fixed ?
thankyou sincerely valerio

Connectez-vous pour commenter.

Torsten
Torsten le 24 Juin 2025
Modifié(e) : Torsten le 24 Juin 2025
You shouldn't waste your time here with symbolic manipulations.
What is important is that solutions f(x,y) of the PDE
df/dx + df/dy = 0
are constant on lines in the x-y-plane with slope equal to 1.
That means that f is not really a function of two variables, but it is already given by its values on e.g. the x- or the y-axis:
f(x,y) = f(x-y,0) = f(0,y-x)
More generally, f(x,y) as a function on IR^2 is fixed by its values on any line in the x-y-plane that has not a slope equal to 1.
The lines with slope equal to 1 are called the characteristics of the partial differential equation.
Val
Val le 24 Juin 2025

0 votes

many thanks to all !!
anyway i think that the right answer to the command:
v1 = diff(f(x-y),x)
should be
D(f)(x - y)
not "diff(f(x - y), x)" , which is a repetition of the command line.
consider this workaround:
----------------------------------------
>> syms a positive
>> v1 = diff(f(a*x-y),x)
v1 =
a*D(f)(a*x - y)
>> v1=subs(v1,a,1)
v1 =
D(f)(x - y)
-----------------------------------------
that get the right form of the answer, so may verify the solution f(x-y)...
...may be that is a bug to be fixed ?
Thankyou very much for interest in this matter
kind regards Valerio (i hope i comment in the correct box)

1 commentaire

Torsten
Torsten le 24 Juin 2025
I don't understand why you work with f(x-y). The solution of the differential equation
df/dx + df/dy = 0
is a function of two variables: f(x,y).
As I wrote in my answer, the thing you have to show is that f(x,y) = f(x-y,0) holds if f satisfies the partial differential equation.

Connectez-vous pour commenter.

Question posée :

Val
le 23 Juin 2025

Commenté :

Val
le 25 Juin 2025

Community Treasure Hunt

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

Start Hunting!

Translated by