Let's say, I have a function with a constant, e.g. $y(x)=x+c$, and a condition $y(0) = 5$.
I want to type in something like Solve[{y[x]=x+c, y[0] =5}, {c}]
and get the value of a constant. Is there a way to do it in Mathematica or Wolfram Alpha?
3 Answers
You can define your function, to use your example:
y[x_] := x + c
and then simple solve it using the initial condition:
In[10]:= Solve[y[0] == 5, c]
Out[11]= {{c -> 5}}
The title of your question is a bit confusing, since this doesn't really have much to do with ODEs. :)
-
$\begingroup$ I was working with ODEs, but I totally agree with you, changed the title and the question $\endgroup$– ivtCommented Sep 16, 2014 at 19:03
you can enter y(0)=2 for example enter: y'+y=0,y(0)=2 i think this is solve your problem. this is for online mathmatica(www.wolframalpha.com)
-
$\begingroup$ It will use some kind of DSolve under the hood. I don't need to solve the ODE, I already have the general solution $\endgroup$– ivtCommented Sep 15, 2014 at 20:37
It is worth mentioning DSolve works similarly to Solve, and that NSolve will give you a numerical representation of a number rather than a symbolic. for example, say I want to find the roots of $x^{2} - 2 = 0$
Solve[x^2 - 2, x] == 0
will return $\sqrt{2}, -\sqrt{2}$, but NSolve will return
{{x -> -1.41421}, {x -> 1.41421}}
Also, I think DSolve uses Solve under the hood, not the other way around
y[_x,_c] = x + c
you can callSolve[ y[0,c] == 5, c]
to find the parameterc
. $\endgroup$