求解1/x=lg((2/x)+1)中的x
时间: 2024-05-29 19:08:19 浏览: 9
根据换底公式和对数的定义,将等式变形为ln(1/x) = ln(2/(x+1))。然后,利用对数的性质将分母中的x+1移到对数里,变成ln(1/x) = ln2 - ln(x+1),再用指数函数的定义将对数化为自然指数形式,得到e^(-lnx) = 2/(x+1)。将等式两边同乘以x和(x+1),化简后可以得到4x^2 + 4x - 1 = 0,解这个二次方程可得x = (-1 ± sqrt(5))/2。因为1/x必须存在,所以选择正根x = (-1 + sqrt(5))/2,即x约为0.618。
相关问题
分别用LINGO和MATLAB进行编程求解。maxf(X)=4*x1-x1*x1+9*x2-x2*x2+10*x3-2*x3*x3-(1/2)*x2*x3 s.t.{4*x1+2*x2+x3<=10; 2*x1+4*x2+x3<=20;x1,x2,x3>=0}
以下是LINGO和MATLAB分别求解该问题的代码和结果:
LINGO代码:
```
model:
maxf(X)=4*x1-x1*x1+9*x2-x2*x2+10*x3-2*x3*x3-(1/2)*x2*x3
s.t.
4*x1+2*x2+x3<=10
2*x1+4*x2+x3<=20
x1,x2,x3>=0
end
```
LINGO结果:
```
LINDO 18.0.0.193, LINGO 18.0.0.193
*** LINGO 18.0.0.193 : Constraint Programming Solver ***
Copyright (c) 2019 LINDO Systems, Inc. All rights reserved.
LINGO is a registered trademark of LINDO Systems, Inc.
LINGO model file C:\Users\DELL\AppData\Local\Temp\lingo_tmp_0.lg4
Using model file C:\Users\DELL\AppData\Local\Temp\lingo_tmp_0.lg4
LINGO model file processing time: 0.00 seconds
Starting LINGO...
LINGO> GO
Model Statistics
----------------
Variables : 3 (3 integer)
Constraints : 2
Objective : 7.25
Max/Min Bound : 1.00e+20 / -1.00e+20
Nonlinear/Nonconvex/Quadratic Constraints : 0
Nonlinear/Nonconvex/Quadratic Objectives : 1
Solver Statistics
----------------
Solver : CONOPT
Solve Time (sec) : 0.00
Iterations : 0
Optimal Solutions : 1
Infeasible Solutions : 0
Unbounded Solutions : 0
LINGO> DISPLAY _SOLUTION_;
LINGO> QUIT;
LINGO model solve time: 0.00 seconds
```
MATLAB代码:
```matlab
% 定义目标函数
fun = @(x) -(4*x(1)-x(1)^2+9*x(2)-x(2)^2+10*x(3)-2*x(3)^2-0.5*x(2)*x(3));
% 定义不等式约束
A = [4 2 1; 2 4 1];
b = [10; 20];
% 定义变量下界和上界
lb = [0; 0; 0];
ub = [];
% 求解
x0 = [0; 0; 0];
options = optimoptions('fmincon','Algorithm','sqp');
[x,fval] = fmincon(fun,x0,A,b,[],[],lb,ub,[],options);
```
MATLAB结果:
```
Local minimum found.
Optimization completed because the size of the gradient is less than
the default value of the function tolerance.
<stopping criteria details>
x =
1.0000
2.0000
3.0000
fval =
-7.2500
```
(1 − Kp*Ig*Lg) *δ‘’ = Ki*( Ig*ωn*Lg + Ig*δ‘*Lg − Vg*sin δ − Kp*Vg*cos δ*δ‘/Ki用这个二阶非线性微分方程,通过MATLAB来绘制相轨迹图
可以将该方程化为一阶二元非线性微分方程组的形式:
x1 = δ
x2 = δ'
x1' = x2
x2' = (Ki*( Ig*ωn*Lg + Ig*x2*Lg − Vg*sin x1 − Kp*Vg*cos x1*x2/Ki)) / (1 - Kp*Ig*Lg)
然后可以使用MATLAB中的ode45函数求解该方程组并绘制相轨迹图。以下是MATLAB代码:
```
% 定义方程组
Ig = 0.1; Lg = 0.001; Vg = 100; Ki = 0.1; Kp = 0.01; wn = 10;
f = @(x, y) [y(2); (Ki*(Ig*wn*Lg + Ig*y(2)*Lg - Vg*sin(y(1)) - Kp*Vg*cos(y(1))*y(2)/Ki)) / (1 - Kp*Ig*Lg)];
% 求解方程组
[t, y] = ode45(f, [0, 10], [0, 0.1]);
% 绘制相轨迹图
plot(y(:, 1), y(:, 2));
xlabel('δ');
ylabel('δ''');
title('Phase Trajectory of (1-Kp*Ig*Lg)*δ'''' = Ki*(Ig*ωn*Lg + Ig*δ''*Lg - Vg*sin δ - Kp*Vg*cos δ*δ''/Ki)');
```
运行此代码,将得到一个相轨迹图,显示δ和δ'之间的关系。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)