1
$\begingroup$

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?

$\endgroup$
7
  • $\begingroup$ Do you mean $y \color{red}{'}(x)=x+c$ (otherwise it's not a DE)? $\endgroup$
    – alexqwx
    Sep 15, 2014 at 20:34
  • $\begingroup$ Yeah, I might need y' as well, e.g. [{y[x] = some function, y[0] = a, y'[x] = b}, {c1, c2}] $\endgroup$
    – ivt
    Sep 15, 2014 at 20:34
  • $\begingroup$ Ok, I'm very spooked. How did it take you 1 second to reply to my comment? $\endgroup$
    – alexqwx
    Sep 15, 2014 at 20:35
  • 1
    $\begingroup$ There is definitely a way to do that, I had a hw assignment last spring where I had to do exactly this. I won't be home for a few hours, but once I get home I can send you the Syntax to calculate something like this. (If nobody else has answered the question before then) $\endgroup$
    – graydad
    Sep 15, 2014 at 21:25
  • 2
    $\begingroup$ I think if you define the function y[_x,_c] = x + c you can call Solve[ y[0,c] == 5, c] to find the parameter c. $\endgroup$ Sep 16, 2014 at 15:37

3 Answers 3

3
$\begingroup$

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. :)

$\endgroup$
1
  • $\begingroup$ I was working with ODEs, but I totally agree with you, changed the title and the question $\endgroup$
    – ivt
    Sep 16, 2014 at 19:03
1
$\begingroup$

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)

$\endgroup$
1
  • $\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$
    – ivt
    Sep 15, 2014 at 20:37
1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.