Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Manipulate help

23 views
Skip to first unread message

07.350z

unread,
Nov 7, 2012, 12:58:12 AM11/7/12
to
Create a Manipulate demonstration that draws the tangent line to a curve at the point specified by a continuous control. For the curve, the user should be able to choose between the graphs of the following functions. Make sure your demonstration shows the curve, the point, and the tangent line at that point. The functions are 7cos(x),
x^2/10, 2ln(1+x^2)

Show[Manipulate[
Plot[y, {x, -10, 10},
PlotRange -> {-10, 10}], {y, {7 Cos[x], x^2/10, 2*Log[1 + x^2]}}],
Do[Module[{slopeM, tangentLine, x},
slopeM = D[{7 Cos[x], x^2/10, 2*Log[1 + x^2]}, x] /. x -> t;
tangentLine = slopeM*x - t;
Return[
Plot[{{7 Cos[x], x^2/10, 2*Log[1 + x^2]}, tangentLine}, {t, -5,
5}]]], {x, -10, 10}]]

I know the first part of code is right, but I'm having trouble adding the tangent line. Any help would be great thanks!

Nasser M. Abbasi

unread,
Nov 8, 2012, 2:14:19 AM11/8/12
to
may be

-------------------------------------------
Manipulate[
Module[{lineEquation, pt = {at, y /. x -> at}},
lineEquation = getSlope[at, y, x];
Plot[{y, lineEquation }, {x, -10, 10}, PlotRange -> {-10, 10},
Epilog -> {Red, PointSize[.02], Point[pt]}]
],

{y, {7 Cos[x], x^2/10, 2*Log[1 + x^2]}},
{{at, 0, "x"}, -10, 10, 1, Appearance -> "Labeled"},
TrackedSymbols :> {y, at},

Initialization :>
(
getSlope[at_, y_, var_] := Module[{slope, h, intercept},
h = y /. var -> at;
slope = D[y, var] /. var -> at;
intercept = h - at*slope;
slope*var + intercept
]
)
]
----------------------------------

--Nasser


0 new messages