im trying to solve a system of 4 nonlinear equations with 4 unknowns

조회 수: 8 (최근 30일)
joshua payne
joshua payne 2022년 11월 23일
댓글: Alex Sha 2022년 11월 27일
clc
clear all
f= @(x) [x(1)+.17*x(1)-x(2)-x(3)-x(4); (((x(3)^(1/2))*x(4))/x(2))-.465797; 2*x(1)-2*x(2)-2*x(3)-x(4); 2*(.17*x(1))-x(2)-x(4)]
s=fsolve(f, [2,2,1,1])
it says it stops prematurely.
im also not sure how to plot these equations to see where my geusses should be

답변 (2개)

Torsten
Torsten 2022년 11월 23일
Equations (1), (3) and (4) give x(2) = 0. Thus it's impossible to satisfy equation (2) where x(2) is in the denominator.
syms x1 x2 x3 x4
f1 = x1+.17*x1-x2-x3-x4 == 0
f1 = 
f2 = 2*x1-2*x2-2*x3-x4 == 0
f2 = 
f3 = 2*0.17*x1-x2-x4 == 0
f3 = 
sol = solve([f1,f2,f3],[x1 x2 x4])
sol = struct with fields:
x1: (100*x3)/83 x2: 0 x4: (34*x3)/83

John D'Errico
John D'Errico 2022년 11월 23일
x = sym('x',[1,4])
x = 
eq1 = x(1)+.17*x(1)-x(2)-x(3)-x(4) == 0
eq1 = 
eq2 = (((x(3)^(1/2))*x(4))/x(2))-.465797 == 0
eq2 = 
eq3 = 2*x(1)-2*x(2)-2*x(3)-x(4) == 0
eq3 = 
eq4 = 2*(.17*x(1))-x(2)-x(4) == 0
eq4 = 
So you have 3 linear equations, and one nonlinear. Does a solution exist? We might ask solve, since this is a pretty simple system.
solve(eq1,eq2,eq3,eq4)
ans = struct with fields:
x1: [0×1 sym] x2: [0×1 sym] x3: [0×1 sym] x4: [0×1 sym]
So solve found no solution.
vpasolve(eq1,eq2,eq3,eq4)
ans = struct with fields:
x1: [0×1 sym] x2: [0×1 sym] x3: [0×1 sym] x4: [0×1 sym]
Even vpasolve fails to find a solution.
Equations 1, 3, and 4 are called a homogeneous linear system, although we only have 3 equations in those 4 unknowns. I'll convert them to a matrix form, thus..
[A,b] = equationsToMatrix([eq1,eq3,eq4])
A = 
b = 
We can recover the original equations by a matrix multiply, thus:
A*x.' == b
ans = 
Clearly x1=x2=x3=x4=0 is a solution to that subset of equations. Does a non-trivial solution exist? Yes. It comes from the function null.
Anull = null(A)
Anull = 
So we have that x = Anull, or any multiple of that vector is a solution to the homogeneous linear part of your problem. Now, return to eq2. Do you see the problem?
eq2
eq2 = 
The ONLY solution to those three equations has x2 == 0. But in eq2, we divide by x2.
Therefore, NO solution can possibly exist for this system of equations.
  댓글 수: 1
Alex Sha
Alex Sha 2022년 11월 27일
1: Approximate numerical solution
x1: 4.59039465606019E-13
x2: 1.70124596189725E-20
x3: 4.79191761335149E-13
x4: 1.14474596953164E-14
Feval:
F1 = 4.64369367161173E-14
F2 = 1.11022302462516E-15
F3 = -5.17520851784955E-14
F4 = 1.4462594159827E-13
2: making some transformation for 2nd equation:
(((x3^(1/2))*x4)/x2)-.465797=0
equivalence transformed into:
(((x3^(1/2))*x4))-.465797*x2=0
then the solution will be:
x1: 0
x2: 0
x3: 0
x4: 0

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by