Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATHEMATICA – AN INTRODUCTION R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART III- GRAPHICS Two-dimensional plots Three-dimensional.

Similar presentations


Presentation on theme: "MATHEMATICA – AN INTRODUCTION R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART III- GRAPHICS Two-dimensional plots Three-dimensional."— Presentation transcript:

1 MATHEMATICA – AN INTRODUCTION R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART III- GRAPHICS Two-dimensional plots Three-dimensional plots. List plots Contour plots Density plots Parametric plots Parametric 3D-plots Anmation

2 30. Two-Dimensional Plot In[1]:= Plot[2x^3 –x^2 + 2, {x, -2, 2}]

3 30.1 Options for Plots: Setting Range, Scales, Labeling and PlotStyles The vertical range can be specified using the PlotRange option. This is useful for focusing on a significant feature of a graph. Plots may be assigned to some variable. In[2]:= p1=Plot[2x^3 –x^2 + 2,{x,-2, 2}, PlotRange->{-5, 5}]

4 In[3]:= p2 = Plot[ Exp[-0.1 x] Sin[x],{x,-5,5},PlotRange->{-2,2}]

5 In[4]:= Plot[Sin[x], {x, -Pi, Pi}, AxesLabel->{"x","Sin[x]"}]

6 ln[5]:= Plot[Sin[t], {t, 0, 2Pi}, AxesLabel -> {"Time","Amplitude"}, PlotLabel —> "Sine Wave"]

7 Plot[Sin[x], {x,0,2 Pi},PlotStyle->{RGBColor[1,0,1]}]

8 Mathematica also has ability to cope with poles. In[6]:= Plot[ 1/Sin[x], {x, -Pi, Pi}]

9 31. Plotting two or more functions ln[7]:= Plot[{ Exp[-0.1 x] Sin[x], x^2 -3x +1}, {x, -5, 5}] plots exp[-0.1x] sin(x) and x^2 –3 x + 1 over the interval [-5, 5].

10 31.1 Show The Show[ ] command superimposes many plots. For instance, plotting some of the earlier named plots, type In[8]:= Show[p1, p2]

11

12

13

14 32. Three Dimensional Plotting For creating three dimensional plots, use Plot3D[ ] The arguments of Plot3D[ ] are similar to those of the function Plot[ ]. In[9]:= Plot3D[Sin[x] Cos[y], {x.-Pi.Pi}, {y.-2Pi.2Pi}]

15 In[9]:= Plot3D[Sin[x] Cos[y], {x.-Pi.Pi}, {y.-2Pi.2Pi}, AxesLabel -> {x,y,z}, PlotPoints->40]

16 33 Evaluate command A list of expressions can be given to Mathematica to plot using the Table[ ] In such case, Evaluate command forces evaluation of the command. In[10]:=Plot[Evaluate[Table[ Cos[a*x],{a, 1, 5}]], (x, 0, 2Pi}];

17 34. ListPlot ListPlot[ ] command draws a list of points, given as coordinate pairs (x, y). ln[11]:= p3 =ListPlot[{{-5, -3}, {-3, 2}, {0.5, 6.3), {2.5, 1.4}, {5, 3}}, PlotJoined -> True];

18 To draw a plot joining the points (1, y1), (2,y2),..., (n, y n ). In[12]:= ListPlot[ { 2.5, 3.7, -1.2, 7.0, 9.1, -2.3}, PlotJoined->True ]

19 35. ContourPlot ContourPlot creates contours of an expression involving two variables. The contours are the curves on which the expression is constant. The contours are drawn on a rectangle. Ranges for each variable in the expression can be given. In[12]:= p4 = ContourPlot[x^3 +y^2, {x, -3, 3}, {y, -3. 3}]

20 36. DensityPlot This has the syntax similar to that of the ContourPlot[ ], but it has different options. For an expression involving two variables, this produces a shading of chosen rectangle. In[13]:= DensityPlot[x^3 +y^2, {x, -3, 3}, {y, -3. 3}]

21 Plotting a Vector field <<VectorFieldPlots`; VectorFieldPlot[{x, y}, {x, 0, 1}, {y, 0, 1}]

22 VectorPlot (* Needs["Graphics`PlotField`"]; *) <<VectorFieldPlots`; vector={x, y}/(x^2 + y^2)^(3/2) PlotVectorField[ vector, {x, -7,7,2}, {y, -7,7,2}]

23 Gradient of Scalar <<VectorFieldPlots`; scalar=1/Sqrt[x^2+y^2] PlotGradientField[scalar, {x,-5,5,2},{y,-5,5,2}]

24 37. ParametricPlot ParametriePlot[ ] draws the curve formed by a pair of expression {x[t], y[t]} as the parameter t varies. In[14]:= ParametricPlot[ {Exp[-t/20] Cos[t],Exp[-t/20] Sin[t]},{t,0,50}]

25 38. ParametricPlot3D This plots a parametrically defined three-dimensional curve (or a parametrically defined three-dimensional surface). It is part of the collection of Graphics packages, which must be loaded explicitly before it can be used, In[15]:= <<Graphics`ParametricPlot3D` In[16]:= ParametricPlot3D[{Cos[x], Sin[x],x/4}, {x, 0, 2Pi}];

26 SphericalPlot SphericalPlot3D[ 1+2 Cos[2 q], {q,0,Pi}, {f,0,2 Pi} ]

27 39. Plotting Spherical Harmonics (Math2.2) Needs["Graphics`ParametricPlot3D`"] SphericalPlot3D[ Abs[ SphericalHarmonicY[3, 1, theta, phi] ], {theta, 0, Pi, Pi/30}, {phi, 0, 2 Pi, Pi/15}]

28 In Math 6.0 SphericalPlot3D[Abs[SphericalHarmonicY[3,1,theta,phi]],{theta,0,Pi},{phi,0,2 Pi}]

29 SphericalPlot3D[Abs[SphericalHarmonicY[5,1,theta,phi]],{theta,0,Pi},{phi,0,2 Pi}]

30

31

32 End of part III


Download ppt "MATHEMATICA – AN INTRODUCTION R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART III- GRAPHICS Two-dimensional plots Three-dimensional."

Similar presentations


Ads by Google