Value of Integer cannot be converted to Double() error


  • Hello, Everyone.

    I am trying to build my first solution on Visual Studio 2017, and one problem has arisen.

    The aim of the solution is to solve a simple equation (x^2-3*x+2=0) and to do it, I have installed a Nuget package (Math.NET Numerics). I have decided to solve it with the Broyden method, which requires an initial guess of the root (in this case is 2), and the solution is as follows.

    Dim root As Double

    Dim g As Func(Of Double, Double) = Function(x) x ^ 2 - 3 * x + 2

    root = MathNet.Numerics.RootFinding.Broyden.FindRoot(g, 2)

    The problem is that the following message pops up referring to the arguments of "FindRoot()", either because of the way the function is declared(g) or the nature of the 2(integer).

    Message for g: "Func(of Double, Double) cannot be converted to Func(of Double(), Double())"

    Message for 2:"Value of Integer cannot be converted to Double()"

    I do not know what to do. Help.

    Thanks in advance.

    Wednesday, April 12, 2017 2:24 AM

All replies

  • Message for 2:"Value of Integer cannot be converted to Double()"

    Your FindRoot function is expecting a pair of arrays of double.  You are providing a pair of doubles.  You need to provide g and '2' as arrays of doubles.

    Wednesday, April 12, 2017 4:39 AM
  • Hi Walter,

    According to the screenshot below, you could need to know Dim g As Func(Of Double(), Double()) replace Dim g As Func(Of Double, Double), and then g is a Array, it is not equal Function(x) x ^ 2 - 3 * x + 2. Secondly, MathNet.Numerics.RootFinding.Broyden.FindRoot() should return Double().

    Hope it is helpful to you.

    Best regards,

    Cherry Bu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, April 12, 2017 6:50 AM