getdata and curve fitting from a graph in maple

90 Views Asked by At

I plot a parametric curve from the functions $$f(r):=-(1/2)*(r^3-1)/r^2,$$ $$ g(r):=-(1/6)*(-r^3-9)/r^2$$ $$plot([ f(r),g(r) , r=0.1..1]);$$ in maple. I am looking for the best curve fitting function of the $f$-$g$ graph. How can I accomplish it in maple? I hope to have a function like $f= a*g^2 + b*g + c $ after the curve fitting.

1

There are 1 best solutions below

2
On

This answer concerns only the fitting part of the question, what ever the software to draw it.

Parametric equation : $\quad\begin{cases} x=g(r)=\frac{9+r^3}{6\:r^2}\\ y=f(r)=\frac{1-r^3}{2\:r^2} \end{cases}$

Fitting with an equation on the form : $$f(g)\simeq F(g)=a\:g^2+b\:g+c$$ with the mean square deviation method.

Considering the local square deviation $\quad\epsilon(r)^2=(F(g)-f(g))^2$ $$\epsilon(r)^2=\left( a\left(\frac{9+r^3}{6\:r^2}\right)^2 + b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2} \right)^2$$ On the specified range $0.1\leq r\leq 1$ , the cumulative square deviation is : $$\int_{0.1}^{1}\epsilon(r)^2 dr=\int_{0.1}^{1} \left( a\left(\frac{9+r^3}{6\:r^2}\right)^2 + b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2} \right)^2 dr$$ The minimum of deviation is achieved when the derivatives with respect to $a$ , $b$ and $c$ are nul :

$$\begin{cases} \int_{0.1}^{1} \left( a\left(\frac{9+r^3}{6\:r^2}\right)^2 + b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2}\right) \left(\frac{9+r^3}{6\:r^2}\right)^2 dr=0 \\ \int_{0.1}^{1} \left( a\left(\frac{9+r^3}{6\:r^2}\right)^2 + b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2}\right) \left(\frac{9+r^3}{6\:r^2}\right) dr=0 \\ \int_{0.1}^{1} \left( a\left(\frac{9+r^3}{6\:r^2}\right)^2 + b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2}\right) dr=0 \end{cases}$$ We have to solve this linear system for $a$ , $b$ and $c$.

enter image description here

The result is : $\quad \begin{cases} a\simeq -0.000 073 239 09 \\ b\simeq 0.344 918 \\ c\simeq -0.419 327 \end{cases}$

The graphical representation shows that the deviation is larger when $r$ is close to $1$ (i.e. for small $f$ and $g$).

The parametric curve is drawn in black. The fitted curve $f(g)=ag^2+bg+c$ is drawn in red.

enter image description here

All above is valid on the specified range. The full drawing of the parametric curve is :

enter image description here

IN ADDITION, CASE $a=0$ : FITTIG OF THE FUNCTION $f(g)\simeq F(g)=b\,g+c$

The method is the same as above, but simpler. No need to repeat the theory. $$\begin{cases} \int_{0.1}^{1} \left( b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2}\right) \left(\frac{9+r^3}{6\:r^2}\right) dr=0 \\ \int_{0.1}^{1} \left( b\left(\frac{9+r^3}{6\:r^2}\right)+c-\frac{1-r^3}{2\:r^2}\right) dr=0 \end{cases}$$ We have to solve this linear system for $b$ and $c$.

enter image description here

The result is : $\quad \begin{cases} b\simeq 0.337 368 \\ c\simeq -0.366 444 \end{cases}$

The graphical representation below shows that the deviation is larger than above. This is not surprising since only two parameters $b,c$ are optimized instead of three $a,b,c$ before.

enter image description here