# -*- coding:utf-8 -*- import random, hashlib import requests import configs from utils.diffi_label import get_item_diff from utils.img2latex import get_ocrlatex_by_url from utils.qcloud_bucket import upload_img_to_qcloud, img_inbucket_count, client, filestream_upload from concurrent.futures import ProcessPoolExecutor from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor from utils.image_convert import svg2png from utils.label_data_Hphy import Label import re, time, os, json, datetime logger = configs.myLog(__name__, log_cate="ruku_log").getlog() class Ruku: def __init__(self, items_list, htmlt, svg_data, wordid, callback_url="", subject=""): self.items_list = items_list self.htmlt = htmlt self.svg_data = svg_data self.wordid = wordid self.callback_url = callback_url self.subject = subject def bucket_img_del(self): """ wordbin中图片上传腾讯云的原因:1.存在线上服务器的图片要定期删除,而有的题可能还没审核完;2.上传腾讯云比较便宜 删除腾讯云中的图片 根据【解析结果】文本中删除的图片信息,通过阙值判断是否从腾讯云中删除图片 也有限制:解析结果不能为空,结果中出现的图片在原试卷应该也要有! :return: """ items_str = str(self.items_list) raw_imgs = [] # img_source = "" http://zxhx-1302712961.cos.ap-shanghai.myqcloud.com/imgpaper/lqy_upload/612f60307ddb8b2765e50512/img_23.png items_str = re.sub(r'( 5: # 多余图片超过5张才开始删除,包含mathjax生成的图片 bucket_imgs = [i['Key'] for i in bucket_imgs] # dict:[{'Key': put_key}, {}] to_del_imgs = [bimg for bimg in bucket_imgs if bimg not in raw_imgs] if to_del_imgs: objects = { "Quiet": "true", "Object": [{'Key': item} for item in to_del_imgs] } client.delete_objects(configs.public_bucket, objects) # 批量删除 logger.info("----【word_id:{}】删除桶数据时间:{}".format(self.wordid, time.time() - time2)) def mathjx2png(self): """ 【基于mathjax渲染输出是svg格式】 将mathjax渲染的公式转化为图片格式 mathjax渲染的svg图片提取->保存->格式转化 :return: """ file_path = configs.IMG_FOLDER + "/" + str(self.wordid) svgp_ltx = {} # svg图片本地路径 映射 latex put_key_mjmath = [] # 桶中key local_mjmath = [] # 本地图片存储位置 self.ltx2url = {} # latex 映射 线上可访问url ltx2svgcss = {} # latex 映射 svg-css if self.callback_url and "MathJax" in str(self.svg_data["svg_html_data"]): # 再解析中存在mathjax公式渲染的标签 time3 = time.time() all_mathjax = re.findall('(()*)', str(self.svg_data["svg_html_data"])) all_linkdata = re.findall('()', self.svg_data["svg_path"]) link_dict = {a[1]: a[0] for a in all_linkdata if a} # all_svg, all_latex = [], [] for n, jax in enumerate(all_mathjax): svgs = re.findall("", jax[0]) latex = re.findall(''.format( shape[0] / 2, shape[1] / 2, "${}$".format(mj_ltx)) self.ltx2url[mj_ltx] = mjmath_online logger.info("----【word_id:{}】svg2png 时间:{}".format(self.wordid, time.time() - time4)) logger.info("----【word_id:{}】ltx2url:{}".format(self.wordid, self.ltx2url)) return put_key_mjmath, local_mjmath def upload_img(self): """ items_list:结构化纯文本 htmlt:ocr或word解析后的html文本 svg_data:{"svg_html_data": "", "svg_path": ""} 含svg数据的结构化整体html文本,svg中的索引数据 wordid:试卷存储id callback_url: 回调地址 入库操作包含: 1、再解析后确认入库时,将image上传,htmlt中图片; 2、学管端可以是组合(文本+图片)的解析结果。学管可以选择和修改文本,但选择的文本解析时都会替换原先的img标签内容, 最后入库时,传回学管端的都是带img标签的结果 3、传回学管端和共享题库的题目中的$$公式要转换为图片; $$左右还有公式字符串的话,在结构化过程中一起并入!!! 4、调取查重关联功能,没有重题时再调自动标注; 5、传入校本题库(发送标注),将结构化后的每道题设置个与大数据资源库的关联标签,如"zyk_id":id+题号 5种图片:1>>ser_static/.*?/word/media(解析服务中最开始保存在线上服务器本地) 2>>/zyk/uploadfiles/wording/(解析服务中上传到腾讯云) 3、4>>ser_static/.*?/(new_image[^"]*?|eq_img_\d.png):批量再解析和单题再解析中, 用户在编辑页面新粘贴进来的base64图片,以及批量再解析中域公式转图片,临时存在结构化服务器本地 5、利用mathjax渲染latex的svg格式转为png,再上传到腾讯云 上传之前,将腾讯云桶里的new_image全部替换,raw_image判断下再替换 items_list:list 所有题目 :return: res_zyk = {"data":{"html": xxx, "items": xxx}, "errcode": 0, "errmsgs": ""} res_xbk = {"items": xxx, "errcode": 0, "errmsg":"ok"} """ if not self.items_list: return {"errcode":1, "errmsgs": "无结果,不能入库", "data":{}} # if any([True if "stem_img" not in i and "stem" not in i else False # for i in self.items_list]): # 存在新增的空试题时,只有3个字段type,img_status,check_type # return {"errcode":1, "errmsgs": "存在空试题,请检查!", "data":{}} for i in self.items_list: if "stem_img" not in i and "stem" not in i: return {"errcode": 1, "errmsgs": "存在空试题,请检查!", "data": {}} # elif "errmsgs" in i and i["errmsgs"]: # return {"errcode": 1, "errmsgs": "存在报错试题还没改正过来,请检查!", "data": {}} res_xbk = {"items": [], "errcode": 0, "errmsg":"ok", "callback_type":2} res_zyk = {"errcode": 0, "errmsgs": "", "data": {"html": self.htmlt, "items": self.items_list}} # 1>>判断删除腾讯云桶内图片 self.bucket_img_del() # --------------------------------------------------------------------- # 1.2>>将zyk/uploadfiles/wording/ 路径的缺latex的公式图片,再调mathpix接口拿到latex填充 # 2>>mathjax渲染的svg图片提取->保存->格式转化 put_key_mjmath, local_mjmath = self.mathjx2png() # -------------------------------------------------------------------- # 3>> 统计结构化试题data-latex为空的图片,再ocr-latex处理并替换 # time5 = time.time() # items_str = str(self.items_list) # all_imgs_no_latex = re.findall(r'(> 统计 ocr和结构化试题 中的新图片,以防结构化入库的试题少了而导致图片上传不足,左边页面无法显示 put_key_list = [] # 桶中key localnewpic_list = [] # 本地图片存储位置 new_imgs = re.findall(r'> 结构化题目中图片地址替换,需要区分下学管端还是云题库!!!!!一定会保存一份在资源库 items_res_to_zyk = self.items_list.copy() for one_items in items_res_to_zyk: for k in ["stem", "key", "parse", "options"]: # "analysis", if k in one_items: if k == "options": one_items[k] = list(map(sub1, one_items[k])) else: one_items[k] = sub1(one_items[k]) # -----------难度和知识点自动标注------------------------ t11 = time.time() diffs_xbk = [3] * len(items_res_to_zyk) if self.subject == "高中数学": from multiprocessing.dummy import Pool as ThreadPool pool = ThreadPool(2) # 比# pool = multiprocessing.Pool(3)速度快 diff_info = list(pool.map(get_item_diff, items_res_to_zyk)) items_res_to_zyk = [f[0] for f in diff_info] diffs_xbk = [f[1] for f in diff_info] logger.info("----【word_id:{}】结构化试题中难度标注时间:{}".format(self.wordid, time.time() - t11)) # items_res_to_xbk = items_res_to_zyk.copy() # if self.callback_url and self.ltx2url: for nn, one_items in enumerate(items_res_to_zyk): new_one_item = {"difficulty": diffs_xbk[nn], "knowledge": {}} if self.callback_url: new_one_item["topic_type_id"] = one_items["checkType"]["id"] if "options_rank" in one_items: new_one_item["options_rank"] = one_items["options_rank"] # if one_items["checkType"]["name"] == "填空题": # new_one_item["blank_num"] = one_items["blank_num"] keys_items = ["stem", "key", "parse", "options"] if one_items['img_status'] == 1 and ("stem_img" in one_items and one_items["stem_img"]): logger.info("----【word_id:{}】mathjax2svg所取的字段是带img的".format(self.wordid)) keys_items = ["stem_img", "key_img", "parse_img", "options_img"] for k in keys_items: if self.callback_url and self.ltx2url: if k in one_items: if k in ["options", "options_img"]: one_items[k] = list(map(sub2, one_items[k])) else: one_items[k] = sub2(one_items[k]) else: logger.info("----【word_id:{}】第{}道题{}字段有问题".format(self.wordid, one_items["topic_num"], k)) if k in one_items: new_one_item[k.replace("_img", "")] = one_items[k] # if self.subject == "高中物理": # temp_items = {"topic_id": one_items["topic_num"]} # temp_items["content"] = new_one_item["stem"] # temp_items["parse"] = str(new_one_item["key"]) + "
" + new_one_item["parse"] + "
" + \ # new_one_item["analysis"] # temp_items["option"] = new_one_item["options"] if "options" in new_one_item else [] # auto_kps = self.get_phy_kps_auto(temp_items) # # print("自动标注考点:", auto_kps) # new_one_item["knowledge"] = auto_kps items_res_to_xbk.append(new_one_item) # 5>> ocr-htmlt中图片地址替换成云上地址 self.htmlt = re.sub(r'(> new_image上传腾讯云 try: logger.info('----【word_id:{}】再解析开始上传图片到cloud,并替换成线上地址----'.format(self.wordid)) stime_u = time.time() # TODO 一个进程解析,一个进程上传 executor1 = ProcessPoolExecutor(5) executor1.map(upload_img_to_qcloud, zip(put_key_list, localnewpic_list)) executor1.shutdown(wait=True) # 进程池内部的进程都执行完毕,才会关闭,然后执行后续代码 img_upload_time = time.time() - stime_u logger.info("----【word_id:{}】再解析图片上传时间img_upload_time:{}".format(self.wordid, img_upload_time)) res_zyk = {"data":{"html":self.htmlt, "items":items_res_to_zyk}, "errcode":0, "errmsgs": ""} res_xbk = {"items": items_res_to_xbk, "errcode": 0, "errmsg":"ok", "callback_type":2} except: res_xbk = {"items": [], "errcode": 1, "errmsg": "公式或图片上传腾讯云失败", "callback_type":2} res_zyk = {"data":{"html": self.htmlt, "items": self.items_list}, "errcode": 1, "errmsgs": "公式或图片上传腾讯云失败"} logger.info("----【word_id:{}】公式或图片上传腾讯云失败".format(self.wordid)) else: # -----------难度、知识点自动标注------------------------ t11 = time.time() diffs_xbk = [3] * len(self.items_list) if self.subject == "高中数学": from multiprocessing.dummy import Pool as ThreadPool pool = ThreadPool(2) # 比# pool = multiprocessing.Pool(3)速度快 diff_info = list(pool.map(get_item_diff, self.items_list)) self.items_list = [f[0] for f in diff_info] diffs_xbk = [f[1] for f in diff_info] logger.info("----【word_id:{}】结构化试题中难度标注时间:{}".format(self.wordid, time.time() - t11)) for nn, one_items in enumerate(self.items_list): new_one_item = {"difficulty": diffs_xbk[nn], "knowledge": {}} if self.callback_url: new_one_item["topic_type_id"] = one_items["checkType"]["id"] if "options_rank" in one_items: new_one_item["options_rank"] = one_items["options_rank"] keys_items = ["stem", "key", "parse", "options"] if one_items['img_status'] == 1 and ("stem_img" in one_items and one_items["stem_img"]): logger.info("----【word_id:{}】mathjax2svg所取的字段是带img的".format(self.wordid)) keys_items = ["stem_img", "key_img", "parse_img", "options_img"] for k in keys_items: if k in one_items: new_one_item[k.replace("_img", "")] = one_items[k] # 知识点自动标注 # if self.subject == "高中物理": # temp_items = {"topic_id": one_items["topic_num"]} # temp_items["content"] = new_one_item["stem"] # temp_items["parse"] = str(new_one_item["key"]) + "
" + new_one_item["parse"] + "
" + \ # new_one_item["analysis"] # temp_items["option"] = new_one_item["options"] if "options" in new_one_item else [] # auto_kps = self.get_phy_kps_auto(temp_items) # # print("自动标注考点:", auto_kps) # new_one_item["knowledge"] = auto_kps items_res_to_xbk.append(new_one_item) res_xbk = {"items": items_res_to_xbk, "errcode": 0, "errmsg":"ok", "callback_type":2} # 先传一份到校本题库,再返回结果 if self.callback_url: # 上传腾讯云失败,将结果保存本地一份 self.save_post_file(res_xbk) try: r = requests.post(self.callback_url, # json=res, # 可以,但是会进行转义 data=json.dumps(res_xbk, ensure_ascii=False).encode("utf-8"), # 文件开头有编码显示 # headers=headers, ) logger.info("------【word_id:{}】,post 回调地址状态===> {} -------\n".format(self.wordid, r.status_code)) except TimeoutError: # print("回调超时") logger.info("------【word_id:{}】回调超时-------".format(self.wordid)) except Exception as e: # print(e, "------回调出错") logger.info("------【word_id:{}】回调出错:{}-------".format(self.wordid, e)) return res_zyk def upload_img_with_stream(self): """ 图片以文件流形式上传腾讯云 :return: """ if not self.items_list: return {"errcode":1, "errmsgs": "无结果,不能入库", "data":{}} if any([True for i in self.items_list if len(i)==1]): # 存在新增的空试题时,只有一个type字段 return {"errcode":1, "errmsgs": "存在空试题,请检查!", "data":{}} res_xbk = {"items_res": self.items_list, "errcode": 0} res_zyk = {"errcode":0, "errmsgs": "", "data":{"html": self.htmlt, "items": self.items_list}} # 1>>判断删除腾讯云桶内图片 self.bucket_img_del() # 1.2>>将zyk/uploadfiles/wording/ 路径的缺latex的公式图片,再调mathpix接口拿到latex填充 # 2>>mathjax渲染的svg图片提取->保存->格式转化 put_key_mjmath, local_mjmath = self.mathjx2png() # -------------------------------------------------------------------- # 3>> 统计 ocr和结构化试题 中的新图片,以防结构化入库的试题少了而导致图片上传不足,左边页面无法显示 put_key_list = [] # 桶中key # localnewpic_list = [] # 本地图片存储位置 imgs_url = [] # 存在线上服务器本地的线上可访问地址 new_imgs = re.findall(r'> 结构化题目中图片地址替换,需要区分下学管端还是云题库!!!!!一定会保存一份在资源库 items_res_to_zyk = self.items_list.copy() for one_items in items_res_to_zyk: for k in ["stem", "key", "parse", "analysis", "options"]: if k in one_items: if k == "options": one_items[k] = list(map(sub1, one_items[k])) else: one_items[k] = sub1(one_items[k]) items_res_to_xbk = items_res_to_zyk.copy() if self.callback_url and self.ltx2url: # items_res_to_xbk = items_res_to_zyk.copy() for one_items in items_res_to_xbk: keys_items = ["stem", "key", "parse", "analysis", "options"] if one_items['img_status'] == 1 and ("stem_img" in one_items and one_items["stem_img"].strip()): keys_items = ["stem_img", "key_img", "parse_img", "options_img"] for k in keys_items: if k in one_items: if k == "options": one_items[k] = list(map(sub2, one_items[k])) else: one_items[k] = sub2(one_items[k]) # ----------------------------------------------------------------------- # 5>> ocr-htmlt中图片地址替换成云上地址 self.htmlt = re.sub(r'(> new_image上传腾讯云 try: logger.info('----【word_id:{}】再解析开始上传图片到cloud,并替换成线上地址----'.format(self.wordid)) stime_u = time.time() # TODO 一个进程解析,一个进程上传 executor1 = ProcessPoolExecutor(5) if self.callback_url: executor1.map(upload_img_to_qcloud, zip(put_key_mjmath, local_mjmath)) executor1.map(filestream_upload, zip(put_key_list, imgs_url)) executor1.shutdown(wait=True) # 进程池内部的进程都执行完毕,才会关闭,然后执行后续代码 img_upload_time = time.time() - stime_u logger.info("----【word_id:{}】再解析图片上传时间img_upload_time:{}".format(self.wordid, img_upload_time)) res_zyk = {"data":{"html":self.htmlt, "items":items_res_to_zyk}, "errcode":0, "errmsgs": ""} # res_xbk = {"items_res": items_res_to_xbk, "errcode": 0, "errmsgs": ""} # res_zyk = {"html": self.htmlt, "items": items_res_to_xbk, "errcode": 0} except: # res_xbk = {"items_res": self.items_list, "errcode": 1, "errmsgs": "公式或图片上传腾讯云失败"} logger.info("----【word_id:{}】公式或图片上传腾讯云失败".format(self.wordid)) res_zyk = {"data":{"html": self.htmlt, "items": self.items_list}, "errcode": 1, "errmsgs": "公式或图片上传腾讯云失败"} # 先传一份到校本题库,再返回结果 # if callback_url: # 上传腾讯云失败,将结果保存本地一份 # self.save_post_file(res_xbk) # try: # r = requests.post(callback_url, # # json=res, # 可以,但是会进行转义 # data=json.dumps(res_xbk).encode("utf-8"), # 文件开头有编码显示 # # headers=headers, # ) # logger.info("------【word_id:{}】,post 回调地址状态===> {} -------\n".format(self.wordid, r.status_code)) # except TimeoutError: # # print("回调超时") # logger.info("------【word_id:{}】回调超时-------".format(self.wordid)) # except Exception as e: # # print(e, "------回调出错") # logger.info("------【word_id:{}】回调出错:{}-------".format(self.wordid, e)) return res_zyk def save_post_file(self, parse_res): """保存回调的数据解析结果""" now_time = datetime.datetime.now() time_str = datetime.datetime.strftime(now_time, '%Y_%m_%d_%H_%M_%S') # aft_modify = (str("word_name") + '__' + str(random.random())).encode("utf-8") # hh = hashlib.md5(aft_modify).hexdigest() aft_name = self.wordid + '__' + time_str + '.json' res_folder = configs.RES_FOLDER # 保存的文件夹 new_fpath = os.path.join(res_folder, aft_name) re_f = open(new_fpath, 'w', encoding='utf-8') json.dump(parse_res, re_f,ensure_ascii=False) def get_phy_kps_auto(self, item): """ 调取物理自动标注的端口获取考点 :return: """ kps_id = [] kps_name = [] if item: r = requests.post("http://49.232.72.198:11088/phy_kpl/", json={'data': item}) if r.status_code == 200: res = eval(r.text)['all'] if res: kps_id.extend(res) kps_name.extend([Label().id2kps_phy.get(i, "") for i in res]) if kps_id: return {"knowledge_id": kps_id, "knowledge_name": kps_name} else: return {} if __name__ == '__main__': from pprint import pprint items_list = [{'id': '60bdcd734a5335001b0a73cf', 'type': '填空题', 'stem': '在数列\\({\\lbrace a_{n}\\rbrace }\\)中,若\\({a_{1}=1,a_{n}-a_{n-1}=n(n\\geq 2),}\\)则该数列的通项\\({a_{n}=}\\)', 'options': [], 'key': '\\( \\frac{1}{2} \\) \n ', 'subject': '数学', 'errmsgs': '', 'topic_num': 0, 'parse_img': '略', 'analysis': '', 'slave_img': '', 'parse': '略 \n \n ', 'category': ['月考'], 'grade': '高一', 'stem_img': "", 'period': '高中', 'province': '湖北', 'susp_pic': None, 'option_str': '', 'blank_num': None, 'year': 2020, 'difficulty': '中', 'specials': [], 'upload_time': '2021-07-16T13:51:49.561000Z', 'key_img': "", 'options_img': [], 'options_rank': None, 'text_status': None, 'img_status': 1, 'source': {'type': 's', 'related_exampaper': [{'paper_id': '5fc0d256407550d0b7d9a43c', 'file_name': '十堰市一中 2019 级高一下4月月考 数学试题包含答案 ', 'item_id': None}]}}] ocr_html = r'数学
命题人:王旭辉
一、选择题(本大题共12小题,每小题5分,请将正确答案填涂在答题卡相应的位置。)
1.cos80°sin40°+sin50°cos10°的值为()
A.${\quad \frac{1}{2}}$B.${\quad \frac{\sqrt {2}}{2}}${c.\quad \frac{\sqrt {3}}{2}}${b.\quad -\frac{\sqrt {3}}{2}}$
2.已知在等比数列${\lbrace a_{n}\rbrace }$中,${a_{1}=1,\quad a_{5}=9,}${a_{3}=(\quad }$
B.±5.±3D.3
3.已知a>b>0,则下列不等式成立的是()
A.${\quad a>b>\frac{a+b}{2}>\sqrt {ab}}$B.${\quad a>\frac{a+b}{2}>\sqrt {ab}>b}$
${c.\quad a>\frac{a+b}{2}>b>\sqrt {ab}}$D.${\quad a>\sqrt {ab}>\frac{a+b}{2}>b}$
4.给出下列命题:
①棱柱的侧棱都相等,侧面都是全等的平行四边形;
②用一个平面去截棱锥,棱锥底面与截面之间的部分是棱台;
③半圆绕着它的直径所在的直线旋转一周所形成的曲面叫做球面;
④棱台的侧棱延长后交于一点,侧面是等腰梯形.
其中正确命题的序号是()
A.①②④B.①②③C.②③).③
5.已知向量a${i=(1,2),\vec {b}=(2,-2),\quad \vec {c}=(\lambda ,-1)}$,若${\vec {c}//(2\vec {a}+\vec {b})}$则λ=()
A.-2B.-1${c.\quad -\frac{1}{2}}$D.${\quad \frac{1}{2}}$
6.已知△ABC中,a=1,${b=\sqrt {3},}$A=30°,则B等于()
A.30°B.30°或150°C.60°D.60°或120°
7.在△ABC中,a、b、c分别为角A、B、C的对边,若b=2,c=1,C=30°,则a=()()
A.${\quad \sqrt {3}}$B.3C.${\quad \sqrt {5}}$D.1
8.若(a+b+c)(b+c-a)=3bc,且sinA=2sinBcosC,那么△ABC是()
A.直角三角形B.等边三角形
C.等腰三角形D.等腰直角三角形
9.在等差数列${\lbrace a_{n}\rbrace }$中,${S_{15}>0,\quad S_{16}<0,}$则使${a_{n}>0}$成立的n的最大值为()
A.6B.7C.8D.S
10.已知等比数列${\lbrace a_{n}\rbrace }$的前n项和为${S_{n},}${S_{5}=2,\quad S_{10}=6,}${a_{16}+a_{17}+a_{18}+a_{19}+a_{20}=}$
()
A.54B.48C.32D.16
11.设点D为△ABC中BC边上的中点,O为AD边上靠近点A的三等分点,则()
A.${\quad \overrightarrow {BO}=-\frac{1}{6}\overrightarrow {AB}+\frac{1}{2}\overrightarrow {AC}}$B.${\quad \overrightarrow {BO}=\frac{1}{6}\overrightarrow {AB}-\frac{1}{2}\overrightarrow {AC}}$
${\therefore \overrightarrow {BO}=\frac{5}{6}\overrightarrow {AB}-\frac{1}{6}\overrightarrow {AC}}$D.${\quad \overrightarrow {BO}=-\frac{5}{6}\overrightarrow {AB}+\frac{1}{6}\overrightarrow {AC}}$
12.△ABC中,角A、B、C的对边分别为a、b、c,且2a+b=2ccosB,若△ABC的面
积为${S=\sqrt {3}c,}$则ab的最小值为()
A.12B.24C.28D.48
二、填空题(本大题共4小题,每小题5分.请将正确答案填写在答题卡相应位置。)
13.在数列${\lbrace a_{n}\rbrace }$中,若${a_{1}=1,a_{n}-a_{n-1}=n(n\geq 2),}$则该数列的通项${a_{n}=}$
14.已知圆锥的侧面展开图是一个半径为6cm,圆心角为${\frac{2\pi}{3}}$的扇形,则此圆锥的体积为
15.已知平面向量${\vec {a}}${\vec {b}}$的夹角为${\frac{\pi}{3},\quad \vec {a}=(\sqrt {3},-1),\quad |\vec {b}|=1,}$则|${2\vec {a}-\vec {b}|=}$
16.已知α、β为锐角,sinα=2,tan(β-α)=-,则tanβ=______
三.解答题(本大题共6小题,共70分.请将正确答案写在答题卡相应位置。解答应写出
文字说明、证明过程或演算步骤.)
17.(10分)(1)解不等式(x-1)(x-a)≥0
(2)已知${f(x)=\frac{x^{2}+6x+9}{x+1},}$其中x>-1,求f(x)的最小值.
18.(12分)已知函数j${{(x)=2\sin x\cos (x+\frac{\pi}{3})+\frac{\sqrt {3}}{2}}}$
(1)求函数f(x)的最小正周期;
(2)若f(x)+m≤0对${x\∈\lbrack 0,\frac{\pi}{2}\rbrack }$亘成立,求实数m的取值范围.
19.(12分)已知等比数列${\lbrace a_{n}\rbrace }$的前n项和为${S_{n},}$且满足${S_{3}=7,\quad S_{6}=63,}$
(1)求数列${\lbrace a_{n}\rbrace }$的通项公式;
(2)若${b_{n}=a_{n}+\log _{2}a_{n},}$求数列${\lbrace b_{n}\rbrace }$的前n项和${T_{n}}$
0.(12分)已知数列${\lbrace a_{n}\rbrace }$满足${a_{1}=\frac{3}{2},}${l_{n}=\frac{a_{n-1}}{2}+\frac{1}{2^{n-1}}(n\geq 2,n\∈N^{*})}$
(1)求证:数列${\lbrace 2^{n}a_{n}\rbrace }$是等差数列,并求出数列${\lbrace a_{n}\rbrace }$的通项公式;
(2)求数列${\lbrace a_{n}\rbrace }$的前n项和${S_{n}.}$
21.(12分)如图,在△ABC中,${C=\frac{\pi}{4},\overrightarrow {CA}\cdot \overrightarrow {CB}=48,}$点D在BC边上,且
${AD=5\sqrt {2},\cos \angle ADB=\frac{3}{5}}$
(I)求AC,CD的长;(II)求cos∠BAD的值.
22.(12分)数列{a,}中,a,=1,当n≥2时,其前n项和S,满足S,2=a,(S,--)${(u_{n})^{\prime }//t_{1},\quad u_{1}-}${4b_{n}//A_{n}-u_{n}\cdot (\beta _{n}-\bar {2})}$
(1)求${S_{n}}$的表达式;
(2)求数列${\lbrace a_{n}\rbrace }$的通项公式;
(3)设${b_{n}=\frac{S_{n}}{2n+1}.}$求数列${\lbrace b_{n}\rbrace }$的前n项和${T_{n}.}$
数学答案
一、选择题
二、填空题
${13.\frac{n^{2}+n}{2}\quad 14.\frac{16\sqrt {2}}{3}\pi\quad 15.\sqrt {13}\quad 16.\frac{73}{9}}$
三、解答题
17.(1)当a>1时,原不等式解集是{x|x≥a,或x≤1};
当a=1时,原不等式解集是R:
当a<1时,原不等式解集是(x|x|1或X]a}_5分
(2)∵x>-1,则x+1>0,
由基本不等式得${f(x)=\frac{x^{2}+6x+9}{x+1}=}$+1x+1${(x+1)+\frac{4}{x+i}+4}$
${=2\sqrt {(x+1)\cdot \frac{4}{x+1}}+4=8}$(当且仅当${x+1=\frac{4}{x+1}}$时,即当x=1时取得等号)
因此,函数${f(x)=\frac{x^{2}+6x+9}{x+1}(x>-1}$)的最小值为810分
18.解:(1)因为${f(x)=2\sin x\cos (x+}$
${=2\sin x(\cos x\cos \frac{\pi}{3}-\sin x\sin x\sin }$
${=2\sin x(\frac{1}{2}\cos x-\frac{\sqrt {3}}{2}\sin x}$
${\div \sin x\cos x-\sqrt {3}\sin ^{2}x+\frac{\sqrt {3}}{2}}$
${=\frac{1}{2}\sin 2x+\frac{\sqrt {3}}{2}\cos 2x}$
${=\sin (2x+\frac{\pi}{3})}$
所以f(x)的最小正周期为${f=\frac{2\pi}{2}=\pi}$
(2)"f(x)+m≤0对${x\∈\lbrack 0,\frac{\pi}{2}\rbrack }$恒成立"等价于"${f(x)_{\max }+m\leq 0^{n}}$
因为${x\∈\lbrack 0,\frac{\pi}{2}\rbrack }$
所以${2x+\frac{\pi}{3}\∈\lbrack \frac{\pi}{3},\frac{4\pi}{3}\rbrack }$
${2x+\frac{\pi}{3}=\frac{\pi}{2},}${x=\frac{\pi}{12}}$
f(x)的最大值为${f(\frac{\pi}{12})=1.}$
所以实数m的取值范围为${(-9O,-1\rbrack }$12分
19.(1)由题意知S${\because _{6}\neq 2s_{3},q\neq 1\cdots }$
${\therefore S_{3}=\frac{a_{1}(7-q^{3})}{1-q}=7}$
........................3分
${s_{6}=\frac{a_{1}(1-q^{6})}{1-q}}$
解得${\left\lbrace \begin{array}{l}{a_{1}=7}\\{q=2}\end{array}\right.\cdots \cdots }$5分${\therefore a_{n}=2^{n-7}\cdots \cdots }$.6分
2)由(1)知${b_{n}=2^{n-7}+n-1\cdots \cdots \cdots }$..7分
∴T。=(1+2+-..+${y^{-x-3}_{n}}$+[1+2+--+(n-1)].................9分
${=2^{n}+\frac{n^{2}-n}{2}-1\cdots }$.........12分
20.(1)因为${a_{n}=\frac{a_{n-1}}{2}+\frac{1}{2^{n-1}}(n\geq 2,n\∈N^{*})}$,所以${2^{n}a_{n}=2^{n-1}a_{a}+2}$,即
${2^{n}a_{n}-2^{n-1}a_{n-1}=2,}$
所以数列${\lbrace 2^{n}a_{n}\rbrace }$是等差数列,且公差d=2,其首项${2a_{1}=3}$
所以${2^{7}a_{n}=3+(n-1)\times 2=2n+7}$,解得${a_{n}=\frac{2n+i}{2^{n}}}$
${2)\quad S_{n}=\frac{3}{2}+\frac{5}{2^{2}}+\frac{7}{2^{3}}+\cdots +\frac{2n-1}{2^{p-1}}+\frac{2n+1}{z^{\theta }},}$
${\frac{S_{n}}{2}=\frac{3}{2^{2}}+\frac{5}{2^{3}}+\frac{7}{2^{4}}+\cdots +\frac{2n-1}{2^{n}}+\frac{2n+1}{2^{n}+1},}$
①-②,得${\frac{S_{e}}{z}=\frac{3}{z}+}${+\frac{7}{2^{3}}+\cdots +\frac{1}{2^{s}}}${=\frac{3}{2}+}${z^{e}+x^{2}}$ ${1-\frac{7}{2}}$
${=\frac{5}{x}-\frac{2n+5}{a+1},}$
所以${S_{n}=5-\frac{2n+5}{2^{n}}}$12分
21.(I)在△ABD中,∵${\cos \angle ADB=\frac{3}{5},\therefore \sin \angle ADB=\frac{4}{5}.}$
sin∠CAD=sin(∠ADB-${\angle AcD,=\sin \angle ADB\cos \frac{\pi}{4}-\cos \angle ADB\sin \frac{\pi}{4}}$
${=\frac{4}{5}\times \frac{\sqrt {2}}{2}-\frac{3}{5}\times \frac{\sqrt {2}}{2}=\frac{\sqrt {2}}{10}}$
在△ADC中,由正弦定理得${\frac{Ac}{\sin \angle ADc}=\frac{cD}{\sin \angle CAD}=\frac{AD}{\sin \angle ACD}}${\frac{AC}{\frac{4}{5}}=\frac{cD}{\sqrt {2}}=\frac{5\sqrt {2}}{\sqrt {2}}}$
解得${AC=8,CD=\sqrt {2},}$
${\Pi)\because \overrightarrow {CA}\cdot \overrightarrow {CB}=48,}${8\cdot cB\cdot \frac{\sqrt {2}}{2}=48.}$解得${c_{B}=6\sqrt {2},}$∴BD=CB-CD=5√2
在△ABC中,A${B=\sqrt {8^{2}+(6\sqrt {2})-2\times 8\times 6\sqrt {2}}=2\sqrt {10}}$,在△ABD中
${\infty \angle BAD=\frac{(2\sqrt {10})^{2}+(5\sqrt {2})}{2\times 2\sqrt {10}\times 5\sqrt {2}}=\frac{\sqrt {5}}{5}}$
22.(1)由${\sin ^{2}=5}=S_{n}-5_{5}}&{T_{6}^{z}=-7}}${s_{w}^{2}=(S_{w}-S_{6-1})(s_{w}-\frac{1}{2})=s_{e}^{\vec {x}}-\frac{1}{2}S_{\varphi }-S_{6}=+\frac{7}{2}s}$
${\therefore \frac{1}{s_{n}}-\frac{1}{S_{n-1}}=2(n\supseteq 2)}$
${\therefore \left\lbrace \begin{array}{l}{\frac{1}{s}\rbrace }$是以${\frac{1}{s_{7}}}$为首项,以2为公差的等差数列,
${\therefore \frac{1}{s_{n}}=2n-1,}$
${s_{n}=\frac{1}{2n-1}(n\∈N^{*}.}$
${a_{n}=\left\lbrace \begin{array}{l}{7,n=7}\\{\frac{1}{2p-1}-\frac{7}{2n-3},n\geq }\end{array}\right.}$
(3)${b_{n}=\frac{7}{(2n-7)(2n+i)}=}$
${\therefore 7_{8}=\frac{1}{2}(1-\frac{1}{3}+\frac{1}{3}-\frac{1}{5}+\frac{1}{2\pi-1}-\frac{1}{2\pi+1})=\frac{1}{2}(-\frac{1}{2n+1})=\frac{\pi}{2\pi}}$12/' svg_data = {'svg_html_data': ['
1.在数列{an}中,若a1=1,anan1=n(n2),则该数列的通项an=
'], 'svg_path': ''} wordid = "5fc0d256407550d0b7d9a43c" res=Ruku(items_list, ocr_html, svg_data, wordid).upload_img() pprint(res)