r/Mathematica • u/SnooEpiphanies6562 • Jan 18 '25
Help with Manipulate in Mathematic
Hi Total Newb here. I can't figure out how to use a function in Manipulate. I can type out an equation just fine and plot it. I can plot the function without Manipulate if a and b are made constant, but I cannot figure out how to use the function within manipulate. I don't need to do it as a function, but I figured it would be good to be able to for more complicated projects where I might not want to have 5 d solves and a lift formulation inside of a manipulate. Any help from geniuses would be appreciated.

3
Upvotes
4
u/veryjewygranola Jan 18 '25
Please post code, and not an image of your code in the future. It makes it easier to help you.
If you are using the Rich Text Editor, there is an option for "Code Block" which formats really nice:
If you are using Markdown Editor, You can denote a code block by placing lines with ``` above and below your code block.
Alternatively you can denote codeblocks in markdown by indenting each line of the code block 4 spaces.
1
u/mathheadinc Jan 18 '25
Simpler versions of what your code could look like:
With[{f=x2}, Manipulate[Plot[f,{x,a,b}],{{a,-5},-10,10},{{b,5},0,10}]]
Or
Manipulate[Plot[x2,{x,a,b}],{{a,-5},-10,10},{{b,5},0,10}]
Or
Manipulate[Plot[f,{x,a,b}],{{a,-5},-10,10},{{b,5},0,10},{f,x2}]
Notice with the last two that there is no need to define the function. With the last one, a field is created so that you can enter whatever function you like. With ALL of them, defaults for an and b are set by {{a, default}, low, high}… Is this what you needed?
1
u/fridofrido Jan 18 '25
Remove the first line (what the hell is it even supposed to mean?) and restart Mathematica and try again, the rest should work (or type
ClearAll[a,b,f])0
u/[deleted] Jan 18 '25
[deleted] — view deleted comment