Find integer root in a given range of an equation

2 views (last 30 days)
Given an equation $\sum_{i=1}^{n} C_{ij}*(x_i - k_i)^2 = R$ with C is a covariance n*n matrix of vector x; R and vector k is given.
It's obvious that there are infinite number of real roots for this equation.
However, I wonder if I'm only interesting in integer roots which are in the range between some value [a, b], then is there any function in Matlab that can find them?
I'm looking at fsolve function but I don't see anyway to specify the conditions that I need (i.e. integers in a certain range).
Does any one have any suggestion, please?
Thanks,
  1 Comment
Khanh
Khanh on 21 Nov 2011
I see the brute force solution would be checking all the possible solutions which is (b-a)^n which is all the possible integer vectors of vector x. However, I wonder if there is any better way to solve it?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 21 Nov 2011
Remap the search space to be between 1 and (1 + (b-a+)/2^53), and then the adjacent floating point numbers within that space would correspond exactly to integers over a to b.
I make no representation that this would be efficient.

Categories

Find more on Mathematics 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!