Mathematica How can I vary physical constants in Mathematica plots?

AI Thread Summary
To efficiently vary multiple physical constants in plotting functions, defining their values explicitly for each plot can be cumbersome, especially with eight constants. While using commands like Plot[f[x] /. {a -> 1, b -> 2}, {x, 0, 1}] simplifies the process, it remains tedious. An alternative approach involves defining constants as lists, such as const = {a -> 1, b -> 2}, although this can complicate the plotting process. A more effective solution is to utilize the "Manipulate" command, which allows for the creation of interactive slider bars to adjust the constants dynamically, enhancing the plotting experience.
madness
Messages
813
Reaction score
69
I have a function which depends on several physical constants, which I want to be able to vary each time I make a plot. What is the best way to do this?
 
Physics news on Phys.org
Well, simply define their numerical values, plot the function, and repeat again. If this is what you're trying to do.
 
Is this really the best way? I have at least 8 constants here. I've seen the command
Plot[f[x] /.{a->1,b->2},{x,0,1}], but this is still annoying for 8 constants. Or defining constants as lists const={a->1,b->2}; but I can't work out how to call them when I plot the function.
 
Hm, I can't think of a more handy way, since in any case you'll have to define these constants explicitly.
 
Can slider bars help?

Code:
DynamicModule[{x = Random[]}, 
 Column[Table[
   Slider[Dynamic[x], ImageSize -> RandomReal[200]], {10}]]]
 
I would look at using the "Manipulate" command. It will generate slider bars like Phrak suggested.
 
Back
Top