Matlab code for solving nonlinear equations
古いコメントを表示
How can I solve three nonlinear equations to get the closest real solutions and not complex numbers.
3 件のコメント
Torsten
2022 年 9 月 24 日
Please show your equations.
Asma
2022 年 9 月 24 日
Walter Roberson
2022 年 9 月 24 日
Taking the cosine of 55 radians is... unusual. Perhaps you want the cosine of 55 degrees instead?
採用された回答
その他の回答 (2 件)
Since you generally asked for any three nonlinear equations, I guess you just need to constrain the solver/algorithm to take only the integer values.
Otherwise, you can try this as shown in the example:
intcon = 1;
rng default % For reproducibility
fun = @(x) (x - 3.25).^2;
A = [];
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
nonlcon = [];
x = ga(fun, 1, A, b, Aeq, beq, lb, ub, nonlcon, intcon)
5 件のコメント
Asma
2022 年 9 月 24 日
Asma
2022 年 9 月 24 日
Walter Roberson
2022 年 9 月 24 日
fsolve cannot be constrained to integers.
Walter Roberson
2022 年 9 月 24 日
ga() cannot be used with multiple objectives.
take your three parts and square each of them and sum the three, so you have sum of squares. The result is something that can be used with ga() configured with integer constraints.
Asma
2022 年 9 月 24 日
Walter Roberson
2022 年 9 月 24 日
1 投票
In the general case that could be difficult and time consuming. For example the nonlinear system might be describing Elliptic Curve Cryptography.
Nonlinear systems often have multiple local minima, sometimes a large or infinite number of them. Finding the nearest integer solution could require finding all of those minima and testing all combinations of round() +/- 1 and picking out the one with the lowest residue.
Now, there are certainly some nonlinear systems that are less work than that, but finding the combination that is certain to be the closest integer solution is generally a hard problem.
カテゴリ
ヘルプ センター および File Exchange で Equation Solving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

