Why does Matlab not simplify this further?

I want Matlab to simplify the first partial derivative of the following function:
With the arguments of the function repressed, the first partial derivative with respect to is
Matlab gives me the correct derivative but then does not simplify it further:
clear, clearvars
syms x1 x2 p1 p2 l C rho
syms f(p1,p2)
f(p1,p2) = (l.^(1/(1-rho)) *(p1).^(rho/(rho-1))+(1-l).^(1/(1-rho))*(p2).^(rho/(rho-1))).^((rho-1)/rho)
f(p1, p2) = 
C = f(p1,p2)
C = 
x2 = (diff(f,p2))
x2(p1, p2) = 
simplify(x2,'Steps',10)
ans(p1, p2) = 
I tried to define C=f(p1,p2) but it doesn't help. Any ideas what I can do here?

답변 (1개)

Star Strider
Star Strider 2024년 2월 12일
Increase the ‘Steps’ value. It will then continue simplifying until it cannot simplify further, or reaches the maximum ‘Steps’ iteration limit. I use 500 here (as I do usually), however it can be either more or less than that, depending on the result you want. (In this instance, increasing it does not change the result.)
Try this —
clear, clearvars
syms x1 x2 p1 p2 l C rho
syms f(p1,p2)
f(p1,p2) = (l.^(1/(1-rho)) *(p1).^(rho/(rho-1))+(1-l).^(1/(1-rho))*(p2).^(rho/(rho-1))).^((rho-1)/rho)
f(p1, p2) = 
C = f(p1,p2)
C = 
x2 = (diff(f,p2))
x2(p1, p2) = 
simplify(x2,'Steps',500)
ans(p1, p2) = 
.

카테고리

제품

릴리스

R2023a

질문:

2024년 2월 12일

답변:

2024년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by