Clear[“Global`*”]
eq = f’ == 1/x
s = DSolve[eq, f, x]
Print[Evaluate[s[1]]]
Evaluate[eq[1]]
How to evaluate a function at 1? The code does not produce a number.
Clear[“Global`*”]
eq = f’ == 1/x
s = DSolve[eq, f, x]
Print[Evaluate[s[1]]]
Evaluate[eq[1]]
How to evaluate a function at 1? The code does not produce a number.
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:
because 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
Isn’t this simply
In[4]:= DSolve[f'[x] == 1/x, f[x], x] /. x -> 1
Out[4]= {{f[1] -> C[1]}}
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