Result for solve( ) with minimized number of parameters
1 次查看(过去 30 天)
显示 更早的评论
I have an underdetermined system with the following variables:
vars = [x1;u;x2;x1_d;u_d;x2_d]
and the following equations:
eq = [x2_d == 0;
log(x2) + sin(u) == 0]
I want to solve the system using the 'ReturnConditions' function, in order to get a parametrized solution.
Is it possible to obtain a parametrization such that the number of parameters is minimized? For example, if I run in this case the following:
Sol = solve(eq, [u;x2], 'ReturnConditions', true)
I get the following solution:
Sol.parameters = [k, z4, z5, z6, z7]
Where the second equations was parametrized as u in terms of x2:
Sol.x2 = z5
Sol.u = pi + asin(log(z5)) + 2*pi*k
However, if the solver would have chosen to parametrize x2 in terms of u, I could have get something like this (the following was done by hand, just to show my expected result):
Sol.u = z5
Sol.x2 = exp(-sin(z5))
In this case, we don't need the parameter k, thus our parameters would be as follows:
Sol.parameters = [z4, z5, z6, z7]
I would really appreciate your help in here, I hope it's clear enough.
0 个评论
采纳的回答
John D'Errico
2021-10-26
编辑:John D'Errico
2021-10-26
The problme is, the "minimal" solution that you ask for is not the complete solution. You asked solve to provide a solution. How is solve to know that you want a half baked job, only a partial solution? Solve cannot read your mind.
Of course, if you knew in advance which parameters mattered to you, then you could manage things slightly better. So you might decide to choose in advance, that some of the parameters are perhaps zero. So you might decide to try setting all combinations of 4 of the 6 parameters to zero, and then seeing if solve can solve the problem in a way that makes you happy.
Or, you might look at the solution you did get, with essentially:
Sol.x2 = z5
Sol.u = pi + asin(log(z5)) + 2*pi*k
and then recognize that k has been introduced because there are infinitely many solutions. So set k==0, and then it reduces a bit. But now we still have the problem, is x2==z5 real? Is x2 bounded? is u real? Look at the original problem you posed. We see:
log(x2) + sin(u) == 0
But if x2 is such that log(x2) is greater than 1, or less than -1, then u will not be real valued. And of course, solve has not been told of any of that, so it cannot know how far to reduce the problem. But all of this is doing the thinking for solve, and if you do not want to do any thinking at all, then solve will be hopelessly stuck.
更多回答(1 个)
Walter Roberson
2021-10-26
No. You asked to solve in terms of u and x2, so the results always have to have u and x2 expressed in terms of constants or independent variables.
2 个评论
Walter Roberson
2021-10-26
syms x1 u x2 x1_d u_d x2_d
vars = [x1;u;x2;x1_d;u_d;x2_d]
eq = [x2_d == 0;
log(x2) + sin(u) == 0]
x2_sol = solve(eq(2), x2)
eq2 = subs(eq(1), x2, x2_sol)
u_sol = solve(eq2, u, 'returnconditions', true)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!