Cannot solve symbolic equation annalytically
9 ビュー (過去 30 日間)
Marc Laub 2020 年 3 月 30 日
コメント済み: Walter Roberson 2020 年 4 月 1 日
I have following problem.
I am computing phase equilibria from thermodynamic data. Those polynomials consist of hundrets of variables and i found out that once solves analytically its much faster to solve them numerically in every itteration. But somehow i got an equation which i am unable to solve..Since the equation is so long i attached it in a seperate .txt file.
When trying to solve(eqn==0,NB_pre) i always get:
Warning: Unable to find explicit solution. For options, see help.
> In solve (line 317)
In ortho_try (line 26)
I tried everything but nothing helped.
When trying with vpasolve i get:
Symbolic parameters not supported in nonpolynomial equations.
Since most of the variables are const in the itteration itsself, I took them out of the syms varaibles and handeled them as constants, leaving only my NB_pre as variable.
Doing this, matlab tells me:
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
> In solve (line 304)
In equilibriater>chemical_potter_phase (line 257)
In equilibriater (line 26)
The numeric solution provided is correct, but unfortunattely numerical calculated, which in first place only works with symbolic functions and second takes too long time.
What i need is an analytical solution where I only need to insert my variables (constants).
Does anybody has an idea why the function (which is basically only a difference of sums of polynomials with some logarythmic functions) is not solvable analytically? Not even numericall, only when i put im some constant values instead of variables?
Note: the solution has to be within the intervall [0,1], othervise its not a solution, since NB_pre can only vary within this range.
The function from the txt file is included in the input_variables file as symfun, but only with NB_pre as variable, while all other variables from the txt file are replaced by constante, also saved within the txt file
Many thanks in adavance,
Hopefully there is a solution for this problem.
Walter Roberson 2020 年 3 月 30 日
編集済み: Walter Roberson 2020 年 3 月 31 日
Does anybody has an idea why the function (which is basically only a difference of sums of polynomials with some logarythmic functions) is not solvable analytically?
Your function with those constants simplifies to
1/70368744177664 * ((-1170156196038742272 * NB_pre^4 + 11*NB_pre^3) * log((2*NB_pre-1)/NB_pre) + (585078098019371136*NB_pre^4 - 11*NB_pre^3) * log((-NB_pre+1)/NB_pre) - 69157852880379731712 * NB_pre^4 + 139200283138766929920 * NB_pre^2 - 122053179401274654720 * NB_pre + 30513294850318663680) / NB_pre^4
To solve for zero you can take the numerator, which gives you something that is polynomial-like up to NB_pre^4 but containing terms
log((2*NB_pre - 1)/NB_pre)
Most of the time when you have log or exponential terms with other terms, there will be no analytic solution. Except for some situations that can be transformed into complex representation and solved in terms of trig, typically the only cases involving log or exp that can be solved analytically are those that can be solved in terms of the Lambert W function.
The LambertW function can be used for equations of the form (x+A)*exp(x^N+B)=C for N a non-negative integer, or of the form x*exp(x^N+B)=C for N a negative integer, and for the log transforms of those such as log(x) + x^N + B = log(C ) . But it can't go much further than that. For example it cannot solve x*exp(x^2+2*x+1)=A or x*exp(x) + x = A . It can deal with the individual term x*exp((2*x - 1)/x) = A but not when you start adding anything to the left hand side.
Polynomials and logs seldom mix to find closed form solutions.
Walter Roberson 2020 年 4 月 1 日
True analytic solutions correspond roughly to calculations that can be constructed geometrically. For example a number of square roots of integers can be constructed geometrically, such as sqrt(13) being the length of the hypoteneuse of a right triangle with sides of length 2 and 3; in turn 2 and 3 can be constructed by compass and straight-edge.
But most logs cannot be constructed geometrically. Logarithms mostly require an infinite series, and are only approximated mathematically. Supposedly Intel CPUs use an algorithm based on taylor series and a look-up table to approximate the answer.
You can do a taylor expansion of your formula to any desired degree, but if you go beyond roughly order 5, you are going to end up with a formula involving x^5 or higher, and you would be wanting to solve that polynomial for its roots. Unfortunately, some advanced group theory (Abel-Ruffini) showed that starting at order 5, the "number" of possible polynomials exceeded the number of possible constructable analytic solutions for roots, and thereby showed that there are polynomials of degree 5 or higher that cannot possibly have constructable analytic solutions (this applied even for integer coefficients.)
その他の回答 (1 件)
John D'Errico 2020 年 3 月 31 日
編集済み: John D'Errico 2020 年 3 月 31 日
"Does anybody has an idea why the function (which is basically only a difference of sums of polynomials with some logarythmic functions) is not solvable analytically? Not even numericall, only when i put im some constant values instead of variables?"
There is only so much you can do to solve a problem in symbolic form. You can do simple algebraic manipulations, adds, subtracts, multiplies, divides. You can transform the problem, by taking a transformation of a variable, or by using nonlinear transformations applied to entire expressions. You can use various known identities that apply to special functions.
However, those transformations have limits to what can be done. And very often those transofrmations just introduce more special functions into the mix. Sometimes, you get lucky, with a very simple problem.
syms a x
solve( x == exp(x),x)
So for the above mix of a polynomial and a special function (even though a rather common one) we have a solution. But that solution required solve to introduce an entirely new special function. Solve can also handle the next one, using a different special function, even though the two problams are subtly intertwined.
solve( x == log(x),x)
But make it slightly more complex, and the solution fount dries up. Now only a numerical solution exists.
solve( x^2 - 1 == exp(x),x)
Nobody has ever chosen to spend the time to define a special function family that characterizes this solution in the form of a special function. So at best, we can find a numerical solution, using what is effectively a nonlinear rootfinding approach.
A problem arises however, when we introduce a symbolic parameter into the problem. For example...
solve( x^2 - a == exp(x),x)
Empty sym: 0-by-1
When we have a symbolic parameter in there, that unknown parameter a changes the problem. Now we cannot perform an iterative solution (Newton's method, for example) since the shape of these things can completely change, depending on the values of the parameters in the problem.
Even in the simple example of a polynomial, if we wanted to apply Newton's method to the problem:
a*x^2 - b == 0
depending on the signs and values of the parameters a and b, there may be a single real solution, or two real solutions, or only complex solutions. As such, even that simple polynomial cannot be solved numerically, UNLESS we provide the values of a and b, at which point it becomes simple. Luckily, since this is a simple polynomial, we have analytical resources. However, make the problem only a little more complicated, and that too will fail. Thus...
a1*x^5 + a2*x^4 + a3*x^3 + a4*x^2 + a5*x + a6 == 0
Now we have a fully general 5th degree polynomial in x. It was long ago shown (Abel-Ruffini) there are now no general solutions that can ever be given. If the parameters a1,...a6 are given specfic values, then again we can find the roots of that polynomial, in numerical form. But that is the limit of what you can do.
Once you introduce also special functions, in the form of logs, etc., into the mix? Just wanting a solution is not enough. Yes, you could try to formulate the solution of some specific class of problems as itself a special function. Name that special function what you will.
You also ask why even numerical solvers are not able to handle a general problem with symbolic parameters. But if you think of a numerical solver as a very simple search routine, that can adaptively move around, searching for a solution, consider that if we formulate even the simple problem. Here, find the minimum of the problem:
a*x^2 - 1
as a function of x. The problem is, if we change the sign of a then the shape of that function undergoes a fundamental change. This gets far more complex when the problem has lots of unknown parameters, but you need to recognize the problem is no longer solvable using numerical methods. The final answer there becomes to take a class (or read a book) to learn how numerical methods work.
Another solution method sometimes suggested is to expand the problem as Taylor series in the unknown variable. Of course, this very much requires a full understanding of infinite series and the convergence thereof. Thus, consider the simple problem:
x/2 - 1 == cos(x)
Unless you bother to define the solution in terms of your own special function family, you will be out of luck here, unless you use a numerical solver as I explained above.
solve(x/2 - 1 == cos(x))
Even worse, consider the more general form:
a*x + b == cos(x)
Again, no general solution will exist at all now. However, we could expand this in a series approximation. Perhaps:
taylor(x*a - b - cos(x),x,'order',10)
- x^8/40320 + x^6/720 - x^4/24 + x^2/2 + a*x - b - 1
Now, we could try to solve for the roots of that polynomial. Sorry, but you will be again out of luck. Abel-Ruffini will again interfere, since no solution will exist. And depending on the values of a and b, it might require a VERY high order polynomial before the Taylor polynomial is even a good approximation to what is happening in the vicinity of a solution.
Again, it gets complicated, and the best answer might to revisit your course notes from some semester of calcuus, or to take a course on numerical analysis.
Yes, I understand that my comments in this answer were sort of on the order of how a parent might answer their child, when asked "Why is the sky blue?". To some extent, you might try a discussion about spectral scattering of different wavelengths of light in the atmosphere. At some point, the answer will reduce to - it gets complicated.
Sorry, but there are limits to what you can do in the form of a symbolic problem. Computers are not infinitely capable, and mathematics is not able to solve all possible problems. Have I really answered your fundamental question? Maybe not, because it gets complicated. :)
Find more on Mathematics and Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!