Solving set of non-linear equations with two unknowns in MATLAB

In summary, the given Matlab code uses a numerical root-finding algorithm to solve a system of non-linear equations and the output is the value of tau that satisfies the system of equations.
  • #1
bilalcisco
1
0
Hi,
I have two non-linear equations with two unknowns, i.e., tau and p. both equations are:
p=1-(1-tau).^(n-1)
and
tau - 2*(1-2*p) ./ ( (1-2*p)*(W+1)+(p*W).*(1-(2*p).^m)).

I am interested to find the value of tau.
After doing some research on internet I came to know that these equations can be solved by finding roots and finding fixed points. However, the problem is not that straight as it involves two non-linear equations, as opposed to various examples I found on internet which involves only one non-linear equation.
Additionally, I have MATLAB code for solving this problem, but still spending few days to understand and searching internet relentlessly, I couldn't understand how this solution actually works. Below I am giving that MATLAB code and need your helping hand to explain it to me the actual logic behind solving 'set of non-linear equations.

Matlab M-file is:

function result=tau_eq(tau)

n=6;
W=32;
m=5;

p=1-(1-tau).^(n-1);
result=tau - 2*(1-2*p) ./ ( (1-2*p)*(W+1)+(p*W).*(1-(2*p).^m));

Command at the command window:
result=fzero(@tau_eq,[0,1],[])
output is:
result =

0.0448

The given result is satisfactory, however I do not understand the logic behind it. Any explanation or referring to useful resources will be highly appreciated.
 
Physics news on Phys.org
  • #2
Thanks in advance. The given Matlab code is an example of using a numerical root-finding algorithm to solve a system of non-linear equations. The function "fzero" is used to find a root (in this case, the root is tau) of a function (in this case, the function is given by the equations you provided). The input of the fzero function is the equation (in this case, it is the @tau_eq function) and the interval ([0,1]) in which the root is expected to lie. The output is the value of tau that satisfies the system of equations. Root finding algorithms are iterative methods which use an initial guess for the root and iteratively refine it until the desired accuracy is achieved. The process of refinement is based on the derivatives of the equations (in this case, the Jacobian matrix of the system of equations) and can be thought of as a method for minimizing the error between the equations and their solutions. This process is repeated until the error is sufficiently small and the solution is accepted as the root. There are several root-finding algorithms available and they differ in terms of their efficiency, accuracy, and robustness. In this case, the fzero function is using the Brent's method, which is a combination of the bisection and secant methods. For more information, you can refer to the Mathworks website: https://www.mathworks.com/help/matlab/ref/fzero.html
 

1. How do I define the non-linear equations in MATLAB?

To define a non-linear equation in MATLAB, you can use the fzero function. This function takes in two inputs: a function handle and an initial guess for the solution. The function handle should be defined using the @ symbol, followed by the function name.

2. Can I solve a set of non-linear equations with more than two unknowns in MATLAB?

Yes, MATLAB allows you to solve a set of non-linear equations with any number of unknowns. You can use the fsolve function, which takes in two inputs: a function handle and a vector of initial guesses for the solutions. The function handle should be defined using the @ symbol, followed by the function name.

3. How do I check if my solution is correct?

After solving the set of non-linear equations, you can use the allclose function to check if the solutions satisfy the equations. This function takes in two inputs: the function handle for the equations and the solutions. If the solutions satisfy the equations within a given tolerance, allclose will return true.

4. Can I plot the solutions for a set of non-linear equations in MATLAB?

Yes, you can use the plot function to plot the solutions for a set of non-linear equations in MATLAB. First, define the equations and solutions as vectors, and then use the plot function with the 'o' option to plot the solutions as points on a graph.

5. Is there a built-in function to solve non-linear equations in MATLAB?

Yes, MATLAB has a built-in function called fsolve which can solve a set of non-linear equations with two or more unknowns. This function uses the Newton-Raphson method to iteratively find the solutions. However, it is always recommended to check the solutions using other methods to ensure their accuracy.

Similar threads

  • Calculus and Beyond Homework Help
Replies
0
Views
160
  • Calculus and Beyond Homework Help
Replies
2
Views
270
  • Calculus and Beyond Homework Help
Replies
1
Views
703
  • Calculus and Beyond Homework Help
Replies
5
Views
283
  • Calculus and Beyond Homework Help
Replies
7
Views
409
  • Calculus and Beyond Homework Help
Replies
14
Views
591
  • Calculus and Beyond Homework Help
Replies
24
Views
792
  • Calculus and Beyond Homework Help
Replies
7
Views
704
  • Calculus and Beyond Homework Help
Replies
12
Views
1K
  • Calculus and Beyond Homework Help
Replies
7
Views
275
Back
Top