Ask Your Question
0

How can two equations be plotted within the same graph using Mathematica?

asked 2021-06-09 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-03-02 18:00:00 +0000

huitzilopochtli gravatar image

Here is an example of how to plot two equations within the same graph using Mathematica:

  1. First, define the two equations using = signs followed by the equation. For example:
eqn1 = x^2 + 2x + 1
eqn2 = 2x + 1
  1. Next, use the Plot function to graph the equations. Use curly brackets {} to enclose the equations and separate them with a comma. Set the range of the x-axis using the PlotRange option:
Plot[{eqn1, eqn2}, {x, -5, 5}, PlotRange -> {-5, 25}]

This will plot both equations on the same graph with x ranging from -5 to 5 and y ranging from -5 to 25.

  1. Add labels and a legend to the graph using the LabelStyle, PlotLabel, and PlotLegends options:
Plot[{eqn1, eqn2}, {x, -5, 5}, PlotRange -> {-5, 25}, LabelStyle -> {FontSize -> 14},
PlotLabel -> "Two equations", PlotLegends -> {"eqn1", "eqn2"}]

This will add a title to the graph, increase the font size of the labels, and add a legend showing which equation is which.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-09 11:00:00 +0000

Seen: 10 times

Last updated: Mar 02 '22