Plotting 2(or more) functions at once

AI Thread Summary
To plot two functions simultaneously in Mathematica, such as x^2 over the interval {x, 0, 1} and x^3 over {x, 1, 2}, the commands can be combined using the Show function. The example provided demonstrates this with the code: g1 = Plot[x^2, {x, 0, 1}]; g2 = Plot[x^3, {x, 1, 2}]; Show[g1, g2]. This method effectively overlays the two plots, allowing for a clear visualization of the ball's motion during its bouncing stages. Additionally, substituting x^3 with x^3 - 1 can help in verifying the functionality of the plot. The discussion highlights the importance of combining plots for visualizing discrete stages in motion equations.
karkas
Messages
131
Reaction score
1
Hey all, I want to ask a simple question that I can't seem to get answered myself. How is it possible to get Mathematica to plot 2 functions at once? As in, I want to have x^2 {x,0,1} and x^3 {x,1,2} in the same plot graph.

More specifically, what I'm trying to do is plot the y-t graph of a ball bouncing on the ground, and I'm thinking of doing so by combining the equations of motion for every discrete stage of the bouncing.

Any help is greatly appreciated.
 
Physics news on Phys.org
g1 = Plot[x^2, {x, 0, 1}];
g2 = Plot[x^3, {x, 1, 2}];
Show[g1, g2]

If it isn't clear whether it is working then substitute x^3-1 for a moment
 
Bill Simpson said:
g1 = Plot[x^2, {x, 0, 1}];
g2 = Plot[x^3, {x, 1, 2}];
Show[g1, g2]

If it isn't clear whether it is working then substitute x^3-1 for a moment

Thanks a huge ton. It was clear as hell, didn't think of that.
 
Back
Top