2

I have difficulty in making CloudDeploy in my desktop. Does anyone know why ? Thanks

Here is what I see:

enter image description here


Here is the code if someone would like to test

CloudDeploy[
 Manipulate[
  f[x] = Sin[x];
  Plot[f[k x], {x, 0, 10}], {k, 1, 10}]

 ]

Mathematica 11.0

Kuba
  • 136,707
  • 13
  • 279
  • 740
Joey
  • 21
  • 2

1 Answers1

1

Try to change the function definition.

CloudDeploy[
 Manipulate[
  f[x_] := Sin[x];
  Plot[f[k x], {x, 0, 10}], {k, 1, 10}]
 ]

Note that I am changing f[x]=Sin[x] to f[x_]:=Sin[x]. The key points here are:

  • x to x_ (the use of a Pattern, the main change here)
  • = to := (the use of SetDelayed, optional but I would suggest as a good habit for Mathematica newcomers).

I welcome more experienced users to clarify here, but I like to think Mathematica as a kind of term rewriting system. When I say f[x]=Sin[x] all that is said to Mathematica is "if you find literally f[x] change it to Sin[x] (it is creating a kind of DownValues - a good question regarding related concepts is here). Normally, a newcomer do not want this. You would expect to create something that would allow f[3] to be understood as Sin[3]. This is where Patterns come to rescue."

  • That's all true but how does this answer the problem about CloudDeploy? I can use OP's code and deploy it, sure it won't work correctly but that is not the point here. – Kuba Apr 30 '17 at 08:45
  • @Kuba, I think the main problem is a corrupted session (I +1'ed your comment suggesting a fresh start). I was only able to reproduce the problem by clearing CloudDeploy. However, the syntax used could fail if a Symbol x was already present in the session. Because of this I decided to point to more robust ways of defining functions and related concepts. – Ailton Andrade de Oliveira Apr 30 '17 at 12:26