Matlab wouldn't find simple inverse

조회 수: 18 (최근 30일)
Niklas Kurz
Niklas Kurz 2021년 11월 30일
편집: Paul 2021년 11월 30일
Given the function defined via
syms x a real; f = x^(a-1)
Why Matlab won't find an inverse to that?
finverse(f)
is resulting to an empty array.
However merely by looking at the function the inverse might be
I guess due to MATLAB's wide insight there is a case where this general solution fails so it can't find one at all.

채택된 답변

John D'Errico
John D'Errico 2021년 11월 30일
편집: John D'Errico 2021년 11월 30일
There is another possibly more important problem, beyond those mentioned by @Yongjian Feng.
While you may, personally think the inverse function is of the form you show. But what if you wanted to see an inverse in terms of a?
You have TWO parameters in there: a AND x. And yes, surely you think of x as a variable, with a as an unknown parameter. We get conditioned to think of things that way.
But suppose we made this a simpler problem, without x in there?
syms a
f = 2^(a - 1);
finverse(f)
ans = 
Now finverse actually succeeds, because it sees only the one variable: a.
So I will argue the problem is not so much that MATLAB was worried a might have special values that invalidated the existence of an inverse, but that MATLAB was unsure what the inverse function means when you have TWO variables.
syms a x real
f = x^(a-1)
f = 
finverse(f,x)
Warning: Unable to find functional inverse.
ans = Empty sym: 0-by-1
finverse(f,a)
ans = 
As you should see, in the first case, MATLAB still gets upset, because for some values of a, the inverse does not exist. It tells you that. I could probably tell MATLAB to assume a never takes on problematic values. I'm actually a little surprised that in the second case, the inverse function becomes problematic if x==1, in which case again an inverse will not exist. Regardless, there would be two very different inverses, depending on whether a or x is the variable.
Had your function been of the form:
f = x^(y-1)
my guess is you might have recognized this as an issue. But we are conditioned to think of x as a variable, whereas a is always a parameter. We get this from schooling, from books, etc. MATLAB does not have such preconceptions, nor should it.
But you should see the issue now. MATLAB needs to know if it should consider this a function of a or of x, where the other variable is just a parameter. You needed to provide guidance to finverse.
  댓글 수: 1
Paul
Paul 2021년 11월 30일
편집: Paul 2021년 11월 30일
Usually, when the var isn't speficied as an input to SMT function, the default is to use symvar(expr,1) where expr is the input to the function. For example, see the doc pages for diff and int. That also seems to be the behavior of finverse(). For example:
syms u v
finverse(exp(u-2*v), u)
ans = 
finverse(exp(u-2*v), v)
ans = 
finverse(exp(u-2*v))
ans = 
symvar(exp(u-2*v),1)
ans = 
v
However, the doc page for finverse() does not call out this behavior explicitly, even though it appears to be how the function actually works.
For the case of the OP
syms x a real;
f = x^(a-1)
f = 
symvar(f,1)
ans = 
x
Matlab wasn't unsure about which solution was being requested. It assumes that the variable is x and then reports that it cannot find the solution for that variable.
Having said that, I agree that it's best practice to always specify the var input for all functions that take it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 11월 30일
The inverse function is not well defined for all the possible a.
For example a=1, there is no reverse function.
If a is an odd number, then there are two, positive and negative ones.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by