0
$\begingroup$

Here is a function that calculates the probability of randomly landing on a Fibonacci number not greater than $n$:

f[n_Integer] := (Floor[Log[GoldenRatio, Sqrt[5] (n + (1/2))]] - 1)/n  

1-50

How can I extend/complete it to some differentiable function that agrees with the original values when given an "integer" input?

$\endgroup$
1
1
$\begingroup$

as b.gatessucks said, you can use Interpolation:

f[n_Integer] := (Floor[Log[GoldenRatio, Sqrt[5] (n + (1/2))]] - 1)/n
data = Table[{n, f[n]}, {n, 50}];
g = Interpolation[data];
p1 = Plot[g[x], {x, 1, 70}, AxesOrigin -> {0, 0}];
p2 = ListPlot[data, Mesh -> True, Filling -> Axis, 
     PlotStyle -> {Red, PointSize[0.015]}];

Show[p1, p2, Frame -> True]

Mathematica graphics

There are many other functions in M for this sort of thing as described here http://reference.wolfram.com/mathematica/tutorial/ApproximateFunctionsAndInterpolation.html

Now you can take the derivative of g[x] and also integrate it etc.. as any other function:

  D[g[x], x]

Mathematica graphics

  Integrate[g[x], {x, 1, 50}] // N
  (* 17.4376 *)
$\endgroup$

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.