How to get correct partial derivatives using diff function?

조회 수: 3 (최근 30일)
Robert  Flores
Robert Flores 2019년 10월 1일
댓글: Robert Flores 2019년 10월 1일
Hello,
I am trying to take the derivative of a logorithum that consists of three varibles, x1, x2, and u. I think the syntax of my code works somewhat okay, because I get part of the solution. However, I know it is wrong because I did it by hand, and I am missing some terms in the MatLab output. Below is a copy of my code so far. If anyone can help me resolve this issue, it will be greatly appreciated, thank you in advance.
I have attached a image of what the solution should look like. MATLAB_Question.PNG
Sincerely,
Robert
CODE:
clc, clear, close all
syms x1 x2 u
J = log(x1)+2*log(x2)+3*log(u);
% J = combine(J,'log','IgnoreAnalyticConstraints',true);
delJdelx1 = diff(J,x1)
delJdelx2 = diff(J,x2)
  댓글 수: 2
Basil C.
Basil C. 2019년 10월 1일
In your hand written solution why haven't you cancelled out the common terms for example:-
Robert  Flores
Robert Flores 2019년 10월 1일
Oh my goodness, you are amazing. The script works then, haha, I have just been working out problems for to long. Thank you, haha

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by