[ 
https://issues.apache.org/jira/browse/MATH-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Connor Petty updated MATH-1333:
-------------------------------
    Description: 
package whatever;

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 <[email protected]>
 */
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!");
        }
    }
}


  was:

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 <[email protected]>
 */
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!");
        }
    }
}



> 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 whatever;
> 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 <[email protected]>
>  */
> 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)

Reply via email to