Graphing equation in Mathematica help

In summary, to graph an equation in Mathematica, use the Plot function and input the equation as an argument. You can also graph multiple equations on the same plot and add labels and a title by using the PlotLabel and PlotLegends options. Additionally, you can change the color and style of the graph and save it as an image or export it to another file format using the Export function.
  • #1
abe_cooldude
15
0
Hi, I am trying to graph

(x+(1/√(1+cos(x)²)))

in mathematica, and i used

Plot[x + (1/(sqrt (1 + cos (x)^2))), {x, 0, 9}]

but I am not getting an output graph.

Any ideas?!

Plot[x + 1/Sqrt[1 + Cos x^2], {x, 0, 9}, PlotRange -> {-10, 10}]

I found few errors, and above is what I got, it's a progress, but now I get this error:

Plot::exclul: {Im[Cos x^2]-0} must be a list of equalities or \
real-valued functions.
 
Last edited:
Physics news on Phys.org
  • #2
Plot[x + 1/Sqrt[1 + Cos[x]^2 ], {x, 0, 9}]

Function arguments always use square brackets as in f[x]
 
  • #3


Hi there, it seems like you are on the right track with your Mathematica code. However, there are a few errors that need to be addressed in order to get a proper graph output.

Firstly, in the equation you provided, there is a missing parenthesis after the square root sign. It should be written as 1/(sqrt(1+cos(x)^2)), with a closing parenthesis after the 2.

Secondly, you have used a lowercase "s" in "sqrt" instead of a capital "S". In Mathematica, the square root function is written as Sqrt, so your code should be Plot[x + 1/Sqrt[1 + Cos x^2], {x, 0, 9}].

Lastly, the PlotRange option is missing from your code. This specifies the range of values on the y-axis for the graph. In this case, it would be helpful to set the range to {-10, 10} to ensure that the graph is properly displayed.

Taking all of these corrections into account, your code should look like:

Plot[x + 1/Sqrt[1 + Cos x^2], {x, 0, 9}, PlotRange -> {-10, 10}]

I hope this helps and you are able to get your desired graph output. Keep exploring and experimenting with Mathematica - it is a powerful tool for graphing and analyzing equations. Good luck!
 

Related to Graphing equation in Mathematica help

1. How do I graph an equation in Mathematica?

To graph an equation in Mathematica, use the Plot function and input the equation as an argument. For example, to graph the equation y = x^2, you would type Plot[x^2, {x, -5, 5}].

2. Can I graph multiple equations on the same plot in Mathematica?

Yes, you can graph multiple equations on the same plot by inputting them as a list of functions in the Plot function. For example, to graph y = x^2 and y = x^3, you would type Plot[{x^2, x^3}, {x, -5, 5}].

3. How can I add labels and a title to my graph in Mathematica?

To add labels and a title to your graph, use the PlotLabel and PlotLegends options in the Plot function. For example, to add a label and a title to the graph of y = x^2, you would type Plot[x^2, {x, -5, 5}, PlotLabel -> "Graph of y = x^2", PlotLegends -> "Equation"].

4. Is it possible to change the color and style of the graph in Mathematica?

Yes, you can change the color and style of the graph by using the PlotStyle option in the Plot function. For example, to change the graph of y = x^2 to be a red dashed line, you would type Plot[x^2, {x, -5, 5}, PlotStyle -> {Red, Dashed}].

5. Can I save my graph as an image or export it to another file format in Mathematica?

Yes, you can save your graph as an image or export it to another file format by using the Export function. For example, to save the graph of y = x^2 as a PNG file, you would type Export["graph.png", Plot[x^2, {x, -5, 5}]].

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
360
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
646
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
255
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
329
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top