Any feedback on this?

I am really curious if there is a misunderstanding from my side or if there
is a bug.

Thomas


On Tue, May 21, 2013 at 5:01 PM, Thomas Neidhart
<thomas.neidh...@gmail.com>wrote:

> Hi,
>
> based on the question on the user-ml, I did an experiment with the
> NewtonRaphson solver, and I get some strange results, see below:
>
>     @Test
>     public void testSquare() {
>
>         final UnivariateDifferentiableFunction d = new
> UnivariateDifferentiableFunction() {
>
>             public double value(double x) {
>                 return x*x;
>             }
>
>             public DerivativeStructure value(DerivativeStructure t)
>                 throws DimensionMismatchException {
>                 return t.multiply(t);
>             }
>         };
>
>         NewtonRaphsonSolver solver = new NewtonRaphsonSolver();
>         UnivariateDifferentiableFunction sin = new Sin();
>         double result = solver.solve(1000, sin, -4, 1);
>         System.out.println(result + " " + sin.value(result)); // prints
> 12.566370614359172 -4.898587196589413E-16
>                                                               // but there
> should be a root at -PI and 0
>
>         result = solver.solve(1000, d, -4, 1);
>         System.out.println(result + " " + d.value(result));   // prints
> -7.152557373046875E-7 5.115907697472721E-13
>
>         result = solver.solve(1000, d, -1, 1);
>         System.out.println(result + " " + d.value(result));   //
> TooManyEvaluationsException
>     }
>
> For the case of sin, I expected to get either -PI or 0 as root.
> For x^2, the result depends also on the bounds. Is there something wrong
> with my test, or is the solver broken?
>
> Thomas
>

Reply via email to