# Manipulating a pre-defined function [closed]

I am having difficulty using Manipulate to build interactive plots.

I deal with equations that are somewhat long. I would like to define them prior to using them in Manipulate, and use their name in Manipulate instead of copying the entire equation for the function.

For example,

I can easily get the interactive plot for the following function:

Manipulate[Plot[Sin[a*x], {x, -5, 5}],  {a, 0, 10} ]


However, if I try the equation below, I get nothing. What am I doing wrong? I tried func1 := Sin[a*x];, but it doesn't change anything.

examplefunction = Sin[a*x];
Manipulate[Plot[examplefunction, {x, -5, 5}],  {a, 0, 10} ]

• You are almost there. Define your function as: examplefunction[x_, a_] := Sin[a*x]; and then you can use Manipulate as follows: Manipulate[Plot[examplefunction[x, a], {x, -5, 5}], {a, 0, 10}]. Have fun! – Alexei Boulbitch Dec 3 '19 at 11:10
• Thank you I got it working. I have a follow up question, if I =use instead of :=, it stills works, why? – user68738 Dec 3 '19 at 11:21
• 1. This issue is explained in the Possible Issues section of document of Manipulate. 2. examplefunction[x_, a_] := and examplefunction[x_, a_] = are almost equivalent in this case, for an advanced discussion check the following post: mathematica.stackexchange.com/q/181591/1871 – xzczd Dec 3 '19 at 11:40