1
$\begingroup$

How can I build a function using Wolfram Alpha that passes through these 4 points?

{0, 100}, {1, 30}, {7, 6}, {28, 3}

The result I am seeking is a curve with the shape shown in the image. I don't need much precision - just the shape and those 4 points to be on the curve.

enter image description here

$\endgroup$
8
  • $\begingroup$ In my experience the clearest way to communicate with Wolfram Alpha is often to feed it Mathematica syntax: IMO FindFit[{{0,100},{1,30},{7,6},{28,3}}, {a*(x+c)^b, a>0, b<0, c>0}, {a,b,c}, x] gives a good looking fit. $\endgroup$
    – eyorble
    Aug 18 at 18:43
  • 1
    $\begingroup$ @eyorble thanks it is really good, but not good enough. E.g. x = 28, this model gets me 1.98 not exact 3 :( $\endgroup$
    – Narek
    Aug 18 at 18:48
  • 1
    $\begingroup$ WolframAlpha["exponential fit through {0, 100}, {1, 30}, {7, 6}, {28, 3}"] $\endgroup$
    – Jason B.
    Aug 18 at 18:54
  • 4
    $\begingroup$ I’m voting to close this question because this question is about W|A, not how to use Mathematica. $\endgroup$
    – Michael E2
    Aug 18 at 19:32
  • 1
    $\begingroup$ To potential answerers, the question is tagged interpolation and state the curve "passes through these 4 points." It does not seem to be about fitting an exponential model, only that the interpolating curve will end up looking somewhat like an exponential. $\endgroup$
    – Michael E2
    Aug 18 at 19:34

2 Answers 2

3
$\begingroup$
NonlinearModelFit[{{0, 100}, {1, 30}, {7, 6}, {28, 3}},   a Exp[-b x] + c, {a, b, c}, x]

Gives 4.4939 + 95.5052 E^(-1.32011 x)
With Residuals: {0.000871158, -0.00380506, 1.49683, -1.4939} enter image description here

If you are ok with a linear adjustment to the exponential, you can get a near perfect fit with:

NonlinearModelFit[{{0, 100}, {1, 30}, {7, 6}, {28, 3}}, 
 a Exp[-b  x] + c + d x, {{a, 100}, b, {c, 3}, d}, x]

(Note reasonable starting guesses for a and c.)

Which gives: 6.99266 + 93.0073 E^(-1.39069 x) - 0.142595 x
With residuals: {5.96145*10^-11, -1.69038*10^-11, -8.5266*10^-11, -1.01638*10^-10}

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ a Exp[-b (x - x0)] + c is equivalent to a2 Exp[-b x] + c since a Exp[b*x0] is a constant. $\endgroup$
    – Bob Hanlon
    Aug 18 at 19:33
  • $\begingroup$ @BobHanlon oh right, thanks. For some reason when I tries that originally it wasn't giving a good fit without an initial guess. Will fix in above. $\endgroup$ Aug 18 at 19:39
2
$\begingroup$

With Mathematica you would proceed as described below. I assume that you can do the same with Wolfram Alpha.

You may try "NonLinearModelFit" with the option: "Model->"Newton"" or "Model->"NMinimize"":

d = {{0, 100}, {1, 30}, {7, 6}, {28, 3}};
model = c0 + c1 Exp[c2 (x - c3)];
res = NonlinearModelFit[d, model, {c0, c1, c2, c3}, x, Method -> "Newton"]
Plot[res[x], {x, 0, 28}, Epilog -> Point[d], PlotRange -> All]

enter image description here

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ c0 + c1 Exp[c2 (x - c3)] is equivalent to c0 + c4 Exp[c2 x] since c1 Exp[-c2 c3] is a constant. $\endgroup$
    – Bob Hanlon
    Aug 18 at 19:37
  • $\begingroup$ Right, thanks for the hint. I simplified the model. $\endgroup$ Aug 18 at 19:43

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