Find integer root in a given range of an equation

2 次查看(过去 30 天)
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 个评论
Khanh
Khanh 2011-11-21
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?

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2011-11-21
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.

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by