f(k) = n*ln(k)-n*ln(1/n*sum(i=1 to n)xi^k+(k-1)sum of (1to n)ln(xi))-n

댓글 수: 3

KSSV
KSSV 2023년 7월 13일
What have you tried? You are facing any problem or error?
Taniya
Taniya 2023년 7월 13일
i could not write the code for the sum series where x sum for 1 to n
Dyuman Joshi
Dyuman Joshi 2023년 7월 13일
The expression you have written above is not clear. Please format it properly.

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

 채택된 답변

Rahul
Rahul 2023년 7월 13일

0 개 추천

Hi Taniya,
Assuming you have k, n and xi, you can try the following code to find the Hessian Matrix:
f = n*log(k) - n*log(1/n * sum(xi^k, i, 1, n) + (k-1) * sum(log(xi), i, 1, n)) - n;
% Calculate the second partial derivatives
d2f_dk2 = diff(f, k, 2);
d2f_dxi_dk = diff(f, k, xi);
d2f_dk_dxi = diff(f, xi, k);
d2f_dxi2 = diff(f, xi, 2);
% Create the Hessian matrix
H = [d2f_dk2, d2f_dxi_dk; d2f_dk_dxi, d2f_dxi2];
Hope this helps.
Thanks.

추가 답변 (1개)

Torsten
Torsten 2023년 7월 13일
편집: Torsten 2023년 7월 13일

0 개 추천

The vector of independent variables is (x1,x2,...,xn):
syms i k
n = 3;
x = sym('x',[1 n])
x = 
f = n*log(k) - n*log(1/n*sum(x.^k) + (k-1)*sum(log(x))) - n
f = 
df = gradient(f,x)
df = 
d2f = hessian(f,x)
d2f = 

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

질문:

2023년 7월 13일

편집:

2023년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by