Plotting Quadratics and ODE Solutions in Mathematica - A Guide for Beginners

  • Context: Mathematica 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Mathematica Plotting
Click For Summary

Discussion Overview

The discussion focuses on plotting multiple quadratic functions and numerical solutions to ordinary differential equations (ODEs) using Mathematica. Participants are seeking guidance on how to combine these plots into a single graph and how to label the curves appropriately.

Discussion Character

  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant shares their initial attempt to plot quadratics and ODE solutions using specific Mathematica commands.
  • Another participant suggests a method to combine the plots into one by adding the quadratic plots to the existing ODE plots in a single Plot command.
  • There is a mention of using "Show[]" to maintain different colors for the quadratics while combining the plots.
  • A participant asks for assistance on how to label each curve in the plot, indicating they are new to Mathematica.

Areas of Agreement / Disagreement

Participants generally agree on the methods to combine plots, but there is no consensus on the best approach to label the curves, as one participant has posed a question about it.

Contextual Notes

There may be limitations regarding the specific definitions of variables and the context of the ODEs being solved, which are not fully detailed in the discussion.

member 428835
Hi PF!

I am trying to plot several quadratics along with two numerical solutions to some ODE's. The command I entered for the two ODE's is

Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]}}, {x, 0, 1.2},
PlotRange -> All]

where s and t have been previously defined.

The plot for the quadratics is

Plot[Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a,
Range[-1/5, 0, .06]}] // Evaluate, {x, 0, 1.2},
PlotLegends -> mList]

Both these commands give me plots, but I'd like them all to be on the same graph. Can someone please help?

Thanks so much!
 
Physics news on Phys.org
You can just add them to your list.
Code:
Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]},Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a,Range[-1/5, 0, .06]}] // Evaluate}, {x, 0, 1.2},PlotRange-> All,PlotLegends -> mList]
Or, if you want the quadratics to remain different colours, you can use "Show[]"
Code:
a=Plot[{{Evaluate[y[x] /. t]}, {Evaluate[y[x] /. s]}}, {x, 0, 1.2},PlotRange -> All]
b = Plot[Table[-.35 (1 - x)^2 + (1 - a)/2 (1 - x), {a, Range[-1/5, 0, .06]}] // Evaluate, {x, 0, 1.2},PlotLegends -> mList]
Show[a,b]
 
  • Like
Likes   Reactions: member 428835
Thanks a ton! That's really helpful!
 
  • Like
Likes   Reactions: e.bar.goum
Hey e.bar.goum, how would I label each curve (sorry I'm new to mathematica). Each quadratic is labeled but the other two curves are not.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K