Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: inserting an equation and plotting it
Replies: 1   Last Post: Nov 27, 2012 3:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: inserting an equation and plotting it
Posted: Nov 27, 2012 3:32 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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@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.
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.