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
>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?
Look at the left hand side of differential equation you posted.
It says something about the derivative evaluated at t. But the
right hand side is evaluated at x. Change the t on the left hand
side to x and things should work.
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
> 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}]
>
> 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\)."
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
---- dod...@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
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