0
|
33086 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# How to evaluate a function at a point?

Posted 9 years ago
 Clear["Global*"] eq[x] = f'[x] == 1/x s[x] = DSolve[eq[x], f[x], x] Print[Evaluate[s[1]]] Evaluate[eq[1]]  How to evaluate a function at 1? The code does not produce a number.
3 Replies
Sort By:
Posted 9 years ago
 Isn't this simply In[4]:= DSolve[f'[x] == 1/x, f[x], x] /. x -> 1 Out[4]= {{f[1] -> C[1]}} 
Posted 9 years ago
 Is that not quite what I said, apart from my adding boundary conditions? I made up the boundary conditions so that Steve would get a number as he required.Best wishes,Marco
Posted 9 years ago
 Hi Steve,there are a couple of things here. You might want to look at the examples given in the documentation for DSolve. The documentation is excellent and you would get your questions answered. Second, you might want to read:http://community.wolfram.com/groups/-/m/t/270507because it shows how to format code in your posts. It is much easier to answer your questions if you format the code appropriately. Now, having said that, here is a piece of code that solves the ODE  Clear["Global*"] ; sol = DSolve[f'[x] == 1/x , f[x], x] ; f[x] /. sol (*{C[1] + Log[x]}*) It would be easy to substitute a value for x now, but you still have the constant $C[1]$ because you have not provided initial conditions yet. This code fixes that: Clear["Global*"] ; sol = DSolve[{f'[x] == 1/x , f[1] == 1}, f[x], x] ; f[x] /. sol Then you can simply use: N[f[x] /. sol /. x -> 4] `to get a numerical solution at $x=4$.Cheers,Marco