# Result for solve( ) with minimized number of parameters

10 views (last 30 days)

Show older comments

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 Comments

### Accepted Answer

John D'Errico
on 26 Oct 2021

Edited: John D'Errico
on 26 Oct 2021

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.

### More Answers (1)

Walter Roberson
on 26 Oct 2021

##### 2 Comments

Walter Roberson
on 26 Oct 2021

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)

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!