Solve equations graphically based on MATLAB (with images and codes)

Table of contents

1. One-variable equation graphic method

Example 1

2. Graphical method of binary equation

Example 2

3. Polynomial equation

Example 3


1. One-variable equation graphic method

Example 1

Find it graphically:

e^{-3t}sin(4t+2)+4e^{-0.5t}cos(2t)=0.5

untie:

MATLAB code:

clc;clear;
ezplot('exp(-3*t)*sin(4*t+2)+4*exp(-0.5*t)*cos(2*t)-0.5',[0 5])
hold on,
line([0,5],[0,0]) %同时绘制横轴

%验证
syms t;
t=3.522;
vpa(exp(-3*t)*sin(4*t+2)+4*exp(-0.5*t)*cos(2*t)-0.5)

operation result:

2. Graphical method of binary equation

Example 2

Find it graphically:

untie:

MATLAB code:

clc;clear;
ezplot('x^2*exp(-x*y^2/2)+exp(-x/2)*sin(x*y)') %第一个方程曲线
hold on  %保留当前坐标系
ezplot('x^2 *cos(x+y^2) +y^2*exp(x+y)')

 operation result:

The graphical method of equations is only applicable to root-finding problems of one-variable and two-variable equations.

3. Polynomial equation

Example 3

Find it graphically:

\begin{cases}x^2+y^2-1=0\\0.75x^3-y+0.9=0 \end{}

untie:

Theoretically, there are at least 6 solutions to this system of equations, but the graphical method can only show the real roots of the solved equations.

code:

clc;clear;
ezplot('x^2+y^2-1'); 
hold on  % 绘制第一方程的曲线
ezplot('0.75*x^3-y+0.9')    % 绘制第二方程

operation result:

One of the solutions is x=-0.98124, y=0.19004. Actually this system of equations has four complex roots.

The roots of general polynomial equations can be real numbers or complex numbers. Therefore, the solve() function in the MATLAB symbolic toolbox can be used.

Guess you like

Origin blog.csdn.net/forest_LL/article/details/124576567