Re: inserting an equation and plotting it

*To*: mathgroup at smc.vnet.net*Subject*: [mg128801] Re: inserting an equation and plotting it*From*: Bob Hanlon <hanlonr357 at gmail.com>*Date*: Tue, 27 Nov 2012 03:32:09 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net*References*: <20121126042737.6C81468DB@smc.vnet.net>

Square brackets are only used for enclosing function arguments and curly brackets are only used for lists. Periods do not belong in symbolic expressions unless you are doing dot products. a[q_, m_] = Module[ {r = q/m, s}, s = Sqrt[1 - r^2]; 2 Pi/(m (Pi + r/2 - ArcCos[s] + (1 - s)/r))] (2*Pi)/(m*(Pi + q/(2*m) + (m*(1 - Sqrt[1 - q^2/m^2]))/ q - ArcCos[Sqrt[ 1 - q^2/m^2]])) The case for q=0 must be handed in the limit Limit[a[q, m], q -> 0] 2/m a[q_ /; q == 0, m_] = 2/m; Plot[Evaluate[ Table[a[q, m], {q, 0, 1, 0.1}]], {m, 1, 5}, AxesLabel -> {"m", "a[q,m]"}] The curves essentially overlap, zooming in to see the separate curves: Plot[ Evaluate[ Table[ Tooltip[a[q, m], "q = " <> ToString[q]], {q, 0, 1, 0.1}]], {m, 1, 1.01}, AxesLabel -> {"m", "a[q,m]"}] Alternatively, use Manipulate to look at the separate curves individually. Manipulate[ Plot[a[q, m], {m, 1, 5}, AxesLabel -> {"m", "a[q,m]"}, PlotRange -> {0, 2.1}], {q, 0, 1, 0.1, Appearance -> "Labeled"}] Similarly for q as the independent variable Plot[ Evaluate[ Table[ Tooltip[a[q, m], "m = " <> ToString[m]], {m, 1, 5, 0.5}]], {q, 0, 1}, AxesLabel -> {"q", "a[q,m]"}, PlotRange -> {0, 2.1}] Manipulate[ Plot[a[q, m], {q, 0, 1}, AxesLabel -> {"q", "a[q,m]"}, PlotRange -> {0, 2.1}], {m, 1, 5, 0.05, Appearance -> "Labeled"}] Combining all into a single graphic Manipulate[ Show[ Plot3D[a[qv, mv], {mv, 1, 5}, {qv, 0, 1}], Graphics3D[ {Red, AbsoluteThickness[2], Line[{m, #[[1]], #[[2]]} & /@ Cases[ Plot[a[qv, m], {qv, 0, 1}], Line[pts_] :> pts, Infinity][[1]]], Line[{#[[1]], q, #[[2]]} & /@ Cases[ Plot[a[q, mv], {mv, 1, 5}], Line[pts_] :> pts, Infinity][[1]]], Blue, AbsolutePointSize[10], Tooltip[ Point[{m, q, a[q, m] + 0.01}], Style[ "a[q, m] = " <> ToString[a[q, m]], 14]]}], AxesLabel -> (Style[#, Bold, 12] & /@ {"m", " q", "a[q, m] "})], {{q, 0.5}, 0, 1, 0.02, Appearance -> "Labeled"}, {{m, 3}, 1, 5, 0.05, Appearance -> "Labeled"}] Bob Hanlon On Sun, Nov 25, 2012 at 11:27 PM, Abdo Adam <abdo.d12 at hotmail.com> wrote: > i'm trying to insert an equation and plot it, but i couldn't because i keep getting errors like : matrix dimensions must agree, or inner matrix dimensions must agree. > > http://www4.0zz0.com/2012/11/25/10/272913238.png > this is the equation. M has a value of 1 to 5 with an increment of 0.5. Q has a value of 0 to 1 with an increment of 0.1. > > http://www4.0zz0.com/2012/11/25/10/700692428.png > the plot is something like this. > > i tried to split the equation into parts, so it would be easier for me to insert it > i'm having a problem with the last part, i get this error > > e=q./m(1-sqrt(1-(q./m).^2)); > > Subscript indices must either be real positive integers or logicals. >

**References**:**inserting an equation and plotting it***From:*Abdo Adam <abdo.d12@hotmail.com>