[Date Index]
[Thread Index]
[Author Index]
RE: beginner question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg32008] RE: [mg32003] beginner question
*From*: "David Park" <djmp at earthlink.net>
*Date*: Tue, 18 Dec 2001 02:34:16 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
Hmmm,
Yes, it is possible to do all the things you describe with Mathematica. If
you are a beginner, I recommend that you spend some time working through
Part I of The Mathematica Book, or some introductory book so that you will
at least be familiar with the basic Mathematica commands. In what follows I
will be using pure functions, the Map command (and its shortcut notation),
HoldForm, Dot, Thread, Solve, ReplaceAll, and Flatten. You may want to look
these up in Help.
Topic 1: Solving equations step by step.
I have a notebook at be web-site, written at the high school level, showing
how to do this, and illustrating pure functions and the Map command.
Mathematica will automatically simplify the equation as you have written it,
so I start out by putting it in a HoldForm, and then releasing the Hold as
the first step. Then we just map the desired operation onto both sides of
the equation.
HoldForm[x + 2*x + 3 == 0]
ReleaseHold[%]
(#1 - 3 & ) /@ %
(#1/3 & ) /@ %
x + 2 x + 3 == 0
3 + 3 x == 0
3 x == -3
x == -1
There is also a package and tutorial at my web site called
ExpressionManipulation which allows the detailed manipulation of expressions
in Held form.
Topic 2: Getting a line through two points.
Here are two points.
pt1 = {2, 1};
pt2 = {5, 7};
A parametrization of a line through two points is given by:
line[t_] := pt1 + t(pt2 - pt1)
When t = 0, the line will be at pt1, and when t = 1, the line will be at
pt2. The following plots the line and the two points.
Show[Graphics[
{AbsolutePointSize[4],
Point[pt1],
Point[pt2],
Line[{line[-1], line[2]}]}],
AspectRatio -> Automatic,
Axes -> True];
To obtain the equation for the line we form two vectors. The first vector
goes from pt1 to pt2. The second vector goes from pt1 to a general point
{x,y}. If we take the cross product of these two vectors it must be zero if
{x,y} lies on the line. But it takes a little work to make cross products of
2D vectors. We can either add a third zero z component to each vector, or we
can define a routine that will do the work for us.
{x1, y1, 0}\[Cross]{x2, y2, 0}
{0, 0, -x2 y1 + x1 y2}
We just want to calculate the third component and this will do it for any
pair of 2D vectors.
Cross2D[v1_, v2_] := (v1{1, -1}).Reverse[v2]
As a check:
Cross2D[{x1, y1}, {x2, y2}]
-x2 y1 + x1 y2
Then we just use what we learned in Topic 1.
Cross2D[pt2 - pt1, {x, y} - pt1] == 0
% // ExpandAll
# - 9 & /@ %
Minus /@ %
-6 (-2 + x) + 3 (-1 + y) == 0
9 - 6 x + 3 y == 0
-6 x + 3 y == -9
6 x - 3 y == 9
Topic 3: Tangents to a circle from a point outside the circle.
Here, p is the point, c is the center of the circle, r is the radius of the
circle and q is a general point which we want to fix as the point where the
tangent touches the circle.
p = {1, 5};
c = {7, 3};
r = 2;
q = {x, y};
Using what we learned in Topic 2, we define lines going from p to q and from
c to q.
line[t_] = p + t(q - p)
radius[t_] = c + t(q - c)
{1 + t (-1 + x), 5 + t (-5 + y)}
{7 + t (-7 + x), 3 + t (-3 + y)}
Our first equation says that the line cq is perpendicular to the line pq.
(The dot product must be zero.)
eqn1 = (c - radius[t2]).(p - line[t1]) == 0
t1 t2 (-7 + x) (-1 + x) + t1 t2 (-5 + y) (-3 + y) == 0
Our second equation specifies the length of cq (or its square)
eqn2 = Plus @@ ((c - radius[t2])^2) == r^2
t2^2*(-7 + x)^2 + t2^2*(-3 + y)^2 == 4
Our third and fourth equations come from noting that the position of q on
the tangent line must be the same as the position of q on the radial line.
eqn34 = Thread[line[t1] == radius[t2]]
{1 + t1 (-1 + x) == 7 + t2 (-7 + x), 5 + t1 (-5 + y) == 3 + t2 (-3 + y)}
We now have four equations and four unknowns {x,y,t1,t2}. We Solve for x,y
eliminating t1, t2. We obtain two sets of solutions because there are two
tangent lines.
xysols = Solve[{eqn1, eqn2, eqn34} // Flatten, {x, y}, {t1, t2}]
{{x -> 29/5, y -> 7/5}, {x -> 7, y -> 5}}
The points where the tangents touch the circle are:
{q1, q2} = {x, y} /. xysols
{{29/5, 7/5}, {7, 5}}
The parametrizations of the tangent lines are:
tangent1[t_] = line[t] /. First[xysols]
tangent2[t_] = line[t] /. Last[xysols]
{1 + (24*t)/5, 5 - (18*t)/5}
{1 + 6 t, 5}
This plots the circle, points and two tangent lines.
Show[Graphics[
{Circle[c, r],
Line[{p, tangent1[2]}],
Line[{p, tangent2[2]}],
AbsolutePointSize[6],
Point /@ {p, q1, q2}}],
AspectRatio -> Automatic,
PlotRange -> {{0, 12}, {-2, 6}},
Axes -> True];
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
> From: Hmmm [mailto:ventzy_kunev at yahoo.com]
To: mathgroup at smc.vnet.net
>
> Hi,
> 1)Is this possible to view full way to solution of some math problem.
>
> For example:
> in: x+2x+3=0
> out: 3x+3=0
> 3x=-3
> x=-1
>
> what about quadratic and cubic equations, integrals, differentials...
>
>
> 2)Is Mathematica can solve geometric problems.
> For example how to get line equation through to points or how to get
> point where some line touch certain circle.
>
Prev by Date:
**Re: equations**
Next by Date:
**Re: equations**
Previous by thread:
**beginner question**
Next by thread:
**Handling constraints in NDSolve**
| |