Effacer les filtres
Effacer les filtres

How to expand symbolic exponential numerator to reduce fraction

7 vues (au cours des 30 derniers jours)
Alena
Alena le 3 Août 2023
Réponse apportée : Paul le 3 Août 2023
I'm trying to write code to solve some macroeconomic models and I'm running into some issues getting MATLAB to give me my results in simplified form. I want the y_t equation only in terms of A_t and k_t, since L_t should cancel out. MATLAB won't seem to let me distribute the exponent and reduce the fraction unless there is a command I don't know.
Here is my code:
And here is the current output:
What I want is A_t k_t^(alpha). How do I get MATLAB to distribute the exponent?

Réponse acceptée

Paul
Paul le 3 Août 2023
syms Y_t A_t K_t alpha L_t k_t w_t y_t
Y_t = A_t*K_t^alpha*L_t^(1-alpha)
Y_t = 
lil_y = y_t == Y_t/L_t
lil_y = 
labor_eqn = L_t == solve(lil_y, L_t,"Real",true)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
labor_eqn = 
y_t = solve(labor_eqn, y_t, "Real", true)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
y_t = 
k_eqn = K_t/L_t == k_t
k_eqn = 
K_t = solve(k_eqn, K_t, "Real", true)
K_t = 
y_t = subs(y_t)
y_t = 
Use simplify with the additional name/value pair
simplify(y_t,'IgnoreAnalyticConstraints',true)
ans = 
Consider checking into those warnings to make sure the conditions for the solution apply to this problem. Also, it might be beneficial to add appropriate assumptions to the variables. For example, specfying all the variables as positive (if it makes sense to do so) cleans up the warnings and mitigates the need for IgnoreAnalyticConstraints.

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by