# Finding solution of an equation containing symbolic parameters. I want solution of one symbolic parameter in terms of another

1 view (last 30 days)

Show older comments

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 Comments

### Answers (1)

Paul
on 23 Apr 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 Comments

Paul
on 23 Apr 2022

### See Also

### Community Treasure Hunt

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

Start Hunting!