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

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!

 Accepted Answer

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 Comments

Hi jacobsonradical, I tried to contact you to ask a question about one of your stackexchange answers, but I was not allowed to create an account and make a comment without having gained reputation points. I am trying to understand your post where you construct a right continuous modification of a Poisson process, and I am stuck at the very beginning, you write
(1) X0=0X0=0 almost surely;
(2) The paths of XtXt are right continuous with left limits;
(3) If s<ts<t, then XtXsXtXs is a Poisson random variable with parameter λ(ts)λ(ts);
(4) If s<ts<t, then XtXsXtXs is independent of σ(Su,us),σ(Su,us), that is, all increments are independent.
If I interpret a Stochastic process as a measure on the space of functions [0,\infty ) -> N (with (0,\inffty] given the discrete topology, i.e. the measure space is the cartesian product of one copy of N for each real number) then this is equivalent to specifying the probability that a sample path passes between any fintite set of 'error bars.'
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.
So if I am to interpret (2) as a condition on the joint probabilities among the random variables X_t for t belonging to all possible finite sets {t_1,...,t_n } then I have to say something like, for fixed t_1 the limit as t_2 approaches t_1 from above of P( x_{t_1} >2 & X_{t_2} >5) is zero.
However, the probability of a jump occurring at exactly t_1 is zero so this limit seems to be zero regardless of whether I think of X_t as representing the number of geiger-counter clicks in the time interval (0,t) versus (0,t].
I cannot seem to find any change in any of the joint probabilities --- i.e. the measures of cylinder sets -- between the cases when I think of having right continuous sample paths versus left continuous sample paths. They seem to be describing exactly the same Stohastic process, in the sense that a Stochastic process was defined in these notes as being an N valued random variable X_t for each positive real t together with a specification of all joint probabilities for finite sets of the X_t.
I think possibly the issue is that there is a second definition of what a Stochastic process is which differsf rom saying it is a measure on the space of functions R-> N.
I have put hte question on /r/math and it was deleted by mods who said it should go on /r/learnmath and it is there at this link Need help with probability : learnmath (reddit.com)
Mayber you could comment there?
This is really frustrating as no-one seems to be able to give me the correct definition of what a Stochastic process is where it makes sense to say it has right continuous sample paths.
If you are not the same as the stack-exchange jacobsonradical you can ignore this message.
(
there are various typos such as, I meant to write
I have to say something like, for fixed t_1 the limit as t_2 approaches t_1 from above of P( x_{t_1} <2 & X_{t_2} >5) is zero.
)
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.
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.

Sign in to comment.

More Answers (1)

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 Comments

The thing is that I also want to compute the midpoint between two consecutive zeros of the product, so if I do them seperately, I need to sort them after this. Is there anyway to directly solve the product?
"sort" sorts the roots.
Why make things more complicated than they are ?
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?
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.

Sign in to comment.

Categories

Products

Release

R2022a

Community Treasure Hunt

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

Start Hunting!