Skip to content

Sage images for CO, SQ, and PS #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 24, 2024
47 changes: 10 additions & 37 deletions source/calculus/source/03-AD/02.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -51,43 +51,16 @@ Notice that this is obtained by writing the tangent line to <m>f(x)</m> at <m>(a
<task><p>Sketch the tangent line <m>L(x)</m> on the same plane as the graph of <m>\ln(x)</m>. What do you notice?
</p>
<figure>
<image width="50%" xml:id="graph-tangent-line-plane-ln">
<latex-image>
\begin{minipage}{\textwidth}
\begin{center}
\begin{tikzpicture}[scale=0.9]
\begin{axis}[
axis lines=middle,
grid=major,
xmin=0, xmax=5,
ymin=-2, ymax=2,
% xtick={0,10,...,80},
% ytick={0,10,...,50},
% yticklabels={0, 0.01, 0.02, 0.03, 0.04, 0.05},
tick style={thick},
% x label style={at={(axis description cs:1,0.7)}},
% y label style={at={(axis description cs:0.4,1)}},
ylabel=$y$,
xlabel=$x$,
]
\addplot[domain=0.1:5, blue, ultra thick] {ln(x)} node [pos=0.8,above left , ultra thick] {$\boldsymbol{\ln(x)}$};
% \addplot [only marks, blue] table {
% 40 20
% };
% \addplot[only marks, color=blue, nodes near coords={$(40,20)$}] coordinates {(30,20)};
% \addplot[domain=20:70, black, thick] {(x-40)+20} node [pos=0.6, below right, ultra thick] {$\boldsymbol{L(x)}$};
% \addplot [only marks, black] table {
% 20 0
% };
% \addplot[only marks, color=black, nodes near coords={$(20,0)$}] coordinates {(30,0)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{minipage}
</latex-image>
</image>
<caption>The graph of <m> \ln(x)</m></caption>
</figure>
<image width="50%" xml:id="graph-tangent-line-plane-ln">
<sageplot>
x = var('x')
f = ln(x)
p = plot(f,(x,0.1,5), gridlines=True, axes_labels=('$x$','$y$'), thickness=2, aspect_ratio = 1.25)
p
</sageplot>
</image>
<caption>The graph of <m> \ln(x)</m></caption>
</figure>
</task>
</activity>

Expand Down
87 changes: 56 additions & 31 deletions source/calculus/source/03-AD/04.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,15 @@
</p>

<figure xml:id="height-function">
<image width="50%" xml:id="graph-parabolic-height-function">
<latex-image>
\begin{tikzpicture}[scale=1]
\begin{axis}[
samples = 900,
axis lines=middle,
grid=major,
% xmin=0, xmax=4,
ymin=0, ymax=70,
% xtick={0,0.5,...,4},
% ytick={-2,-1,...,10},
% tick style={thick},
% x label style={at={(axis description cs:1,0.7)}},
% y label style={at={(axis description cs:0.4,1)}},
ylabel=$s(t)$,
xlabel=$t$,
]
\addplot[domain=0:3, blue, thick] {-16*x^2+32*x+48};
\end{axis}
\end{tikzpicture}

</latex-image>
</image>
<caption>The graph of <m>s(t) = -16t^2 + 32t + 48</m></caption>
<image width="50%" xml:id="graph-parabolic-height-function">
<sageplot>
x = var('x')
f = -16*x^2+32*x+48
p = plot(f,(x,0,3), gridlines=True, axes_labels=('$t$','$s(t)$'), thickness=2, aspect_ratio = .05)
p
</sageplot>
</image>
<caption>The graph of <m>s(t) = -16t^2 + 32t + 48</m></caption>
</figure>
</example>

Expand Down Expand Up @@ -101,22 +86,62 @@
<p>For each of the following figures, decide where the global extrema are located.</p>
</introduction>
<task>
<figure xml:id="figure-evt-int">
<image width="25%" source="evt_int.png" />
<!-- <caption>A.</caption> -->
<figure xml:id="figure-evt-int">
<image width="25%">
<sageplot>
x = var('x')
f = sin(x)
ticks = [[-pi/2, 0, pi/2, pi, 3*pi/2, 2*pi, 5*pi/2],[-1.5,-1,-0.5,0,0.5,1,1.5]]
p = plot(f,(x,0,2*pi), xmin = -pi/2, xmax = 5*pi/2, ymin = -1.5, ymax=1.5, ticks=ticks, tick_formatter=[pi,None], thickness=2, gridlines=True, aspect_ratio=1.5)
c1 = circle((0,0),0.05,fill=True)
c2 = circle((2*pi,0),0.05,fill=True)
p+c1+c2
</sageplot>
</image>
<!-- <caption>A.</caption> -->
</figure>
</task>
</task>
<task><figure xml:id="figure-evt-endpoints">
<image width="25%" source="evt_endpts.png" />
<image width="25%">
<sageplot>
x=var('x')
f(x) = exp(-x) + 1
p = plot(f,(x,0,3), ymin = -1, ymax = 3, gridlines=True, thickness=2, aspect_ratio=1)
q = plot(4,(x,-1,4), ymin=-1, ymax=3, gridlines=True, thickness=2, aspect_ratio=1)
c1 = circle((0,f(0)), 0.05, fill=True)
c2 = circle((3,f(3)),0.05, fill=True)
p+c1+c2+q
</sageplot>
</image>
<!-- <caption>B.</caption> -->
</figure></task>
<task><figure xml:id="figure-evt-mixed">
<image width="25%" source="evt_mixed.png" />
<image width="25%">
<sageplot>
x=var('x')
f(x) = -x^3+2*x^2
c1 = circle((-0.5,f(-0.5)),0.05,fill=True)
c2 = circle((2.2,f(2.2)),0.05,fill=True)
p = plot(f,(x,-0.5,2.2),ymin=-2,ymax=2,thickness=2,gridlines=True,aspect_ratio=1)
q = plot(3,(x,-1,3),ymin=-2,ymax=2,aspect_ratio=1)
c1+c2+p+q
</sageplot>
</image>
<!-- <caption>C.</caption> -->
</figure></task>
<task>
<figure xml:id="figure-evt-mixed2">
<image width="25%" source="evt_mixed2.png" />
<image width="25%">
<sageplot>
x=var('x')
f(x) = abs(-(x-1)^(1/3))
c1 = circle((0,f(0)),0.05,fill=True)
c2 = circle((3,f(3)),0.05,fill=True)
p = plot(f,(x,0,3),ymin=-1,ymax=2,thickness=2,gridlines=True,aspect_ratio=1)
q = plot(3,(x,-1,3.5),ymin=-1,ymax=2,aspect_ratio=1)
c1+c2+p+q
</sageplot>
</image>
<!-- <caption>D.</caption> -->
</figure>
</task>
Expand Down
113 changes: 106 additions & 7 deletions source/calculus/source/03-AD/06.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,36 @@

<figure xml:id="concavity-1">
<caption>Three increasing functions</caption>
<image width="100%" source="concavity-1" />
<sidebyside widths = "30% 30% 30%">
<image xml:id="concavity-1-down">
<sageplot>
x = var('x')
f = 2*exp(4*x-3)
ticks=[[],[]]
p = plot(f,(x,.2,1), xmin = -10, xmax = 1, ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.2)
p
</sageplot>
</image>
<image xml:id="concavity-1-none">
<sageplot>
x = var('x')
f = x+.75
ticks=[[],[]]
p = plot(f,(x,.05,1), xmin = -10, xmax = 1, ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
<image xml:id="concavity-1-up">
<sageplot>
x = var('x')
f = (x-1.5)^3+2.5
ticks=[[],[]]
p = plot(f,(x,.25,1.25), ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
</sidebyside>

</figure>
</introduction>
<task>
Expand Down Expand Up @@ -91,7 +120,35 @@
</p>
<figure xml:id="concavity-2" permid="PJf">
<caption>From left to right, three functions that are all decreasing.</caption>
<image width="100%" source="concavity-2" />
<sidebyside widths="30% 30% 30%">
<image xml:id="concavity-2-up">
<sageplot>
x = var('x')
f = -(x-1.5)^3+.5
ticks=[[],[]]
p = plot(f,(x,.25,1.25), ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
<image xml:id="concavity-2-none">
<sageplot>
x = var('x')
f = -2*x + 3
ticks = [[],[]]
p = plot(f, (x,.25, 1.25), ymin = -1, ymax = 3, gridlines=True, thickness=2, ticks=ticks, aspect_ratio = 0.25)
p
</sageplot>
</image>
<image xml:id="concavity-2-down">
<sageplot>
x = var('x')
f = -(x)^3+2.5
ticks=[[],[]]
p = plot(f,(x,.25,1.25), ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
</sidebyside>
</figure>

</introduction>
Expand Down Expand Up @@ -148,12 +205,54 @@
<activity xml:id="activity-derivative-concavity3a">
<statement><p>Look at in <xref ref="concavity-3"/>. Which curve is concave up? Which one is concave down? Why? Try to explain using the graph!</p>

<figure xml:id="concavity-3" permid="vQo">
<caption>Two concavity, which is which? </caption>
<image width="90%" source="concavity-3" />
</figure>
<figure xml:id="concavity-3" permid="vQo">
<caption>Two concavities, which is which? </caption>
<sidebyside widths="45% 45%">
<image>
<sageplot>
x = var('x')
f(x) = (x-1)^2 + 1
line1 = -3*(x+0.5)+f(-0.5)
line2 = -1*(x-0.5)+f(0.5)
line3 = (x-1.5)+f(1.5)
line4 = 3*(x-2.5)+f(2.5)
p1 = plot(f,(x,-1,3), ymin = 0, ymax = 6, gridlines=True,thickness=2, aspect_ratio=1)
p2 = plot(line1,(x,-.75,-.25), color="green", thickness=2.5)
p3 = plot(line2,(x,.25,.75), color="green", thickness=2.5)
p4 = plot(line3,(x,1.25,1.75), color="green", thickness=2.5)
p5 = plot(line4,(x,2.25,2.75), color="green", thickness=2.5)
c1 = circle((-.5,f(-.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c2 = circle((.5,f(.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c3 = circle((1.5,f(1.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c4 = circle((2.5,f(2.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
p1+p2+p3+p4+p5+c1+c2+c3+c4
</sageplot>
</image>
<image>
<sageplot>
x = var('x')
f(x) = -(x-1)^2 +2
line1 = 3*(x+0.5)+f(-0.5)
line2 = 1*(x-0.5)+f(0.5)
line3 = -(x-1.5)+f(1.5)
line4 = -3*(x-2.5)+f(2.5)
p1 = plot(f,(x,-1,3), ymin = -3, ymax = 3, gridlines=True,thickness=2, aspect_ratio=1)
p2 = plot(line1,(x,-.75,-.25), color="green", thickness=2.5)
p3 = plot(line2,(x,.25,.75), color="green", thickness=2.5)
p4 = plot(line3,(x,1.25,1.75), color="green", thickness=2.5)
p5 = plot(line4,(x,2.25,2.75), color="green", thickness=2.5)
c1 = circle((-.5,f(-.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c2 = circle((.5,f(.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c3 = circle((1.5,f(1.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
c4 = circle((2.5,f(2.5)),0.1,fill=True,facecolor="red", aspect_ratio="automatic")
p1+p2+p3+p4+p5+c1+c2+c3+c4
</sageplot>
</image>
</sidebyside>

</figure>

</statement></activity>
</statement></activity>

<definition xml:id="concavity-and-first-derivative" permid="hcP">
<statement>
Expand Down
24 changes: 20 additions & 4 deletions source/calculus/source/03-AD/07.ptx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@
Which of the following features best describe the curve graphed below? </p>


<figure xml:id="dec-cdown">
<figure xml:id="dec-cdown">
<!-- <caption>A curve</caption> -->
<image width="30%" source="dec-cdown.png" />
</figure>
<image width="30%">
<sageplot>
x = var('x')
f = -(x)^3+2.5
ticks=[[],[]]
p = plot(f,(x,.25,1.25), ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
</figure>
</introduction>


Expand All @@ -47,7 +55,15 @@

<figure xml:id="inc-cdown">
<!-- <caption>A curve</caption> -->
<image width="30%" source="inc-cdown.png" />
<image width="30%">
<sageplot>
x = var('x')
f = (x-1.5)^3+2.5
ticks=[[],[]]
p = plot(f,(x,.25,1.25), ymin = -1, ymax = 3, gridlines=True,thickness=2, ticks=ticks, aspect_ratio=.25)
p
</sageplot>
</image>
</figure>


Expand Down
Loading
Loading