Finding solution of an equation containing symbolic parameters. I want solution of one symbolic parameter in terms of another
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
syms c_1 c_2 D r_t
%Parameters
sig = 0.2;
p=0.5;
rho_t =1;
w_t =100;
%Function
u = (c_1^sig)/sig ;
v = (c_2^sig)/sig;
u_diff = diff(u);
v_diff = diff(v);
%D Function
du_dd = subs(u_diff,w_t-D);
dv_dd = subs(v_diff,r_t*D);
eqn2 = du_dd == r_t*dv_dd ;
assume(D>0)
assume(D<w_t)
assume(r_t>0)
S2 = solve(eqn2,D,'Real',true)
I am trying to find soltion of D in terms of r_t but it throws an error
0 commentaires
Réponses (1)
Paul
le 23 Avr 2022
Not sure why solve doesn't work as is. See below for one approach to a solution.
syms c_1 c_2 D r_t
%Parameters
sig = 0.2;
p=0.5;
rho_t =1;
w_t =100;
%Function
u = (c_1^sig)/sig ;
v = (c_2^sig)/sig;
u_diff = diff(u);
v_diff = diff(v);
%D Function
du_dd = subs(u_diff,w_t-D);
dv_dd = subs(v_diff,r_t*D);
eqn2 = du_dd == r_t*dv_dd ;
assume(D>0)
Need use assumeAlso so as not to wipeout the first assumpton on D
assumeAlso(D<w_t)
assume(r_t>0)
Raise both sides of the equation to the 5/4 power and then try to solve. Not sure if doing so is strictly valid for all possible values of D and r_t given the assumptions, but I don't see why it wouldn't be.
S2 = solve((eqn2.^(5/4)),D,'Real',true,'ReturnConditions',true)
So we get a solution, but there are conditions. But if we simplify and then solve, we get one solution
S2 = solve(simplify(eqn2.^(5/4)),D)
Verifty that's a solution
simplify(subs(eqn2,D,S2))
2 commentaires
Paul
le 23 Avr 2022
eqn2 has terms raised the 4/5 power. Raising both sides eqn2 to the 5/4 power just seemed like a logical thing to do. I'm still not sure if there isn't some corner case where doing so wouldn't be valid.
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!