Constants in Mathematica

  • Mathematica
  • Thread starter madness
  • Start date
  • #1
815
70
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?
 

Answers and Replies

  • #2
radou
Homework Helper
3,120
6
Well, simply define their numerical values, plot the function, and repeat again. If this is what you're trying to do.
 
  • #3
815
70
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.
 
  • #4
radou
Homework Helper
3,120
6
Hm, I can't think of a more handy way, since in any case you'll have to define these constants explicitly.
 
  • #5
4,254
1
Can slider bars help?

Code:
DynamicModule[{x = Random[]}, 
 Column[Table[
   Slider[Dynamic[x], ImageSize -> RandomReal[200]], {10}]]]
 
  • #6
Dale
Mentor
Insights Author
2020 Award
31,855
8,719
I would look at using the "Manipulate" command. It will generate slider bars like Phrak suggested.
 

Related Threads on Constants in Mathematica

Replies
3
Views
12K
Replies
1
Views
7K
  • Last Post
Replies
4
Views
2K
Replies
5
Views
4K
Replies
2
Views
2K
Replies
9
Views
3K
Replies
18
Views
3K
Replies
1
Views
2K
Replies
1
Views
3K
Top