Find integer root in a given range of an equation

3 visualizaciones (últimos 30 días)
Khanh
Khanh el 21 de Nov. de 2011
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 comentario
Khanh
Khanh el 21 de Nov. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 21 de Nov. de 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.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by