You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Connor Petty (JIRA)" <ji...@apache.org> on 2016/03/08 02:43:40 UTC

[jira] [Created] (MATH-1333) MullerSolver returns value that is out of bounds

Connor Petty created MATH-1333:
----------------------------------

             Summary: MullerSolver returns value that is out of bounds
                 Key: MATH-1333
                 URL: https://issues.apache.org/jira/browse/MATH-1333
             Project: Commons Math
          Issue Type: Bug
    Affects Versions: 3.6
            Reporter: Connor Petty
            Priority: Minor



package com.objectbrains.tms.service.dialer.predict;

import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.solvers.MullerSolver;
import org.apache.commons.math3.util.FastMath;

/**
 *
 * @author Connor Petty <cp...@users.sourceforge.net>
 */
public class BrokenMuller {

    public static void main(String[] args) {
        UnivariateFunction logFunction = new UnivariateFunction() {

            private double log1pe(double x) {
                if (x > 0) {
                    return x + FastMath.log1p(FastMath.exp(-x));
                } else {
                    return FastMath.log1p(FastMath.exp(x));
                }
            }

            @Override
            public double value(double x) {
                double a = 0.15076136473214652;
                double b = 4.880819340168248;
                double c = -2330.4196672490493;
                double d = 1.1871451743330544E-16;
                //aa*log(1+e^(bbx+c))+d - 0.01 * x - 20 * 0.01
                return a * a * log1pe(b * b * x + c) + d - 0.01 * x - 20 * 0.01;
            }

        };
        MullerSolver solver = new MullerSolver(0.25);
        double min = 20;
        double max = 100.04173804515072;
        double result = solver.solve(1000, logFunction, min, max, 100.0/3.0);

        if (result < min || result > max) {
            throw new RuntimeException("value [" + result + "] is out of bounds!");
        }
    }
}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)