I need help again.

General discussion about Mathematica features and functionality...
Forum Rules
By using the Wolfram Faculty Program Forum, you agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, or sexually oriented material. Wolfram Faculty Program Forum administrators have the right to remove, edit, move or close any topic at any time should we see fit.

Personal Information: Posts in this forum may be viewed by non-members; however, the forum prohibits non-members from viewing your profile. Although your email address is hidden from both non-members and members, your account is initially configured to allow members to contact you via email through the forum. If you wish to hide your profile, or prohibit others from contacting you directly, you may change these settings by updating your profile through the User Control Panel.

Attachments: Attachments are not currently enabled on this forum. To share a file with others on this site, simply upload your file to the online storage service of your choice and include a link to the file within your post. If your school does not offer an online file storage and sharing service, the following sites provide free basic online file storage and sharing: Mozy, FilesAnywhere, Adrive, and KeepandShare.

I need help again.

Postby Rob_Holman » Sat Aug 11, 2012 2:17 pm


I'm trying to do a Mean Value Theorem demonstration, where two points can be selected on a curve, and the computer will find the point(s) at which the derivative matches the average slope, and display that point plus the tangent line.

All was going well, and then I hit the following snag. In the code below I've defined the variables I need (I think), and the secant line displays just fine. However, I can't get the program to actually COMPUTE the value of m1. All it does is substitute values into the difference quotient (for lack of a better term) without actually finding the numerical value. Drag the points around and check out the value of m1 below the plot.

I'm sure I'm doing something incorrectly -- I just need someone to tell me what it is.

Thanks, as always. Code is below.



f[x_] := x^2;
dpt1 = {0, 1};
dpt2 = {1, 0};

x1 = Dynamic[First[dpt1]];
y1 = Dynamic[f[First[dpt1]]];
x2 = Dynamic[First[dpt2]];
y2 = Dynamic[f[x2]];

m1 = (y2 - y1)/(x2 - x1);
xx1 = Dynamic[Solve[D[f[x], x] == m1, x]];

tangentPlot =
Plot[m1*(x - xx1) + f[xx1], {x, -2, 2}, PlotStyle -> Green];

Dynamic[{dpt1, dpt2}],

Plot[f[x], {x, -2, 2}],
Red, Line[{
Dynamic[{x1, y1}], Dynamic[{x2, y2}]
Epilog -> {PointSize[Large], Point[Dynamic[{x1, y1}]],
Point[Dynamic[{x2, y2}]]}

Appearance -> None


Also, just beneath this line, put a line that just says "m1", and enter that. then you can hopefully see the behavior of m1 that I'm talking about...
User avatar
Posts: 14
Joined: Wed Feb 29, 2012 7:03 pm
Organization: The Walker School
Department: Mathematics and Science

Re: I need help again.

Postby Kathy_Bautista » Wed Aug 15, 2012 4:32 am

Hi Rob,

Dynamic updates the screen area whenever the variable under consideration is changed. So using a ; at the end of a Dynamic statement essentially negates this dynamism.

Below is a MathGroup post from one of my collegues, John Fultz, which addresses this very issue, and I hope you find helpful.
http://forums.wolfram.com/mathgroup/arc ... 00424.html

Katherine Bautista
Senior Academic Program Manager
Wolfram Research, Inc.
User avatar
Site Admin
Posts: 182
Joined: Fri Jul 31, 2009 6:24 pm
Location: Mesa, Arizona
Organization: Wolfram Research, Inc.
Department: Academic Initiatives

Return to General Mathematica Discussion

Who is online

Users browsing this forum: No registered users and 1 guest