Plotting functions and coordinates, Mathematica

In summary, the conversation discusses the possibility of plotting multiple functions and coordinates on the same graph in Mathematica, the potential differences in pseudo-random number generation techniques in different programming languages, and a suggestion for a cheap hardware hack for generating random numbers.
  • #1
freefaller
10
0
Hi all.

Is there a way to plot both functions and coordinates/points on the same graph in Mathematica? The various functions for plotting each seem very incompatible. I would like to compare a probability function to Monte-Carlo-method simulation results.

Also, out of curiosity, do different programming languages have "better" pseudo-random number generation techniques or does it not really make a difference?

Thank you.
 
Physics news on Phys.org
  • #2
data = Table[{x, x^2}, {x, 0, 2}];
Show[
Plot[x^2, {x, 0, 2}],
ListPlot[data],
Graphics[Text["(1,1)", {1, 1}, {-1, 0}]]
]

will show a graph, points and a coordinate.
If you need to you can change point size, color, background, dashing and a thousand other visual effects.

There are expensive hardware random number generators you can buy.

I've wanted someone to think of a cheap hardware hack that would generate a few random bits a second from the radioactive decay of a smoke detector, but I haven't found anyone interested in doing that.
 
  • #3
Thanks Bill! It works nicely.

I'm self-taught so I ignored Show[]'s existence. Now I know.

That's an interesting hack, although I guess for most purposes computer-generated numbers work fine ... and are simpler to obtain.

Thanks again
 

1. How do I plot a function in Mathematica?

To plot a function in Mathematica, use the Plot function. For example, to plot the function y = x^2, you would enter the code Plot[x^2, {x, 0, 5}]. This will plot the function from x = 0 to x = 5.

2. How can I customize the appearance of my plot in Mathematica?

To customize the appearance of your plot, you can use various options within the Plot function. Some options include changing the color, style, and thickness of the plot line, adding labels and titles, and adjusting the range of the axes. You can also use the PlotStyle option to plot multiple functions with different styles.

3. How do I plot multiple functions on the same graph in Mathematica?

To plot multiple functions on the same graph, you can use the Plot function with a list of functions as the first argument. For example, to plot the functions y = x^2 and y = x^3 on the same graph, you would enter the code Plot[{x^2, x^3}, {x, 0, 5}]. You can also use the Show function to combine multiple plots into one.

4. Can I plot functions in polar coordinates in Mathematica?

Yes, you can plot functions in polar coordinates in Mathematica. To do so, use the PolarPlot function and specify the function in terms of r and θ. For example, to plot the function r = 2θ, you would enter the code PolarPlot[2θ, {θ, 0, 2π}].

5. How can I save my plot as an image or export it to a different format in Mathematica?

You can save your plot as an image in Mathematica by using the Export function. For example, to save your plot as a PNG file, you would enter the code Export["plot.png", plot], where "plot" is the name of your plot. You can also export your plot to different formats such as PDF, JPEG, or SVG.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top