#정적분의 활용
#속도와 거리에 대한 문제를 해결할 수 있다.
#49-2번
global answer
import random
from sage.symbolic.integration.integral import indefinite_integral
def problem_num():
var('t')
a = randint(1, 3)
b = randint(1, 5)
c = randint(1, 5)
while b == c or b > c:
b = randint(1, 5)
c = randint(1, 5)
f(t) = a*(t-b)*(t-c)
answer = integral(f(t), t, 0, b) - integral(f(t), t, b, c) + integral(f(t), t, c, 6)
return answer, t, a, b, c
def problem():
prob = problem_num()
answer = prob[0]
t = prob[1]
a = prob[2]
b = prob[3]
c = prob[4]
return answer, t, a, b, c
def problem_answer_list():
var('t')
prob = problem()
answer = prob[0]
t = prob[1]
a = prob[2]
b = prob[3]
c = prob[4]
answer_calc_list = []
random_answer_calc = random.randint(-10, 10)
while random_answer_calc == 0:
random_answer_calc = random.randint(-10, 10)
for i in range(4):
while random_answer_calc in answer_calc_list:
random_answer_calc = random.randint(-10, 10)
while random_answer_calc == 0:
random_answer_calc = random.randint(-10, 10)
answer_calc_list.append(random_answer_calc)
select_answer = [answer+answer_calc_list[0], answer+answer_calc_list[1], answer+answer_calc_list[2], answer+answer_calc_list[3], answer]
return [select_answer, answer, [t, a, b, c]]
def final_answer_list():
select_answer = problem_answer_list()
select_answer_list = select_answer[0]
answer = select_answer[1]
problem_number_list = select_answer[2]
return [select_answer_list, answer, problem_number_list]
final = final_answer_list()
select_answer_list = final[0]
answer = final[1]
problem_number_list = final[2]
t = problem_number_list[0]
a = problem_number_list[1]
b = problem_number_list[2]
c = problem_number_list[3]
f(t) = a*(t-b)*(t-c)
ff = plot(f(t), 0, b, fill=0) + plot(-f(t), b, c, fill=0) + plot(f(t), c, 6, fill=0) + plot(f(t), b, c, linestyle = "--")
random.shuffle(select_answer_list)
show(html("<p> 수직선 위를 움직이는 점 $P$ 의 시각 $t$ 에서의 속도가 $v(t) = %s$ 일 때, <br> 시각 $t=0$ 에서 $t=6$ 까지 점 $P$ 가 실제로 움직인 거리를 구하여라. </p>"%(latex(f(t).simplify_full()))))
sp = LatexExpr('\\quad')
spp = LatexExpr('\\qquad')
for i in range(len(select_answer_list)):
show("%s."%(i+1), sp, latex(expand(select_answer_list[i])))
@interact
def _(answers = selector([(None, ""), (select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False):
if answers == None:
show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>"))
else:
if answer == answers:
show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br> $t=0$ 에서 $t=6$ 까지 점 $P$ 가 실제로 움직인 거리는 <br> $\\int_{0}^{6}{|%s| dt} = \\int_{0}^{%s}(%s) dt + \\int_{%s}^{%s}(%s) dt + \\int_{%s}^{6}(%s) dt$ <br> $[%s]_{0}^{%s} + [%s]_{%s}^{%s} + [%s]_{%s}^{6} = %s + %s + %s = %s$ 이다."%(latex(f(t).simplify_full()), latex(b), latex(f(t).simplify_full()), latex(b), latex(c), latex(-f(t).simplify_full()), latex(c), latex(f(t).simplify_full()), latex(indefinite_integral(f(t), t)), latex(b), latex(indefinite_integral(-f(t), t)), latex(b), latex(c), latex(indefinite_integral(f(t), t)), latex(c), latex(integral(f(t), t, 0, b)), latex(integral(-f(t), t, b, c)), latex(integral(f(t), t, c, 6)), latex(answer))))
fl = open("record.txt",'w')
fl.write('success')
fl.close()
else:
show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br> $t=0$ 에서 $t=6$ 까지 점 $P$ 가 실제로 움직인 거리는 <br> $\\int_{0}^{6}{|%s| dt} = \\int_{0}^{%s}(%s) dt + \\int_{%s}^{%s}(%s) dt + \\int_{%s}^{6}(%s) dt$ <br> $[%s]_{0}^{%s} + [%s]_{%s}^{%s} + [%s]_{%s}^{6} = %s + %s + %s = %s$ 이다."%(latex(f(t).simplify_full()), latex(b), latex(f(t).simplify_full()), latex(b), latex(c), latex(-f(t).simplify_full()), latex(c), latex(f(t).simplify_full()), latex(indefinite_integral(f(t), t)), latex(b), latex(indefinite_integral(-f(t), t)), latex(b), latex(c), latex(indefinite_integral(f(t), t)), latex(c), latex(integral(f(t), t, 0, b)), latex(integral(-f(t), t, b, c)), latex(integral(f(t), t, c, 6)), latex(answer))))
fl = open("record.txt",'w')
fl.write('fail')
fl.close()
show(ff)
|
Click to the left again to hide and once more to show the dynamic interactive window
|