Fitting solution function of NDSolve with a curve

In summary, the conversation is about solving an IVP and finding a curve fit for the function f3[x] over the domain t∈[0,1]. The solution is found using the Wolfram Language function FindFit, which gives the output of 0.96556t^0.573358. The conversation also includes the method used to obtain the values for a and b in the curve fit, which involves using the function Table and using the output of FindFit as a(100t)^b.
  • #1
member 428835
The following solves an IVP, giving the output as the function f3[x]:

Code:
s3 = NDSolve[{(-z1[t]^(3/2) + (1 + z1[t]^2)^(3/4))/(
    3 (-z1[t] + Sqrt[1 + z1[t]^2])) == z1[t] z1'[t], z1[0] == 0.0001},
   z1, {t, 0, 30}

f3[x_] := z1[x] /. First[s3];
My question is, how do I curve fit f3[x] to the function ##at^b## over domain ##t\in[0,1]##? Looks like ##t^{0.6}## does a good job (by eye) but is there a better way?
 
Physics news on Phys.org
  • #2
Nevermind, the solution is here: https://reference.wolfram.com/language/ref/FindFit.html which gives: ## 0.96556 t^{0.573358}##

FYI for future people I used

Code:
Table[f3[x], {x, 0, 1, 0.01}];
FindFit[%, a x^b, {a, b}, x]
and then used the ##a,b## output as ##a(100t)^b## where I used 100 since I incremented by 0.01, or 1/100.
 

1. How do I fit a solution function of NDSolve with a curve?

To fit a solution function of NDSolve with a curve, you will need to use the FindFit function in Mathematica. This function takes in the solution function, the curve you want to fit it with, and any parameters that need to be adjusted. It then uses an iterative process to find the best fit for the parameters.

2. Can I fit a solution function of NDSolve with multiple curves?

Yes, you can fit a solution function of NDSolve with multiple curves by using the FindFit function with a list of curves instead of just one. You will also need to specify the corresponding parameters for each curve in the list.

3. What if my solution function of NDSolve has multiple variables?

If your solution function has multiple variables, you will need to use the ParametricNDSolve function instead of NDSolve. This will allow you to specify the variables and their corresponding initial conditions, as well as any parameters that need to be adjusted during the fitting process.

4. Can I visualize the fit of my solution function with the curve?

Yes, you can visualize the fit of your solution function with the curve by using the Plot function in Mathematica. Simply plot both the solution function and the curve on the same graph and the fit will be visually apparent.

5. How do I evaluate the accuracy of the fit for my solution function?

To evaluate the accuracy of the fit for your solution function, you can use the NonlinearModelFit function in Mathematica. This function will return a statistical report that includes the root-mean-square error and the coefficient of determination, among other measures, to assess the quality of the fit.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
696
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top