Home > Software engineering >  "fsolve" doesn't work for system nonlinear equation
"fsolve" doesn't work for system nonlinear equation

Time:02-16

I have these equations:

syms pm pr teta s  
A1 = -2 * b1 * pm   2 * b2 * pr   b * teta   (1-t) * s   (1-p) * a   c * (b1 - b2);
A2 = 2 * b2 * pm   2 * b1 * pr   (1-b) * teta   t * s   p * a   c * (b1 - b2);
A3 = b * pm   (1-b) * pr - n * teta - c;
A4 = (1-t) * pm   t * pr - k * s - c;
eqns = [A1,A2,A3,A4];

F=@(pm, pr, teta, s) [A1
                      A2
                      A3
                      A4];
                      
x0 = [10, 10, 10, 10];
fsolve(F, x0)

How I can solve them? (When I use fsolve, it shows this error: FSOLVE requires all values returned by functions to be of data type double)

CodePudding user response:

Since you tagged Mathematica

A1 = -2*b1*pm   2*b2*pr   b*teta   (1 - t)*s   (1 - p)*a   c*(b1 - b2);
A2 = 2*b2*pm   2*b1*pr   (1 - b)*teta   t*s   p*a   c*(b1 - b2);
A3 = b*pm   (1 - b)*pr - n*teta - c;
A4 = (1 - t)*pm   t*pr - k*s - c;

FullSimplify[Solve[{A1 == 10, A2 == 10, A3 == 10, A4 == 10}, {pm, pr, teta, s}]]

pm -> ((k ((-1 b)^2 2 b1 n) n t^2) (b (10 c) k n (10 c 10 k - a k - b1 c k b2 c k a k p - (10 c) t)) ((-1 b) (10 c) k k n (-10 b1 c - b2 c a p) - (10 c) n t) (b k - b^2 k n (2 b2 k t - t^2)))/(k n (1 - 2 b1 k b^2 (1 4 b2 k) 2 (b1 - 2 (b1^2 b2^2) k) n - 2 t - 4 (b1 b2) n t (1 4 b2 n) t^2 2 b (-1 2 b1 k - 2 b2 k t)))

pr -> (c b^2 (10 c - (-20 a 2 b1 c - 2 b2 c) k) 2 b1^2 c k n - b2 (20 c - 2 (-10 a) k 2 b2 c k) n - a (1 2 b2 k) n p - 2 b1 k (10 c n (10 - a p)) 10 (1 n - 2 t) - c (2 b2 n) t n (-30 a 20 b2 a p) t (10 c - (-20 a) n 2 b2 c n) t^2 - b1 n (c 20 t c t (-1 2 t)) b (k (-10 a 20 b1 - 20 b2 - a p) 20 (-1 t) c (-2 3 b1 k - 3 b2 k 2 t)))/(1 - 2 b1 k b^2 (1 4 b2 k) 2 (b1 - 2 (b1^2 b2^2) k) n - 2 t - 4 (b1 b2) n t (1 4 b2 n) t^2 2 b (-1 2 b1 k - 2 b2 k t))

teta -> (10 - 20 b2 - b2 c - 20 b2 k 2 a b2 k 40 b2^2 k 2 b2^2 c k 2 b1^2 (20 3 c) k - a p - 2 a b2 k p (-30 3 b2 (20 c) a (1 p)) t - (-20 a 2 b2 (20 c)) t^2 b (-10 - 4 b1^2 c k a p b1 (20 40 k - 2 a k c (3 4 b2 k - 2 t)) 20 t - a t b2 (20 c - 2 a k 4 a k p - 2 (20 c) t)) b1 (2 k (-10 a p) 20 (-1 t) c (-3 (5 - 2 t) t)))/(1 - 2 b1 k b^2 (1 4 b2 k) 2 (b1 - 2 (b1^2 b2^2) k) n - 2 t - 4 (b1 b2) n t (1 4 b2 n) t^2 2 b (-1 2 b1 k - 2 b2 k t))

s -> (20 b1 b1 c - b2 c - 2 b^2 (-10 b1 c b2 (20 c)) 20 b1 n 40 b1^2 n - 20 b2 n 40 b2^2 n 2 b1^2 c n 4 b1 b2 c n 2 b2^2 c n - (b1 - b2) (20 c) t 4 b1 (-10 b1 c - b2 c) n t - 10 (-1 2 b2 t) a (-1 - b^2 - 2 b1 n p 2 (b1 b2) n p t - p t 2 n (b1 b2 - 2 b2 p) t - b (-2 p t)) b (-(-10 b2 (20 c)) (-3 2 t) b1 (-20 c - 2 c t)))/(1 - 2 b1 k b^2 (1 4 b2 k) 2 (b1 - 2 (b1^2 b2^2) k) n - 2 t - 4 (b1 b2) n t (1 4 b2 n) t^2 2 b (-1 2 b1 k - 2 b2 k t))

  • Related