# Directly Obtain Solution Expressions for ODEs

Directly obtain an expression for the solution of an ODE using DSolveValue.

 In[1]:= Xsol = DSolveValue[{Derivative[1][y][x] + y[x] == a Sin[x], y[0] == 0}, y[x], x]
 Out[1]=

Plot the solution.

 In[2]:= XPlot[Evaluate[Table[sol, {a, 7}]], {x, 0, 4 \[Pi]}]
 Out[2]=

Compute the derivative of the solution for an ODE.

 In[3]:= XDSolveValue[{(y^\[Prime]\[Prime])[x] + y[x] == 0, y[0] == 0, Derivative[1][y][0] == 1}, Derivative[1][y][x], x]
 Out[3]=

Solve for arbitrary expressions involving the dependent variables.

 In[4]:= XDSolveValue[{Derivative[1][y][x] == x y[x], Derivative[1][z][x] == 5 z[x], y[0] == 3, z[0] == 5}, y[x], x]
 Out[4]=
 In[5]:= XDSolveValue[{Derivative[1][y][x] == x y[x], Derivative[1][z][x] == 5 z[x], y[0] == 3, z[0] == 5}, y[x] + z[1], x]
 Out[5]=
 In[6]:= XDSolveValue[{Derivative[1][y][x] == x y[x], Derivative[1][z][x] == 5 z[x], y[0] == 3, z[0] == 5}, \!\( \*SubsuperscriptBox[\(\[Integral]\), \(0\), \(7\)]\(\(( \*SuperscriptBox[\(y[x]\), \(2\)] + 3\ z[x])\) \[DifferentialD]x\)\), x]
 Out[6]=

Obtain a pure function solution for a nonlinear second-order ODE.

 In[7]:= Xeqn = {(y^\[Prime]\[Prime])[x] == 4 Derivative[1][y][x] + 1/Derivative[1][y][x]^2, y[1] == 3, Derivative[1][y][1] == 1};
 In[8]:= Xsol = DSolveValue[eqn, y, x]
 Out[8]=

Verify the solution.

 In[9]:= Xeqn /. {y -> sol} // FullSimplify
 Out[9]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »