1
$\begingroup$

I want to plot the graph in this picture, but I don't know formula of the function. I tried

 f[x_] := a x^9 + b x^8 + c x^7 + d x^6 + e x^5 + n x^4 + g x^3 + 
   h x^2 + k x + l ;
NSolve[{f[-2] == -2, f[2] == 2, f[4] == 4, f[0] == 6, f[1.5] == 3, 
  f'[0] == 0, f'[2.5] == 0, f'[1.5] == 0, f[2.5] == 1.5, 
  f'[1.2] == 0}, {a, b, c, d, e, n, g, h, k, l}, Reals]

I got

{{a -> 0.23626, b -> -2.61292, c -> 9.81292, d -> -9.83145, e -> -26.1737, n -> 76.7269, g -> -67.1827, h -> 16.1222, k -> 0., l -> 6.}}

But the result don't exactly.

How can I find formula of the function of this graph?

enter image description here

$\endgroup$
6
$\begingroup$

We can extract the data from the picture ,then use the "FindFormula" to find formula of the function.(It is difficult to extract data directly through image processing, so I erased interference in the picture firstly) .

enter image description here

imgdat = Sort[ImageValuePositions[Thinning@ColorNegate@Binarize[IMG], 1]];
dat = ({Rescale[#1, MinMax[imgdat[[;; , 1]]], {-2.1, 4.4}], Rescale[#2, MinMax[imgdat[[;; , 2]]], {-2.7, 6.4}]} & @@@ imgdat);
fits = FindFormula[dat, x, 1, "Score" ]
Show[ListPlot[dat], 
 Plot[First@fits, {x, -2.1, 4.4}, PlotRange -> All, 
  PlotStyle -> Directive[Red, Thick]], AspectRatio -> 1]

enter image description here

maybe help.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Another approach is used here mapleprimes.com/questions/… . $\endgroup$ – user64494 Sep 9 '17 at 18:27
  • $\begingroup$ @jiaoeyuhushu Where can I put my picture? $\endgroup$ – minhthien_2016 Sep 10 '17 at 7:38
  • $\begingroup$ If my picture has name is pic.PNG, how to put it in your code? $\endgroup$ – minhthien_2016 Sep 10 '17 at 8:36
  • $\begingroup$ @toandhsp RemoveAlphaChannel[pic.PNG] or Save as pic.JPG $\endgroup$ – jiaoeyushushu Sep 10 '17 at 9:41
  • $\begingroup$ How I input pic.JPG? Where the command contain pic.JPG? $\endgroup$ – minhthien_2016 Sep 10 '17 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.