Message Boards Message Boards

Solve simple differential equation?

Posted 9 years ago

hi i can not manage to understand what blocks here :

a = DSolve[{y'[x] == x*Log[x], y[1] == 1}, y[x], x];
a[[1]]
g[x_] = y[x] /. a[[1]]
g[1]
Plot[g[x], {x, 0.1, 1}]

it is the same if i replace a[[1]] with a[[1]][[1]]

1) why is it nor accepted as e diff equa ?

2) what is a ? a list of list ???

i found this on a web site ; why does this code works and not mine ?

solution = DSolve[y'[x] == x, y[x], x]

f[x_] = y[x] /. solution[[1]]
POSTED BY: Adrien Guyader

In[2]:= DSolve[{y'[x] == x*Log[x], y[1] == 1}, y[x], x] Out[2]= {{y[x] -> 1/4 (5 - x^2 + 2 x^2 Log[x])}}

In[3]:= Dimensions[%]
Out[3]= {1, 1}

and that works

In[5]:= Clear[a]
a = DSolve[{y'[x] == x*Log[x], y[1] == 1}, y[x], x];

In[7]:= a[[1]] 
Out[7]= {y[x] -> 1/4 (5 - x^2 + 2 x^2 Log[x])}

In[11]:= g[q_] := (y[x] /. a[[1]]) //. x -> q

In[12]:= g[1]
Out[12]= 1

enter image description here

Observe the SetDelayed in the definition of g and how the variable q enters after the replacement.

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract