フィルターのクリア

Operator '==' is not supported for operands of type 'function_handle'

1 回表示 (過去 30 日間)
JacobsonRadical
JacobsonRadical 2022 年 4 月 24 日
編集済み: JacobsonRadical 2022 年 5 月 11 日
I want to find all the non-negative roots of the product of the following polynomials:
So, I did the following:
poly1 = @(x)x;
poly2 = @(x)x-1;
poly3 = @(x)x.^2-3*x+1;
poly4 = @(x)x.^4-7*x.^3+13*x.^2-7*x+1;
poly5 = @(x)x.^8-15*x.^7+83*x.^6-220*x.^5+303*x.^4-220*x.^3+83*x.^2-15*x+1;
poly6 = @(x)x.^3-5*x.^2+6*x-1;
poly7 = @(x)x.^3-6*x.^2+5*x-1;
poly8 = @(x)x.^4-7*x.^3+14*x.^2-8*x+1;
poly9 = @(x)x.^4-8*x.^3+14*x.^2-7*x+1;
polyproduct = @(x)poly1(x).*poly2(x).*poly3(x).*poly4(x).*poly5(x).* ...
poly6(x).*poly7(x).*poly8(x).*poly9(x);
eqn = polyproduct == 0
S = solve(eqn)
I understand that I can directly set up the equation without calling functions, but later I will do something else with those functions --- including plug in specific x, so I want to restore them first. (And I really don't want to restore each one in a seperate file..)
However, Matlab gives the following error:
>> Replication
Operator '==' is not supported for operands of type 'function_handle'.
Error in Replication (line 13)
eqn = polyproduct == 0
If I use the following code instead:
sym x
eqn = polyproduct(x) == 0
S = solve(eqn,x)
Then, it will give the following error:
Unrecognized function or variable 'x'.
Error in Replication (line 14)
eqn = polyproduct(x) == 0
I am not sure what to do instead. I am sorry if this question is dumb... Thank you so much!

採用された回答

JacobsonRadical
JacobsonRadical 2022 年 4 月 24 日
Ok I figured it out. My code had mistakes. To declare the variable x, I should use
syms x
However, my original code used
sym x
Hence, with all the things unchanged, to solve it (I use numercially solve here), the following code suffices:
syms x
eqn = polyproduct(x) == 0
vpasolve(eqn,x)
This indeed gave me the solution.
  4 件のコメント
JacobsonRadical
JacobsonRadical 2022 年 5 月 11 日
編集済み: JacobsonRadical 2022 年 5 月 11 日
I am that user. But I have been out of the field of probablity theory/stochastic analysis for a long time. I only studied it when I took a course for my master degree (well its a PhD course for PhD student, so I might not understand all of them, like those PhD students). I think that the problem here is the interpretation and definition of a stochastic process.
"In that sense, it is not possible to say "there are no decreasing sample paths" but rather that the probability of a sample path being in the set of decreasing functions is zero. "
I don't think that you are wrong. There is a way to define Possion process to require no decreasing sample path almost surely, which is exactly what you mean. Just like defining Wiener process (or Browninan motion), you can require the definition to be strict, or to be ture almost surely. It really depends on convention. And in this case, if I directly require that there are no decreasing sample path, then it covers your almost surely definition.
To your confusion about the definition of a stochastic process, here is what I used.
This does not say anything about the continuity, which is defined by using "trajectory".
So by saying a stochastic process being continuous, at least I am referring to the trajectory (the path) is continuous in the time t, for each fixed omega.
I am not sure if this answers your question.
JacobsonRadical
JacobsonRadical 2022 年 5 月 11 日
編集済み: JacobsonRadical 2022 年 5 月 11 日
I never consider a stochastic process as a measure. It is a collection measurable functions "indexed" by the time t. This definition indeed has problem of the existence of a stochastic process, because you can for sure require some family of random variables to satisfy anything you want but then there may not exist a probability distribution for this process. To thie end, you need to check by checking the consistency of all the family of finite distribution of this process and using the Daniell-Kolmogorov Consistency Theorem.
I am not sure what definition you are using. But you view any process as a measure, which is a better way --- by specifying the measure/distribution, you are sure that you have such a process.
I pointed out in that MSE post that, the definition you are referring to, is not the one I prefer, because you never know such a process could ever exist, and simply defining a process by giving some properties that one likes to have should not be the correct way to do so --- one must specifcy the measure/the distribution (as what I wrote in the definition I preferred) --- or one needs to prove that such a process exists.
One should always firstly have a distribution and then to have a concrete description of the process.
I am again not sure if this is why you are confusing.

サインインしてコメントする。

その他の回答 (1 件)

Torsten
Torsten 2022 年 4 月 24 日
Determine the roots of each polynomial separately using "roots".
The roots of the product will be the union of the roots of the single polynomials.
  4 件のコメント
John D'Errico
John D'Errico 2022 年 4 月 24 日
編集済み: John D'Errico 2022 年 4 月 24 日
You DON'T WANT TO SOLVE THE PRODUCT POLYNOMIAL. Doing so creates a massively high order problem when there is no need to do so. And in turn, that means you will have problems resolving the roots. It means you will have numerical problems working wih that very high order polynomial. You will never be able to do anything meaningful with the product polynomial in double precisoin arithmetic.
Since the roots of each individul polynomial are well defined, all you need to do is then sort them. Seriously, that is a problem?
JacobsonRadical
JacobsonRadical 2022 年 4 月 24 日
I am not really an expert of the computer arithmetic. The point for me is to have numercial solution. So the first idea for me is to simply numerically solve the product I defined. It has an advantage for me, in the way that the solution is given from the lowest value to the highest value. Then, I don't need to sort.
To use the "roots" command, I need to compute the roots of each polynomial, and then I need to put them into one set and I sort them. I am not sure if this is more complicated than what I originally wanted. And as I have figured out, the product can be numercially solved.
"You will never be able to do anything meaningful with the product polynomial in double precisoin arithmetic." I believe that there must be something of computaional science going on behind your recommendation, and I am sorry for not knowing these notions.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by