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)
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

Réponses (1)

Paul
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)
S2 = struct with fields:
D: x parameters: x conditions: x^4 + 400*r_t*x^3 + 4000000*r_t*x == r_t*x^4 + 60000*r_t*x^2 + 100000000*r_t & r_t ~= 1 & 0 < x & x < 100
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)
S2 = 
Verifty that's a solution
simplify(subs(eqn2,D,S2))
ans = 
symtrue
  2 commentaires
Aiswarya Nair Manikantan Geetha
Wow ! That did work. Can you tell me how u got the idea to raise equation to the 5/4th power.
I just want to improve my way of thinking. Thank you.
Paul
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.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by