Category Archives: biginteger

Apache Math to solve for all numberical combinations [on hold]

I was looking for the best way to use the apache math library to solve for all possible unique combination of formula like x1*10^0+x2*10^1+x3*10^2+x4*10^3+x5*10^4+x6*10^6+x7*10^7=3729463 but using big integers so the equation can scales out to very large numbers. The solution set should also be limited to non negative integers

class MyFunction implements UnivariateFunction {
    public double value(double x) {
        double y = hugeFormula(x);
        if (y==0) {
            throw new LocalException(x);
        }
        return y;
    }

    public void compute() {
        try {
            solve(maxEval, new MyFunction(a, b, c), min, max);
        } catch (LocalException le)  {
            // retrieve the x value
        }
    }
}