Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Mathematics
General TopicsResearchOperations ResearchStatisticsMathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math
Math Software
MapleMathematicaMATLABScilabSASSPSS

Math Forum / Math Software / Mathematica / October 2008



Tip: Looking for answers? Try searching our database.

NDSolve and error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dodatki@poczta.fm - 04 Oct 2008 11:16 GMT
Hello!
Lately I wrote simple code in Mathematica

sol[p_] :=
 NDSolve[{Sqrt[
         1 + (y'[t])^2] == (x^(p - 1) + (y[x])^(p - 1)*y'[x])/(x^p +
               y[x]^p)^(1 - 1/p), y[1] == 6}, y, {x, 1, 4}]

but when I typed sol[2] the following kind of error was shown:

NDSolve::"ndnum": "Encountered non-numerical value for a derivative at
\
\!\(x\) == \!\(4.587812868332132`*^-296\)."

May I know what I'm doing wrong? Or how can I improve that code to
work correctly?
Thank you in advance
                                 John
Peter Pein - 06 Oct 2008 04:49 GMT
dodatki@poczta.fm schrieb:
> Hello!
> Lately I wrote simple code in Mathematica
[quoted text clipped - 14 lines]
> Thank you in advance
>                                   John

Hi John,

try to replace y'[t] in the call to Sqrt by y'[x], and you'll get an exact
solution for p=2:
In[3]:= DSolve[{Sqrt[Derivative[1][y][x]^2 + 1] ==
    (x^(p - 1) + y[x]^(p - 1)*Derivative[1][y][
        x])/(x^p + y[x]^p)^(1 - 1/p),
   y[1] == 6} /. p -> 2, y, x]
Out[3]= {{y -> Function[{x}, 6*x]}}

Peter
Jean-Marc Gulliet - 06 Oct 2008 05:16 GMT
> sol[p_] :=
>   NDSolve[{Sqrt[
>           1 + (y'[t])^2] == (x^(p - 1) + (y[x])^(p - 1)*y'[x])/(x^p +
=================^^^^^^
Must be y'[x] not of t.

>                 y[x]^p)^(1 - 1/p), y[1] == 6}, y, {x, 1, 4}]
>
[quoted text clipped - 3 lines]
> \
> \!\(x\) == \!\(4.587812868332132`*^-296\)."

In[1]:= sol[p_] :=
 NDSolve[{Sqrt[
     1 + (y'[x])^2] == (x^(p - 1) + (y[x])^(p - 1)*y'[x])/(x^p +
        y[x]^p)^(1 - 1/p), y[1] == 6}, y, {x, 1, 4}]

In[2]:= sol[2]

Out[2]= {{y->InterpolatingFunction[{{1.,4.}},<>]}}

In[3]:= Plot[y[x] /. %, {x, 1, 4}]

Regards,
-- Jean-Marc
Bob Hanlon - 06 Oct 2008 05:17 GMT
You typed y[t] rather than y[x]

Bob Hanlon

---- dodatki@poczta.fm wrote:

=============
Hello!
Lately I wrote simple code in Mathematica

sol[p_] :=
 NDSolve[{Sqrt[
         1 + (y'[t])^2] == (x^(p - 1) + (y[x])^(p - 1)*y'[x])/(x^p +
               y[x]^p)^(1 - 1/p), y[1] == 6}, y, {x, 1, 4}]

but when I typed sol[2] the following kind of error was shown:

NDSolve::"ndnum": "Encountered non-numerical value for a derivative at
\
\!\(x\) == \!\(4.587812868332132`*^-296\)."

May I know what I'm doing wrong? Or how can I improve that code to
work correctly?
Thank you in advance
                                 John

--

Bob Hanlon
M.G. Bartlett - 06 Oct 2008 09:31 GMT
On Oct 5, 12:16 am, doda...@poczta.fm wrote:
> Hello!
> Lately I wrote simple code in Mathematica
>
> sol[p_] :=
>   NDSolve[{Sqrt[
>           1 + (y'[t])^2] == (x^(p - 1) + (y[x])^(p - 1)*y'[=
x])/(x^p +
>                 y[x]^p)^(1 - 1/p), y[1] == 6}, y, {x,=
1, 4}]

> but when I typed sol[2] the following kind of error was shown:
>
[quoted text clipped - 6 lines]
> Thank you in advance
>                                   John

John,

I think your error results from the fact that you have defined y as
both a function of x and as a function of t (y[t] and y[x]).  I am not
certain if you meant for y to be a function of both (in which case you
need to specify it as such (y[x,t]) throughout the equation (and
specify which derivatives you are taking) or if the y[t] on the left
side of your differential equation should be a y[x] (leaving you with
a tractable ordinary differential equation).  Hope that helps,

Marshall
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.