Find integer root in a given range of an equation

2 ビュー (過去 30 日間)
Khanh
Khanh 2011 年 11 月 21 日
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 Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by