How can I vary physical constants in Mathematica plots?

  • Context: Mathematica 
  • Thread starter Thread starter madness
  • Start date Start date
  • Tags Tags
    Constants Mathematica
Click For Summary

Discussion Overview

The discussion revolves around how to vary physical constants in Mathematica plots, focusing on methods for efficiently managing multiple constants during plotting. The scope includes technical explanations and practical applications within Mathematica.

Discussion Character

  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant suggests defining numerical values for the constants and plotting the function repeatedly as a straightforward approach.
  • Another participant questions the efficiency of this method, noting the inconvenience of managing at least 8 constants and mentioning the use of substitution in the plot command.
  • A further contribution indicates that defining constants as a list could be a solution, but expresses difficulty in implementing this during plotting.
  • One participant proposes the use of slider bars as a potential solution for varying constants dynamically.
  • Another participant recommends the "Manipulate" command as a way to generate slider bars for adjusting constants, aligning with the previous suggestion about sliders.

Areas of Agreement / Disagreement

Participants present multiple approaches to the problem, with no consensus on the best method. Some methods are proposed as alternatives to others, indicating a variety of opinions on efficiency and practicality.

Contextual Notes

Participants express uncertainty about the best way to implement their ideas, particularly regarding the use of lists for constants and the functionality of slider bars in Mathematica.

Who May Find This Useful

Users of Mathematica looking to plot functions with variable physical constants, particularly those managing multiple constants in their models.

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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K