MATLAB编程推导公式
文中利用MATLAB演示了二元一次方程的求根公式推导过程。
数学方程
a x 2 + b x + c = 0 ax^2+bx+c=0 ax2+bx+c=0
其数学通解形式为
x
=
−
b
±
b
2
−
4
a
c
2
a
x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}
x=2a−b±b2−4ac
源代码
clc,clear;
syms x a1 a2 w wn
% simple test, viertify the correctness of solving algorithm
syms b c a
eqn = a*x^2+b*x+c == 0;
S = solve(eqn,x,'ReturnConditions',true);
% solve notch filter reference link(derivation maybe mistake) --https://www.pianshen.com/article/1933991321/
% x = w/wn
% eqn = (((1-x^2)^2 + 4*a1*a2*x^2)^2+((1-x^2)*2*a2*x-(1-x^2)*2*a1*x)^2)/((1-x^2)^2+(2*a1*x)^2) == 1/2
% eqn = (((1-x)^2 + 4*a1*a2*x)^2+((1-x)*2*a2*sqrt(x)-(1-x)*2*a1*sqrt(x))^2)/(((1-x)^2+(2*a1*sqrt(x))^2))^2 == 1/2
S.x(1,1)
S.x(2,1)
% S.x(3,1)
% S.x(4,1)
% S.x(5,1)
% S.x(6,1)
% S.x(7,1)
% S.x(8,1)