How can I vary physical constants in Mathematica plots?

In summary, the best way to vary physical constants when making a plot is to define their numerical values and use the command Plot[f[x] /.{a->1,b->2},{x,0,1}]. Using slider bars with the "Manipulate" command can also be helpful.
  • #1
madness
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?
 
Physics news on Phys.org
  • #2
Well, simply define their numerical values, plot the function, and repeat again. If this is what you're trying to do.
 
  • #3
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
Hm, I can't think of a more handy way, since in any case you'll have to define these constants explicitly.
 
  • #5
Can slider bars help?

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

Related to How can I vary physical constants in Mathematica plots?

1. What are constants in Mathematica?

Constants in Mathematica are predefined mathematical values that remain constant during calculations. They are represented by symbols and do not change their values.

2. How do I access the list of available constants in Mathematica?

To access the list of available constants, you can use the command Constants[] or go to the Constants category in the Wolfram Language Guide from the Help menu in Mathematica.

3. Can I define my own custom constants in Mathematica?

Yes, you can define your own custom constants in Mathematica using the Set or SetDelayed functions. For example, you can define a constant named gravity by typing gravity = 9.8 in the Mathematica notebook.

4. What is the difference between a constant and a variable in Mathematica?

A constant is a predefined value that does not change during calculations, while a variable is a symbol that can hold different values. Constants are usually represented in uppercase letters, while variables are represented in lowercase letters.

5. How can I use constants in mathematical expressions and functions in Mathematica?

You can use constants in mathematical expressions and functions by simply typing their names in the expression or function. For example, you can use the constant pi in the expression 2 * pi * r to calculate the circumference of a circle with radius r.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
330
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
792
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Back
Top