I would like to offer a challenging project to implement in the Wolfram Language that incorporates some of the material from this course. It is to build 2-D and 3-D interactive graphs using Manipulate that show intersections of customizable solids with three planes x = a, y = b, and z = c, where the values of a, b, and c are adjustable. This is based on Free Response Question 2 from this year’s AP Calculus AB exam. I have implemented part of the question in a TI-Nspire CX II CAS graphing calculator document. I want to see this duplicated and extended in Wolfram. A description of the project is in the attached pdf document. If would be great if Devendra, Shenghui, Luke, or any participant (Michael?) could provide at least a beginning of the project’s code and post it here.
Demonstrations used today:
WFR:
In the neat example section for the WFR LucasCubic you can find the non-trivial case used today for oblique asymptotes: 
|
|
|
Demonstrations used Today:
Handy WFR function:
|
|
|
I put the following question, which Shenghui said he would answer in the Community Thread, in the Q&A today (8-18). I have added more to it here: On each of the examples with a tangent line drawn to an implicitly defined curve, can you write code that will also draw all other tangent lines to the curve which are parallel to the first tangent line? The examples included: circle, Folium of Descartes [in the example shown, there are no other tangents since the one shown is parallel to the asymptote—but every other point on the curve should have a parallel tangent], ellipse, hyperbola, cardioid, Devil’s Curve (a symmetric rational quartic), and Kampyle of Eudoxus. Are there any theorems relating the maximum number of possible parallel tangents to the degree of the equation? A non-relative extrema point on the graph of a sine, cosine, secant, cosecant, tangent, or cotangent would have an infinite number of parallel tangents to the one at the given point. Now consider Lissajous curves [see, for example, https://mathworld.wolfram.com/LissajousCurve.html and https://demonstrations.wolfram.com/LissajousFigures/ ], which are parametric curves with both x- and y- components being sinusoidal functions. Would the code for finding parallel tangents from the algebraic curves above also work for these? If not, can you write code for this case?
|
|
|
Here is an more involved example demonstrating that the parallel tangents can be found using numeric equation solving function:
f[x_, y_] := x^2 + x*Sin[4*y] + 3 y^2 - 7 + Cos[3*x];
pt = With[{x = RandomReal[{-2, 2}]}, {x, y /. FindRoot[f[x, y] == 0, {y, 1}]}];
slope = ImplicitD[f[x, y] == 0, y, x];
m = slope /. Thread[{x, y} -> pt];
pt2 = {x, y} /. FindRoot[{f[x, y] == 0, slope == m}, {x, -2}, {y, -1}];
m2 = slope /. Thread[{x, y} -> pt2];
ContourPlot[f[x,y]==0,{x,-4,4},{y,-4,4},Epilog->{InfiniteLine[pt,{1,m}],
InfiniteLine[pt2,{1,m2}],
{PointSize[0.02],Point[pt]},
{PointSize[0.02],Point[pt2]}
}]

|
|
|
Here's an applet that builds on @Shenghui Yang's example. It finds all the tangents with a given slope. I also used an exact solver instead of a numerical one, for variety's sake. I'm quite familiar with Wolfram Language, and I apologize if some of the functions I used are a little further along your personal learning curve for WL.
f[x_, y_] := x^2 + x*Sin[4*y] + 3 y^2 - 7 + Cos[3*x];
(* there are powerful algorithms for solving transcendental equations
over bounded domains, so we'll help Solve[] out with the following *)
boundsArray = RegionBounds[ImplicitRegion[f[x, y] == 0, {x, y}]];
boundsArray = boundsArray /. x_Real :> Sign[x] Ceiling[Abs[x] + 0.01, 1/128]; (* pad bounds a bit *)
boundsIneqs = Replace[boundsArray,
{{x1_, x2_}, {y1_, y2_}} :> x1 < x < x2 && y1 < y < y2];
(* pre-compute plot to speed up Manipulate[] *)
curvePlot = Replace[boundsArray,
{{x1_, x2_}, {y1_, y2_}} :> ContourPlot[f[x, y] == 0, {x, x1, x2}, {y, y1, y2}]];
(* Find all tangents of a given slope *)
Manipulate[
With[{sols = Solve[(* Solve or NSolve *)
{f[x, y] == 0, slope == ImplicitD[f[x, y] == 0, y, x],
boundsIneqs},
{x, y}]},
Show[curvePlot,
Graphics[{
Replace[sols, sol_ :> InfiniteLine[{x, y} /. sol, {1, slope}], 1]
}],
PlotRange -> Max@Abs@boundsArray
]
],
{{slope, 0}, -5, 5, 1/128}]
|
|
|
Michael, Thank you so much! That is great! I was thinking that something else that would be nice to have is a parameterization of the curve with a second slider to move a point around it, perhaps showing the tangent line at that point in red with all the other parallel tangents in black. (Your slider determines all tangents with a given slope. That would need to be turned off when using the second slider.) Can you extend your program to handle the seven examples with tangents that Shenghui used during the lesson, perhaps using a selection feature to choose among those eight functions (or others)?
[I tried just replacing the definition of f with the code for some of those examples (replacing "==" with "-"), and it crashed with error messages.] Can you extend your program to handle the Lissajou curves that I asked about in the original post? Those might need sliders (with just a few selected values) that are constructed to limit the complexity of the curves, so that you wouldn't end up with a multitude of parallel tangents.
|
|
|
Hi Gerald, It's not entirely straightforward to me. I was rather surprised that Mathematica found Shenghui's example so easy to solve. In general, you have to worry about unbounded curves, curves with multiple loops, self-intersecting curves (like Lissajous) and other singularities, and so on. Parametric has to be treated differently than implicit, and converting from one form to the other is not always easy. In general, each example needs to be worked on and tweaked. One might try to simplify some step, like fixing the bounding rectangle. Then one has to find examples that can be shown in the chosen rectangle. It's more work than I can put into it right now. Plus, for me, figuring out how to do the mathematics and how to express the mathematics in WL is the interesting bit. If that's how you feel, I suggest you take one of your examples and try to work it up. If you get stuck, post a question on the main community site so others will see it. Then I or someone else might be able to give you help. That way, you build your own knowledge.
|
|
|
Having said that, here's a Lissajous code. Replace the first two lines in my original code with the following:
lj = {Sin[5 t + Pi/2], Sin[2 t]} // TrigToExp // ReplaceAll[t -> I*Log[z]];
f[x_, y_] = First@GroebnerBasis[{x, y} - lj, {x, y}, {z}];
boundsArray = {{-1, 1}, {-1, 1}};
You can replace {Sin[5 t + Pi/2], Sin[2 t]} with your favorite Lissajous parametrization — unless Mathematica chokes on it. In the above example, you see no tangents of slope 0. It's one of those problems I alluded to that I don't have time for; you have to put in checks and fixes for the various issues that might arise.
|
|
|
Thank you for the nice question! Here is the code for generating the plot shown on the book cover:
RemoveBackground[
Rasterize[
Plot3D[{Re[Sqrt[1/(Cos[5 x] Sin[5 y] - 1/2)]],
Im[Sqrt[1/(Cos[5 x] Sin[5 y] - 1/2)]],
Style[.01, White, Lighting -> {{"Ambient", White}}]}, {x, -1/3,
1.33}, {y, -1/3, 1.6}, Axes -> False, Boxed -> False,
BoundaryStyle -> None, Exclusions -> All, Mesh -> None,
PlotPoints -> 35, PlotRange -> {Automatic, Automatic, {0, 4}},
ViewPoint -> {1.75, 2.25, 1.85}]]]
|
|
|
If I change the Plotrange to {0,6} or higher, the tops of the "volcanoes" get jagged around the edges. Do you happen to know why? 
|
|
|
In order to understand the difference in the two plots, you could try setting Exclusions ->None for both of them. The plot with PlotRange->{0, 4} is mostly smooth and setting Exclusions->All with a moderate setting of PlotPoints is enough to smooth out the singular behavior at the top. The plot with PlotRange->{0, 8} is very irregular and using Exclusions->All with a much higher setting of PlotPoints (say PlotPoints->500) is required to get a reasonably smooth plot at the top, but it may still be difficult to get the same kind of smooth surface that is seen with PlotRange->{0,4}.
|
|
|
Also entering set theory symbols from the keyboard-how to do? It is abstract sets whose elements are not given and sentences like "A is a subset of B", "element a belongs to B". I want to repeat the whole school math, but how is it better to do it - just solving tasks is pointless after all. But how to make a step by step solution knit, from which to start!?
|
|
|
Looking forward to this Daily Study Group with great instructors and an energetic group of learners! See everyone online on Monday, 11am CT. Preview the daily schedule of topics and sign up here.
|
|
|
Reply to this discussion
in reply to
|