필터 지우기
필터 지우기

How can I differentiate an abstract symbolic function?

조회 수: 12 (최근 30일)
c2332
c2332 2021년 8월 4일
댓글: Star Strider 2021년 8월 4일
Hi, I would like to differentiate an abstract symbolic function in MATLAB.
To make sure we're all on the same page, let's say I have a function of two variables what's this where f is any function of one variable that is differentiable across its domain. Using partial differentiation, we should expect to see:
and
I've tried to use syms to observe this behaviour in MATLAB:
syms x y f(k) g(x,y)
g(x,y) = f(x - 3*y);
g_x = diff(g,x);
g_y = diff(g,y);
In effect, we find that
g_y = -3*D(f)(x - 3*y)
Which translates to after using the latex function.
But we also find that
g_x = diff(f(x - 3*y), x)
which translates to .
I have tried to use the expand and simplify functions on this result, but they don't seem to transform it into the expected . Is there a way for me to do this?
Note that if the coefficient of x was anything other than 1 or 0, then we have
g_x = c*D(f)(c*x - 3*y)

답변 (2개)

Star Strider
Star Strider 2021년 8월 4일
I am not certrain that I understand what you want to do.
See if the diff documentation section on Differentiation With Respect to Function and Derivative will do what you want. It requires a slightly different syntax.
.
  댓글 수: 2
c2332
c2332 2021년 8월 4일
편집: c2332 2021년 8월 4일
I was trying to represent as since subtracting the two representations will not equal zero.
"I have tried to use the expand and simplify functions on this result, but they don't seem to transform it into the expected . Is there a way for me to do this?"
Star Strider
Star Strider 2021년 8월 4일
I do not understand what you want to do. It appears that you want a specific format, and that format may not be available, unless you create it yourself.
.

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


Paul
Paul 2021년 8월 4일
When I run this code (2019a) on my computer, I get:
syms x y f(k) g(x,y)
g(x,y) = f(x - 3*y);
g_x = diff(g,x)
g_y = diff(g,y)
g_x(x, y) =
D(f)(x - 3*y)
g_y(x, y) =
-3*D(f)(x - 3*y)
Is that not the form of the expected result? I'm confused if what you're asking about is the form of the result as sym objects, or the form of the typeset output from the Live Editor. If the latter, in my local version of Matlab I do get , although that desn't seem to be the case in 2021a, at least as run here:
g_x
g_x(x, y) = 
  댓글 수: 4
c2332
c2332 2021년 8월 4일
It's not just that issue. If I try performing
3*diff(f(x-3*y),x) + diff(f(x-3*y), y)
I should expect to get zero, but I get the following instead:
3*diff(f(x - 3*y), x) - 3*D(f)(x - 3*y)
Paul
Paul 2021년 8월 4일
Something changed since 2019a. I just ran in 2020b and got:
g_x(x, y) =
diff(f(x - 3*y), x)

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

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by