Skip to content

Update ti8 check it #465

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 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 81 additions & 31 deletions source/calculus/exercises/outcomes/TI/TI8/generator.sage
Original file line number Diff line number Diff line change
@@ -1,49 +1,99 @@
class Generator(BaseGenerator):
def data(self):
from sage.symbolic.integration.integral import definite_integral

x=var("x")
tasks = []

bs = sample([choice([-1,1])*n for n in range(2,10)],4)
bs = sample([choice([-1,1])*n for n in range(2,10)],5)

coeff = [2,3,4,5,6,7,8]

case1 = choice([0,1])

# converges with infinite bound
p = randrange(3,10)
q = randrange(2,p)
tasks.append({
"integrand": 1/(x-bs[0])^(SR(p)/q),
"converges": True,
"top": oo,
"bottom": bs[0]+randrange(1,6),
})
if case1 == 0:
p = randrange(3,10)
q = randrange(3,10)
bottom = bs[0] + randrange(1,6)
shuffle(coeff)
antidiff(x) = -1*(coeff[0]/coeff[1])/(x-bs[0])^(SR(p)/q)
tasks.append({
"integrand": antidiff(x).diff(x),
"converges": True,
"top": oo,
"bottom": bottom,
"proper": False,
"improper": True,
"int": 0-antidiff(bottom),
})

# diverges with infinite bound
p = randrange(2,9)
q = randrange(p+1,10)
tasks.append({
"integrand": 1/(x-bs[1])^(SR(p)/q),
"converges": False,
"top": oo,
"bottom": bs[1]+randrange(1,6),
})
if case1 == 1:
p = randrange(1,5)
q = randrange(p+1,p+5)
bottom = bs[1]+randrange(1,6)
shuffle(coeff)
antidiff(x) = choice([(coeff[0]/coeff[1])*(x-bs[1])^(SR(p)/q), (coeff[0]/coeff[1])*log(x-bs[1]) ])
tasks.append({
"integrand": antidiff(x).diff(x),
"converges": False,
"top": oo,
"bottom": bottom,
"proper": False,
"improper": True,
"int": r"\infty",
})

# converges with finite bounds
p = randrange(2,9)
q = randrange(p+1,10)
tasks.append({
"integrand": 1/(x-bs[2])^(SR(p)/q),
"converges": True,
"top": bs[2]+randrange(1,6),
"bottom": bs[2],
})
if case1 == 1:
case1 = randrange(0,2)
p = randrange(1,5)
q = randrange(p+1,p+5)
top = bs[2]+randrange(1,6)
shuffle(coeff)
antidiff(x) = (coeff[0]/coeff[1])*(x-bs[2])^(SR(p)/q)
tasks.append({
"integrand": antidiff(x).diff(x),
"converges": True,
"top": top,
"bottom": bs[2],
"proper": False,
"improper": True,
"int": antidiff(top),
})

# diverges with finite bounds
if case1 == 0:
p = randrange(3,10)
q = randrange(3,10)
top = bs[3]+randrange(1,6)
shuffle(coeff)
antidiff(x) = choice([-1*(coeff[0]/coeff[1])/(x-bs[3])^(SR(p)/q), (coeff[0]/coeff[1])*log(x-bs[3]) ])
tasks.append({
"integrand": 1/(x-bs[3])^(SR(p)/q),
"converges": False,
"top": top,
"bottom": bs[3],
"proper": False,
"improper": True,
"int": r"\infty",
})


# proper
p = randrange(3,10)
q = randrange(2,p)
q = randrange(3,10)
bottom = bs[4]+randrange(1,6)
top = bottom + randrange(1,6)
tasks.append({
"integrand": 1/(x-bs[3])^(SR(p)/q),
"converges": False,
"top": bs[3]+randrange(1,6),
"bottom": bs[3],
})
"integrand": 1/(x-bs[4])^(SR(p)/q),
"converges": True,
"top": top,
"bottom": bottom,
"proper": True,
"improper": False,
})

shuffle(tasks)

Expand Down
17 changes: 8 additions & 9 deletions source/calculus/exercises/outcomes/TI/TI8/template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
<knowl mode="exercise" xmlns="https://spatext.clontz.org" version="0.2">
<intro>
<p>
Explain and demonstrate how to write each of the following improper integrals
as a limit, and why this limit converges or diverges.
For each of the following integrals, identify if the integral is proper or improper. If improper, then compute the integral by finding the antiderivative, using the fundamental theorem of calculus, and computing the limit.
</p>
</intro>
<!-- {{#tasks}} -->
<knowl>
<content><p><m>\displaystyle\int_{ {{bottom}} }^{ {{top}} } {{integrand}} dx.</m></p></content>
<content><p><m>\renewcommand{\log}{\ln} \displaystyle\int_{ {{bottom}} }^{ {{top}} } {{integrand}} dx.</m></p></content>
<outtro>
<!-- {{#converges}} -->
<p>Converges.</p>
<!-- {{/converges}} -->
<!-- {{^converges}} -->
<p>Diverges.</p>
<!-- {{/converges}} -->
<!-- {{#proper}} -->
<p>This integral is proper.</p>
<!-- {{/proper}} -->
<!-- {{^proper}} -->
<p><m>\renewcommand{\log}{\ln} \displaystyle\int_{ {{bottom}} }^{ {{top}} } {{integrand}} dx = {{int}}.</m></p>
<!-- {{/proper}} -->
</outtro>
</knowl>
<!-- {{/tasks}} -->
Expand Down
Loading