| Thread Closed |
Numerical solution in Mathematica |
Share Thread | Thread Tools |
| Sep22-10, 06:30 AM | #1 |
|
|
Numerical solution in Mathematica
Hello,
I have a problem with numerical solution of the system of ODE's (geodesic eqs.) in Mathematica. The only relevant command I have found is NDSolve. It works perfectly, unless my equations contain functions which are again computed using numerical methods. Simple example illustrating the problem. Let's define function F[x_] := Module[{}, FindRoot[ x y == 1, {y, 1/x} ][[1,2]] ]; I don't want to write F[x_] = 1/x, because I want Mathematica to compute it numerically. This function gives, of course, correct values, e.g. F[2]=0.5. Now I want to solve equation y' = F with initial condition y(1)=0 using sol = NDSolve[ {y'[x]== F[x], y[1]==0}, y, {x, 1, 3} ]; If I define F[x_] = 1/x, it works. If I define it by FindRoot, it doesn't. It seems to me that NDSolve tries to work with F[x] in symbolic form, but then FindRoot says, that 1/x is not a number. I hope that I described the problem clearly. Please, if anybody knows the solution, tell me, I am getting crazy :) Thank you |
| Sep22-10, 11:58 AM | #2 |
|
|
The main problem is that, Mathematica tries to solve your problem analytically first. So it plugs in symbolic x, and your function can't handle it.
Please refer to this question in Voofie/Mathematics: NDSolve in Mathematica with numerical function For ways to solve your problem. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Numerical solution in Mathematica
|
||||
| Thread | Forum | Replies | ||
| Mathematica:Having problem with my calculation(numerical) | Math & Science Software | 2 | ||
| mathematica:How to solve the summation of numerical integration | Math & Science Software | 2 | ||
| Mathematica:Please help me to solve numerical integration | Math & Science Software | 1 | ||
| MATHEMATICA[solve numerical integration and find min value] | Math & Science Software | 3 | ||
| Numerical Derivatives in Mathematica | Math & Science Software | 6 | ||