Impact factor for posts is a measurement of importance.

Impact factor for users reflect their authority, reputation and contribution on a particular topic.

Rating reflects the quality of posts.

Rating on Voofie is not a simple average of all ratings, but a weighted average of rating, weighted by the impact factor of users who rated.

Explore exciting communities of

NDSolve in Mathematica with numerical function

Bookmark and Share
Avatar for sciencolic

Sciencolic (sciencolic)

I love Physics, Mathematics and Science.
Japan

  • Mathematica
  • 0
    23 Sep 10

    The problem that I am having is like this(a forward of this post). If I define a numerical function in Mathematica:

    F[x_] := Module[{}, FindRoot[ x y == 1, {y, 1/x} ][[1,2]] ];

    As you can see that F(x) is just 1/x. However, I just would like to illustrate the point with a simple example.

    If I solve a differential equation numerically involving F(x), I would get errors:

    sol = NDSolve[{y'[x] == F[x], y[1] == 0}, y[x], {x, 1, 3}];

    Errors:

    FindRoot::srect: Value 1/x in search specification {y,1/x} is not a number or array of numbers. >>

    NDSolve::deqn: Equation or list of equations expected instead of False in the first argument {InterpolatingFunction[{{1.,3.}},<<3>>,{Automatic}][x]==1,False}. >>

    What should I do?

    Add comments >
    0
    Avatar for ross_tang

    Ross Tang (ross_tang)

    Degree in Physics and Mathematics, Master in Physics
    香港

  • Mathematica
  • 72
    23 Sep 10

    The main reason you are having this error is that, Mathematica tries to solve your equation analytically first. Therefore, it would use symbolic form x for your function, but your function can't handle it. So it is the error. You may try to define your F(x) so that it would only compute if x is a number:

    F[x_ /; NumberQ[x]] := Module[{}, FindRoot[x y == 1, {y, 1/x}][[1, 2]]];

    With this, I can solve the differential equation using NDSolve without any errors. Hope it can help you.

    Add comments >

    Please login to post answer.

    Page Info
    22Impacts
    0/0 rates
    1314
    Your Rating: