solving a system of nonlinear equations in terms of parameter (essentially rearrangement)

2 views (last 30 days)
I'm having a trouble solving a system of equations with multiple parameters and unknowns
syms a b c k t p1 p2 v1 v2 x
eqn_x = x == a + ((p2-v2)-(p1-v1))/(2*t*(1-a-b)) + (1-a-b)/2 ;
eqn_p1 = p1 == c - k + (1/3)*(v1-v2) + t*(1-a-b)*(1+(a-b-4*v1-2*v2)/3) ;
eqn_p2 = p2 == c - k + (1/3)*(v2-v1) + t*(1-a-b)*(1+(a-b-4*v2-2*v1)/3) ;
eqn_v1 = v1 == (c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b)) ;
eqn_v2 = v2 == (c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b)) ;
eqns = [eqn_x, eqn_p1, eqn_p2, eqn_v1, eqn_v2] ;
S = solve(eqns, [p1 p2 v1 v2 x]) ;
This is my code, the goal is to get v1 and v2 term rearranged in terms of only a, b, c, k, & t terms.
there are 5 functions and 5 unknowns. though it is not a system of linear equation because v1 and v2 term depends on quadratic function of x, I guess there is a possible rearrangement.
But what I get is p1, p2, v1, v2, x being [0x1 sym]. How do I get those rearrangement?

Answers (1)

Torsten
Torsten on 26 Aug 2019
Does this work ?
syms a b c k t x
eqn = x == a + (((c - k + (1/3)*(((c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b)))-((c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b)))) + t*(1-a-b)*(1+(a-b-4*((c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b)))-2*((c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b))))/3))-((c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b))))-((c - k + (1/3)*(((c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b)))-((c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b)))) + t*(1-a-b)*(1+(a-b-4*((c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b)))-2*((c - k + (1/3)*t*(1-a-b)*(3+b-a) + t*(2*(1-b-x)^2 - (x-a)^2))/(1+2*t*(1-a-b))))/3)) -((c - k + (1/3)*t*(1-a-b)*(3+a-b) + t*(2*(x-a)^2 - (1-b-x)^2))/(1+2*t*(1-a-b)))))/(2*t*(1-a-b)) + (1-a-b)/2 ;
S = solve(eqn,x)
  2 Comments
Seyoung Won
Seyoung Won on 26 Aug 2019
no it doesn't.... and I think mere substitution wouldn't work because even if one put x terms into v_1 and v_2, at the end of substitution v_1 and v_2 are simultaneously determined so I think it's supposed to be solving a system of 5 equations.
But I have no idea where my code went wrong, a b c k t are just parameter values and I have 5 equations for 5 unknowns, x p1 p2 v1 v2
Torsten
Torsten on 26 Aug 2019
Edited: Torsten on 26 Aug 2019
I inserted the expressions for v1 and v2 in p1 and p2 and then inserted v1, v2 and the revised p1 and p2 all in the first equation x == ...
I only inspected this equation superficially, but it seems it is a quadratic equation in x that MATLAB should be able to solve.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!