How do you plot nonhomogeous equations in Mathematica?

In summary, to define a nonhomogeneous equation in Mathematica, use the "==" operator. Multiple nonhomogeneous equations can be plotted on the same graph using the "Plot" function. Labels and titles can be added using "PlotLabel" and "PlotLegends" options. The color and style of the plot can be changed using the "PlotStyle" option. To find the intersection points of two nonhomogeneous equations, use the "Solve" function.
  • #1
yitriana
36
0
NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]

i attempted this, but it didn't work.
 
Mathematics news on Phys.org
  • #2
Try this:

Code:
sol1 = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}];
Plot[y[x] /. sol1, {x, 0, 30}]
 

Related to How do you plot nonhomogeous equations in Mathematica?

1. How do I define a nonhomogeneous equation in Mathematica?

To define a nonhomogeneous equation in Mathematica, you can use the "==" operator to represent the equation. For example, "x^2 + 3x == 9" would be a nonhomogeneous equation.

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

Yes, you can plot multiple nonhomogeneous equations on the same graph in Mathematica by using the "Plot" function and separating the equations with a comma. For example, Plot[{x^2 + 3x == 9, x + 2 == 5}, {x, -5, 5}] would plot both equations on the same graph.

3. How can I add labels and titles to my nonhomogeneous equation plot in Mathematica?

To add labels and titles to your nonhomogeneous equation plot in Mathematica, you can use the "PlotLabel" and "PlotLegends" options within the "Plot" function. For example, Plot[x^2 + 3x == 9, {x, -5, 5}, PlotLabel -> "Nonhomogeneous Equation", PlotLegends -> "Equation"] would add a label and legend to your plot.

4. Is it possible to change the color and style of the plot for a nonhomogeneous equation in Mathematica?

Yes, you can change the color and style of the plot for a nonhomogeneous equation in Mathematica by using the "PlotStyle" option within the "Plot" function. For example, Plot[x^2 + 3x == 9, {x, -5, 5}, PlotStyle -> {Red, Dashed}] would plot the equation in red and with a dashed line.

5. How do I find the intersection points of two nonhomogeneous equations in Mathematica?

To find the intersection points of two nonhomogeneous equations in Mathematica, you can use the "Solve" function and set the equations equal to each other. For example, Solve[x^2 + 3x == 9 && x + 2 == 5, x] would give you the x-values where the two equations intersect.

Similar threads

  • General Math
Replies
5
Views
490
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
155
Replies
17
Views
2K
Replies
1
Views
1K
  • General Math
Replies
2
Views
9K
  • General Math
Replies
3
Views
1K
Replies
3
Views
744
  • General Math
Replies
7
Views
1K
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
Back
Top