1
$\begingroup$

I am trying to plot the values of the functions f[x] and der[x], but I am getting an empty plot. I am new to both Mathematica and simulation. Can anyone please help me.

Manipulate[
  fu[alfa], 
  {{alfa, 1, "α"}, 0, 1, 0.001, Appearance ->"Labeled"},
  Initialization :> (
    fu[alfa_] := 
      Module[{α, f, der},
        α = alfa;
        f[x_] = Exp[x];
        der[x_] = Sum[((t)^(k) x^(-α))/Gamma[k + 1 - α], {k, 0, ∞}];  
        Plot[{f[x],der[x]}, {x, 1, 1.5},
          AxesLabel -> 
            {Style["x", Italic],
             Row[{Style["f", Italic], "(", Style["x", Italic], ")"}]}, 
          ImageSize -> {300, 200}, 
          ImagePadding -> {{35, 20}, {20, 20}}, 
          PlotStyle -> Thick]])]
$\endgroup$
  • 1
    $\begingroup$ This code cannot be copied into a notebook in its current state because of syntax errors. For example, [Alpha] is not a valid symbol name. $\endgroup$ – Sjoerd Smit Jun 24 at 8:20
  • $\begingroup$ what is the value of t in Sum[((t)^{k)...]? $\endgroup$ – kglr Jun 24 at 8:36
  • 2
    $\begingroup$ When ever you can't get a complicated piece of code to work, a good strategy is to start first with something that does work, a simple plot, then add one component to it, get it working, then add another and slowly build it back up until you add a piece that causes it to fail then focus your attention on getting that single piece to work. $\endgroup$ – Dominic Jun 24 at 10:25
2
$\begingroup$

There are quite a few programming errors in your code. Probably the most deadly one is not taking into account that der depends on three parameters, x, alfa and t.

Here is a rewrite of your code that produced a plot that can be manipulated. Note, because the evaluation of der is time consuming, response to moving the sliders is rather sluggish.

Clear[f, der]
f[x_] := Exp[x]
der[x_, α_, t_] :=  Sum[t^(k) x^(-α)/Gamma[k + 1 - α], {k, 0, ∞}]

Manipulate[
  Plot[{f[x], der[x, alfa, t]}, {x, 1, 1.5},
    PlotRange -> {0, 5},
    PlotStyle -> Thick,
    AxesLabel ->
      {Style["x", Italic], 
       Row[{Style["f", Italic], "(", Style["x", Italic], ")"}]}, 
    ImageSize -> {300, 200},
    ImagePadding -> {{35, 20}, {20, 20}}],
  {{alfa, 1, "α"}, 0, 1, 0.01, Appearance -> "Labeled"},
  {{t, .2}, 0, 1, 0.01, Appearance -> "Labeled"}]

demo

$\endgroup$
  • $\begingroup$ Thank you for your comments $\endgroup$ – vicky Jun 26 at 7:22

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.