一般在什么网站上做电子请帖,腾讯广告投放端提供的建站工具有,北京搜索优化推广公司,汾阳网架公司【问题】
已知函数f(x)e^x-ln(xm),求证m2时#xff0c;证明f(x)0 #xff08;2013年高考全国卷II理科第21题#xff09;
【出处】
《高中数学解题思维策略》P30 例2-11 杨林军编著
【解答】
对于ye^x,总有e^xx1 (x0时去等)
对于yln(xm),总有yxm-1ln(…【问题】
已知函数f(x)e^x-ln(xm),求证m2时证明f(x)0 2013年高考全国卷II理科第21题
【出处】
《高中数学解题思维策略》P30 例2-11 杨林军编著
【解答】
对于ye^x,总有e^xx1 (x0时去等)
对于yln(xm),总有yxm-1ln(xm) xm1时取等
如对于yln(x2)总有x1ln(x2)
对于yln(x1),总有xln(x1)
所以f(x)e^x-ln(xm)(x1)-(xm-1)2-m 不取等号因为切点不会是同一横坐标
故m2时f(x)0
证毕。下面将用图线辅助思考。
下图是m取不同值时的f(x)e^x-ln(xm)曲线 下面是m2时三条曲线相比的示意图 下面是m1时四条曲线相比的示意图 【图一代码】 !DOCTYPE html
html langutf-8
meta http-equivContent-Type contenttext/html; charsetutf-8/
headtitleUNASSIGNED/titlestyle typetext/css.centerlize{margin:0 auto;border:0px solid red;width:1200px;height:600px;}/style/headbody οnlοaddraw();div classcenterlizecanvas idmyCanvas width10px height10px styleborder:1px dashed black;如果看到这段文字说您的浏览器尚不支持HTML5 Canvas请更换浏览器再试./canvas/div/body
/html
script typetext/javascript
!--
/*****************************************************************
* 将全体代码拷贝下来粘贴到文本编辑器中另存为.html文件
* 再用chrome浏览器打开就能看到动画效果。
******************************************************************/// 系统常量定义处
const TITLE图一 f(x)e^x-ln(xm) 图线 ; // 图像标题
const WIDTH1200; // 画布宽度
const HEIGHT600; // 画布高度
const SCALE_UNIT50; // 缩放比例 25对应x∈[-24,24],100对应x∈[-6,6]// 系统变量定义处
var context0; // 画布环境
var stage; // 舞台对象
var timeElapsed0; // 动画运作的的时间
const TIME_END100000; // 动画运作的期限//-------------------------------
// Canvas开始运作由body_onload调用
//-------------------------------
function draw(){document.titleTITLE;// 画图前初始化var canvasdocument.getElementById(myCanvas); canvas.widthWIDTH;canvas.heightHEIGHT; contextcanvas.getContext(2d); // 进行屏幕坐标系到笛卡尔坐标系的变换// 处置完成前原点在左上角向右为X正向向下为Y的正向// 处置完毕后原点移动到画布中央向右为X正向向上为Y的正向context.translate(WIDTH/2,HEIGHT/2);context.rotate(Math.PI);context.scale(-1,1);// 初始化舞台stagenew Stage();// 开始动画animate();
};//-------------------------------
// 画图
//-------------------------------
function animate(){ timeElapsed1;// 时间每轮增加1stage.update(timeElapsed);stage.paintBg(context);stage.paint(context);if(timeElapsedTIME_END){ window.requestAnimationFrame(animate);}
}//-------------------------------
// 舞台对象定义处
//-------------------------------
function Stage(){// 内置对象(非必要勿更改)var objnew Object;// 对象下的曲线数组(非必要勿更改)obj.curves[];// 塞入曲线1(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x2),xEnd:3,x:-2,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x2);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线2(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x1),xEnd:3,x:-1,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x1);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线3(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x0),xEnd:3,x:0,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x0);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线4(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x-1),xEnd:3,x:-1,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x-1);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线5(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x3),xEnd:3,x:-3,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x3);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 随时间更新位置(非必要勿更改)obj.updatefunction(t){for(var i0;ithis.curves.length;i){var curvethis.curves[i];if(curve.xcurve.xEnd){curve.x0.01;curve.setY(curve.x);}}};// 画前景obj.paintfunction(ctx){ // 手动标记点//paintPoint(ctx,1,0,a,navy);//paintPoint(ctx,0,1,b,navy);// 文字左上角位置(可手动修改设定值)const X_START-230; // 文字横起点const Y_START150; // 文字纵起点const OFFSET50; // 文字间隔// 遍历曲线数组(非必要勿更改)for(var i0;ithis.curves.length;i){var curvethis.curves[i];var colorgetColor(i);// 曲线名称drawText(ctx,curve.name,X_START,Y_START-i*OFFSET,color,18);// 曲线当前点坐标drawText(ctx,当前 X:curve.x.toFixed(3) Y:curve.y.toFixed(3),X_START,Y_START-20-(i)*OFFSET,color,18);// 绘制曲线if(curve.pts0){paintCurve(ctx,color,curve.pts0);// 绘制曲线分段1的高低点(可选)//var mmfindMaxMin(curve.pts0);//markMaxMin(ctx,mm,color);}if(curve.pts1){paintCurve(ctx,color,curve.pts1);// 绘制曲线分段2的高低点(可选)//var mmfindMaxMin(curve.pts1);//markMaxMin(ctx,mm,color);}if(curve.pts2){paintCurve(ctx,color,curve.pts2);// 绘制曲线分段3的高低点(可选)//var mmfindMaxMin(curve.pts2);//markMaxMin(ctx,mm,color);}if(curve.pts3){paintCurve(ctx,color,curve.pts3);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}if(curve.pts4){paintCurve(ctx,color,curve.pts4);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}}};// 画背景(非必要不更改)obj.paintBgfunction(ctx){// 清屏ctx.clearRect(-600,-300,1200,600);ctx.fillStylergb(251,255,253);ctx.fillRect(-600,-300,1200,600);// 画X轴drawAxisX(ctx,-600,600,50);// 画Y轴drawAxisY(ctx,-300,300,50);// 画网格线drawGrid(ctx,-600,-300,50,1200,600,50);// 左上角标题var metrics ctx.measureText(TITLE);var textWidth metrics.width;drawText(ctx,TITLE,-WIDTH/2textWidth3,HEIGHT/2-30,grey,18);// 右下角作者日期const waterMarkTxt逆火原创(new Date()).toLocaleDateString();metrics ctx.measureText(waterMarkTxt);textWidth metrics.width;drawText(ctx,waterMarkTxt,WIDTH/2-textWidth,-HEIGHT/2,lightGrey,16);};return obj;
}// 描绘并标识一个点
function paintPoint(ctx,x,y,text,color){var xRealx*SCALE_UNIT;var yRealy*SCALE_UNIT;ctx.strokeStylecolor;ctx.lineWidth0.5;// 划线ctx.save();ctx.setLineDash([5,5]);ctx.beginPath(); ctx.moveTo(xReal,0);ctx.lineTo(xReal,yReal);ctx.lineTo(0,yReal);ctx.stroke();ctx.restore();// 画圈ctx.beginPath();ctx.arc(xReal,yReal,4,0,Math.PI*2,false);ctx.closePath(); ctx.stroke();// 写文字var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,xRealtextWidth2,yReal-5,color,12);
}// 连点成线画曲线
function paintCurve(ctx,color,cds){ctx.save();ctx.strokeStyle color;ctx.lineWidth1;ctx.beginPath(); for(var i0; icds.length; i){let ycds[i].y;if(Math.abs(cds[i].y*SCALE_UNIT)300){ctx.lineTo(cds[i].x*SCALE_UNIT,cds[i].y*SCALE_UNIT);}} ctx.stroke(); ctx.restore();
}// 找到坐标数组的最大最小值
function findMaxMin(cds){if(cds.length1){return null;}var retval{max:-10000,max_x:0,min:10000,min_x:0};for(var i0;icds.length;i){var ycds[i].y;if(yretval.max){retval.maxy;retval.max_xcds[i].x;}if(yretval.min){retval.miny;retval.min_xcds[i].x;}} return retval;
}// 绘出最大最小值
function markMaxMin(ctx,mm,color){if(mmnull){return;}// 最大值var xmm.max_x;var ymm.max;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textmaxxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);// 最小值var xmm.min_x;var ymm.min;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textminxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);
}// 定点画实心圆
function drawSolidCircle(ctx,x,y,r,color){ctx.save();ctx.beginPath();ctx.arc(x,y,r,0,2*Math.PI);ctx.fillStylecolor;ctx.fill();ctx.restore();
}// 两点之间画线段
function drawLine(ctx,x1,y1,x2,y2,color){ctx.save();ctx.lineWidth0.25;ctx.strokeStylecolor;ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke();ctx.closePath();ctx.restore();
}// 画横轴
function drawAxisX(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(start, 0);ctx.lineTo(end, 0);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(end-Math.cos(getRad(15))*10, Math.sin(getRad(15))*10);ctx.lineTo(end, 0);ctx.lineTo(end-Math.cos(getRad(15))*10, -Math.sin(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;y5;for(xstart;xend;xstep){if(x0){continue;}ctx.beginPath();ctx.moveTo(x, 0);ctx.lineTo(x, y);ctx.stroke();ctx.closePath();var textformatScale(x/SCALE_UNIT);drawText(ctx,text,x,y-20,AXISY_COLOR,12);}ctx.restore();
}// 画纵轴
function drawAxisY(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(0, start);ctx.lineTo(0, end);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.lineTo(0, end);ctx.lineTo(-Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;x5;for(ystart;yend;ystep){ctx.beginPath();ctx.moveTo(x, y);ctx.lineTo(0, y);var textformatScale(y/SCALE_UNIT);var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,x-textWidth-5,y,AXISY_COLOR,12);ctx.stroke();ctx.closePath();}ctx.restore();
}//-------------------------------
// 得到整型后的刻度
//-------------------------------
function formatScale(scale){var sscale*10;if(s % 50){return scale;}else{return scale.toFixed(2);}
}// 画网格线
function drawGrid(ctx,x1,y1,step1,x2,y2,step2){ctx.save();ctx.lineWidth0.25;ctx.strokeStylelightgrey; // 分十格var x,y;for(xx1;xx2;xstep1/10){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();ctx.closePath();}for(yy1;yy2;ystep2/10){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();ctx.closePath();}// 十小格间的分割线ctx.lineWidth0.25;ctx.strokeStylegrey;ctx.setLineDash([5,5]);// 设置虚线,起止点间包含五空格五划线共十段for(xx1;xx2;xstep1){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();}for(yy1;yy2;ystep2){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();}ctx.restore();
}//-------------------------------
// 角度得到弧度
//-------------------------------
function getRad(degree){return degree/180*Math.PI;
}//-------------------------------
// 得到颜色
//-------------------------------
function getColor(index){var arr[maroon /* 栗色 */,orange /* 橙色 */,blue /* 蓝色 */,green /* 绿色 */, fuchsia/* 紫红 */, grey /* 灰色 */,lime /* 酸橙 */, navy /* 海蓝 */, purple /* 紫色 */,skyblue/* 天蓝 */,teal /* 蓝绿 */,yellow /* 亮黄 */,aqua /* 湖绿 */,red /* 红色 */, black /* 黑色 */, ];return arr[index % arr.length];
}//-------------------------------------
// 绘制文字,指定颜色
// ctx:绘图环境
// text:文字
// x,y:坐标
// color:颜色
// size:字体大小
//-------------------------------------
function drawText(ctx,text,x,y,color,size){ctx.save();ctx.translate(x,y)ctx.rotate(getRad(180))ctx.scale(-1,1)ctx.textBaselinebottom;ctx.textAligncenter;ctx.fillStylecolor;ctx.font sizepx consolas;ctx.fillText(text,0,0);ctx.restore();
}// JS开立方
function kaiLiFang(x){if(x0){return Math.pow(x,1/3);}else{return -Math.pow(-x,1/3);}
}
//--
/****************************************
遇到事情要学会沉住气在默默无闻中积攒
力量等待厚积薄发的一天。
****************************************/
/script 【图二代码】 !DOCTYPE html
html langutf-8
meta http-equivContent-Type contenttext/html; charsetutf-8/
headtitleUNASSIGNED/titlestyle typetext/css.centerlize{margin:0 auto;border:0px solid red;width:1200px;height:600px;}/style/headbody οnlοaddraw();div classcenterlizecanvas idmyCanvas width10px height10px styleborder:1px dashed black;如果看到这段文字说您的浏览器尚不支持HTML5 Canvas请更换浏览器再试./canvas/div/body
/html
script typetext/javascript
!--
/*****************************************************************
* 将全体代码拷贝下来粘贴到文本编辑器中另存为.html文件
* 再用chrome浏览器打开就能看到动画效果。
******************************************************************/// 系统常量定义处
const TITLE图二 f(x)e^x-ln(x2) 图线 ; // 图像标题
const WIDTH1200; // 画布宽度
const HEIGHT600; // 画布高度
const SCALE_UNIT50; // 缩放比例 25对应x∈[-24,24],100对应x∈[-6,6]// 系统变量定义处
var context0; // 画布环境
var stage; // 舞台对象
var timeElapsed0; // 动画运作的的时间
const TIME_END100000; // 动画运作的期限//-------------------------------
// Canvas开始运作由body_onload调用
//-------------------------------
function draw(){document.titleTITLE;// 画图前初始化var canvasdocument.getElementById(myCanvas); canvas.widthWIDTH;canvas.heightHEIGHT; contextcanvas.getContext(2d); // 进行屏幕坐标系到笛卡尔坐标系的变换// 处置完成前原点在左上角向右为X正向向下为Y的正向// 处置完毕后原点移动到画布中央向右为X正向向上为Y的正向context.translate(WIDTH/2,HEIGHT/2);context.rotate(Math.PI);context.scale(-1,1);// 初始化舞台stagenew Stage();// 开始动画animate();
};//-------------------------------
// 画图
//-------------------------------
function animate(){ timeElapsed1;// 时间每轮增加1stage.update(timeElapsed);stage.paintBg(context);stage.paint(context);if(timeElapsedTIME_END){ window.requestAnimationFrame(animate);}
}//-------------------------------
// 舞台对象定义处
//-------------------------------
function Stage(){// 内置对象(非必要勿更改)var objnew Object;// 对象下的曲线数组(非必要勿更改)obj.curves[];// 塞入曲线1(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x2),xEnd:3,x:-2,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x2);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线2(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x,xEnd:3,x:-2,y:0,setY:function(x){this.yMath.pow(Math.E,x);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线3(按需修改设定项)obj.curves.push({name:曲线:f(x)x1,xEnd:3,x:-2,y:0,setY:function(x){this.yx1;// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线4(按需修改设定项)obj.curves.push({name:曲线:f(x)ln(x2),xEnd:3,x:-2,y:0,setY:function(x){this.yMath.log(x2);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 随时间更新位置(非必要勿更改)obj.updatefunction(t){for(var i0;ithis.curves.length;i){var curvethis.curves[i];if(curve.xcurve.xEnd){curve.x0.01;curve.setY(curve.x);}}};// 画前景obj.paintfunction(ctx){ // 手动标记点//paintPoint(ctx,1,0,a,navy);//paintPoint(ctx,0,1,b,navy);// 文字左上角位置(可手动修改设定值)const X_START-230; // 文字横起点const Y_START150; // 文字纵起点const OFFSET50; // 文字间隔// 遍历曲线数组(非必要勿更改)for(var i0;ithis.curves.length;i){var curvethis.curves[i];var colorgetColor(i);// 曲线名称drawText(ctx,curve.name,X_START,Y_START-i*OFFSET,color,18);// 曲线当前点坐标drawText(ctx,当前 X:curve.x.toFixed(3) Y:curve.y.toFixed(3),X_START,Y_START-20-(i)*OFFSET,color,18);// 绘制曲线if(curve.pts0){paintCurve(ctx,color,curve.pts0);// 绘制曲线分段1的高低点(可选)//var mmfindMaxMin(curve.pts0);//markMaxMin(ctx,mm,color);}if(curve.pts1){paintCurve(ctx,color,curve.pts1);// 绘制曲线分段2的高低点(可选)//var mmfindMaxMin(curve.pts1);//markMaxMin(ctx,mm,color);}if(curve.pts2){paintCurve(ctx,color,curve.pts2);// 绘制曲线分段3的高低点(可选)//var mmfindMaxMin(curve.pts2);//markMaxMin(ctx,mm,color);}if(curve.pts3){paintCurve(ctx,color,curve.pts3);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}if(curve.pts4){paintCurve(ctx,color,curve.pts4);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}}};// 画背景(非必要不更改)obj.paintBgfunction(ctx){// 清屏ctx.clearRect(-600,-300,1200,600);ctx.fillStylergb(251,255,253);ctx.fillRect(-600,-300,1200,600);// 画X轴drawAxisX(ctx,-600,600,50);// 画Y轴drawAxisY(ctx,-300,300,50);// 画网格线drawGrid(ctx,-600,-300,50,1200,600,50);// 左上角标题var metrics ctx.measureText(TITLE);var textWidth metrics.width;drawText(ctx,TITLE,-WIDTH/2textWidth3,HEIGHT/2-30,grey,18);// 右下角作者日期const waterMarkTxt逆火原创(new Date()).toLocaleDateString();metrics ctx.measureText(waterMarkTxt);textWidth metrics.width;drawText(ctx,waterMarkTxt,WIDTH/2-textWidth,-HEIGHT/2,lightGrey,16);};return obj;
}// 描绘并标识一个点
function paintPoint(ctx,x,y,text,color){var xRealx*SCALE_UNIT;var yRealy*SCALE_UNIT;ctx.strokeStylecolor;ctx.lineWidth0.5;// 划线ctx.save();ctx.setLineDash([5,5]);ctx.beginPath(); ctx.moveTo(xReal,0);ctx.lineTo(xReal,yReal);ctx.lineTo(0,yReal);ctx.stroke();ctx.restore();// 画圈ctx.beginPath();ctx.arc(xReal,yReal,4,0,Math.PI*2,false);ctx.closePath(); ctx.stroke();// 写文字var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,xRealtextWidth2,yReal-5,color,12);
}// 连点成线画曲线
function paintCurve(ctx,color,cds){ctx.save();ctx.strokeStyle color;ctx.lineWidth1;ctx.beginPath(); for(var i0; icds.length; i){let ycds[i].y;if(Math.abs(cds[i].y*SCALE_UNIT)300){ctx.lineTo(cds[i].x*SCALE_UNIT,cds[i].y*SCALE_UNIT);}} ctx.stroke(); ctx.restore();
}// 找到坐标数组的最大最小值
function findMaxMin(cds){if(cds.length1){return null;}var retval{max:-10000,max_x:0,min:10000,min_x:0};for(var i0;icds.length;i){var ycds[i].y;if(yretval.max){retval.maxy;retval.max_xcds[i].x;}if(yretval.min){retval.miny;retval.min_xcds[i].x;}} return retval;
}// 绘出最大最小值
function markMaxMin(ctx,mm,color){if(mmnull){return;}// 最大值var xmm.max_x;var ymm.max;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textmaxxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);// 最小值var xmm.min_x;var ymm.min;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textminxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);
}// 定点画实心圆
function drawSolidCircle(ctx,x,y,r,color){ctx.save();ctx.beginPath();ctx.arc(x,y,r,0,2*Math.PI);ctx.fillStylecolor;ctx.fill();ctx.restore();
}// 两点之间画线段
function drawLine(ctx,x1,y1,x2,y2,color){ctx.save();ctx.lineWidth0.25;ctx.strokeStylecolor;ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke();ctx.closePath();ctx.restore();
}// 画横轴
function drawAxisX(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(start, 0);ctx.lineTo(end, 0);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(end-Math.cos(getRad(15))*10, Math.sin(getRad(15))*10);ctx.lineTo(end, 0);ctx.lineTo(end-Math.cos(getRad(15))*10, -Math.sin(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;y5;for(xstart;xend;xstep){if(x0){continue;}ctx.beginPath();ctx.moveTo(x, 0);ctx.lineTo(x, y);ctx.stroke();ctx.closePath();var textformatScale(x/SCALE_UNIT);drawText(ctx,text,x,y-20,AXISY_COLOR,12);}ctx.restore();
}// 画纵轴
function drawAxisY(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(0, start);ctx.lineTo(0, end);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.lineTo(0, end);ctx.lineTo(-Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;x5;for(ystart;yend;ystep){ctx.beginPath();ctx.moveTo(x, y);ctx.lineTo(0, y);var textformatScale(y/SCALE_UNIT);var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,x-textWidth-5,y,AXISY_COLOR,12);ctx.stroke();ctx.closePath();}ctx.restore();
}//-------------------------------
// 得到整型后的刻度
//-------------------------------
function formatScale(scale){var sscale*10;if(s % 50){return scale;}else{return scale.toFixed(2);}
}// 画网格线
function drawGrid(ctx,x1,y1,step1,x2,y2,step2){ctx.save();ctx.lineWidth0.25;ctx.strokeStylelightgrey; // 分十格var x,y;for(xx1;xx2;xstep1/10){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();ctx.closePath();}for(yy1;yy2;ystep2/10){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();ctx.closePath();}// 十小格间的分割线ctx.lineWidth0.25;ctx.strokeStylegrey;ctx.setLineDash([5,5]);// 设置虚线,起止点间包含五空格五划线共十段for(xx1;xx2;xstep1){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();}for(yy1;yy2;ystep2){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();}ctx.restore();
}//-------------------------------
// 角度得到弧度
//-------------------------------
function getRad(degree){return degree/180*Math.PI;
}//-------------------------------
// 得到颜色
//-------------------------------
function getColor(index){var arr[maroon /* 栗色 */,orange /* 橙色 */,blue /* 蓝色 */,green /* 绿色 */, fuchsia/* 紫红 */, grey /* 灰色 */,lime /* 酸橙 */, navy /* 海蓝 */, purple /* 紫色 */,skyblue/* 天蓝 */,teal /* 蓝绿 */,yellow /* 亮黄 */,aqua /* 湖绿 */,red /* 红色 */, black /* 黑色 */, ];return arr[index % arr.length];
}//-------------------------------------
// 绘制文字,指定颜色
// ctx:绘图环境
// text:文字
// x,y:坐标
// color:颜色
// size:字体大小
//-------------------------------------
function drawText(ctx,text,x,y,color,size){ctx.save();ctx.translate(x,y)ctx.rotate(getRad(180))ctx.scale(-1,1)ctx.textBaselinebottom;ctx.textAligncenter;ctx.fillStylecolor;ctx.font sizepx consolas;ctx.fillText(text,0,0);ctx.restore();
}// JS开立方
function kaiLiFang(x){if(x0){return Math.pow(x,1/3);}else{return -Math.pow(-x,1/3);}
}
//--
/****************************************
遇到事情要学会沉住气在默默无闻中积攒
力量等待厚积薄发的一天。
****************************************/
/script 【图三代码】 !DOCTYPE html
html langutf-8
meta http-equivContent-Type contenttext/html; charsetutf-8/
headtitleUNASSIGNED/titlestyle typetext/css.centerlize{margin:0 auto;border:0px solid red;width:1200px;height:600px;}/style/headbody οnlοaddraw();div classcenterlizecanvas idmyCanvas width10px height10px styleborder:1px dashed black;如果看到这段文字说您的浏览器尚不支持HTML5 Canvas请更换浏览器再试./canvas/div/body
/html
script typetext/javascript
!--
/*****************************************************************
* 将全体代码拷贝下来粘贴到文本编辑器中另存为.html文件
* 再用chrome浏览器打开就能看到动画效果。
******************************************************************/// 系统常量定义处
const TITLE图三 f(x)e^x-ln(x1) 图线 ; // 图像标题
const WIDTH1200; // 画布宽度
const HEIGHT600; // 画布高度
const SCALE_UNIT50; // 缩放比例 25对应x∈[-24,24],100对应x∈[-6,6]// 系统变量定义处
var context0; // 画布环境
var stage; // 舞台对象
var timeElapsed0; // 动画运作的的时间
const TIME_END100000; // 动画运作的期限//-------------------------------
// Canvas开始运作由body_onload调用
//-------------------------------
function draw(){document.titleTITLE;// 画图前初始化var canvasdocument.getElementById(myCanvas); canvas.widthWIDTH;canvas.heightHEIGHT; contextcanvas.getContext(2d); // 进行屏幕坐标系到笛卡尔坐标系的变换// 处置完成前原点在左上角向右为X正向向下为Y的正向// 处置完毕后原点移动到画布中央向右为X正向向上为Y的正向context.translate(WIDTH/2,HEIGHT/2);context.rotate(Math.PI);context.scale(-1,1);// 初始化舞台stagenew Stage();// 开始动画animate();
};//-------------------------------
// 画图
//-------------------------------
function animate(){ timeElapsed1;// 时间每轮增加1stage.update(timeElapsed);stage.paintBg(context);stage.paint(context);if(timeElapsedTIME_END){ window.requestAnimationFrame(animate);}
}//-------------------------------
// 舞台对象定义处
//-------------------------------
function Stage(){// 内置对象(非必要勿更改)var objnew Object;// 对象下的曲线数组(非必要勿更改)obj.curves[];// 塞入曲线1(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x-ln(x1),xEnd:3,x:-2,y:0,setY:function(x){this.yMath.pow(Math.E,x)-Math.log(x1);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线2(按需修改设定项)obj.curves.push({name:曲线:f(x)e^x,xEnd:3,x:-2,y:0,setY:function(x){this.yMath.pow(Math.E,x);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线3(按需修改设定项)obj.curves.push({name:曲线:f(x)x1,xEnd:3,x:-2,y:0,setY:function(x){this.yx1;// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线4(按需修改设定项)obj.curves.push({name:曲线:f(x)ln(x1),xEnd:3,x:-1,y:0,setY:function(x){this.yMath.log(x1);// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 塞入曲线5(按需修改设定项)obj.curves.push({name:曲线:f(x)x,xEnd:3,x:-3,y:0,setY:function(x){this.yx;// 解析式let coord{x:x,y:this.y}; if(x0){this.pts0.push(coord);}else{this.pts1.push(coord);}},pts0:[],pts1:[],});// 随时间更新位置(非必要勿更改)obj.updatefunction(t){for(var i0;ithis.curves.length;i){var curvethis.curves[i];if(curve.xcurve.xEnd){curve.x0.01;curve.setY(curve.x);}}};// 画前景obj.paintfunction(ctx){ // 手动标记点//paintPoint(ctx,1,0,a,navy);//paintPoint(ctx,0,1,b,navy);// 文字左上角位置(可手动修改设定值)const X_START-230; // 文字横起点const Y_START150; // 文字纵起点const OFFSET50; // 文字间隔// 遍历曲线数组(非必要勿更改)for(var i0;ithis.curves.length;i){var curvethis.curves[i];var colorgetColor(i);// 曲线名称drawText(ctx,curve.name,X_START,Y_START-i*OFFSET,color,18);// 曲线当前点坐标drawText(ctx,当前 X:curve.x.toFixed(3) Y:curve.y.toFixed(3),X_START,Y_START-20-(i)*OFFSET,color,18);// 绘制曲线if(curve.pts0){paintCurve(ctx,color,curve.pts0);// 绘制曲线分段1的高低点(可选)//var mmfindMaxMin(curve.pts0);//markMaxMin(ctx,mm,color);}if(curve.pts1){paintCurve(ctx,color,curve.pts1);// 绘制曲线分段2的高低点(可选)//var mmfindMaxMin(curve.pts1);//markMaxMin(ctx,mm,color);}if(curve.pts2){paintCurve(ctx,color,curve.pts2);// 绘制曲线分段3的高低点(可选)//var mmfindMaxMin(curve.pts2);//markMaxMin(ctx,mm,color);}if(curve.pts3){paintCurve(ctx,color,curve.pts3);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}if(curve.pts4){paintCurve(ctx,color,curve.pts4);// 绘制曲线分段4的高低点(可选)//var mmfindMaxMin(curve.pts3);//markMaxMin(ctx,mm,color);}}};// 画背景(非必要不更改)obj.paintBgfunction(ctx){// 清屏ctx.clearRect(-600,-300,1200,600);ctx.fillStylergb(251,255,253);ctx.fillRect(-600,-300,1200,600);// 画X轴drawAxisX(ctx,-600,600,50);// 画Y轴drawAxisY(ctx,-300,300,50);// 画网格线drawGrid(ctx,-600,-300,50,1200,600,50);// 左上角标题var metrics ctx.measureText(TITLE);var textWidth metrics.width;drawText(ctx,TITLE,-WIDTH/2textWidth3,HEIGHT/2-30,grey,18);// 右下角作者日期const waterMarkTxt逆火原创(new Date()).toLocaleDateString();metrics ctx.measureText(waterMarkTxt);textWidth metrics.width;drawText(ctx,waterMarkTxt,WIDTH/2-textWidth,-HEIGHT/2,lightGrey,16);};return obj;
}// 描绘并标识一个点
function paintPoint(ctx,x,y,text,color){var xRealx*SCALE_UNIT;var yRealy*SCALE_UNIT;ctx.strokeStylecolor;ctx.lineWidth0.5;// 划线ctx.save();ctx.setLineDash([5,5]);ctx.beginPath(); ctx.moveTo(xReal,0);ctx.lineTo(xReal,yReal);ctx.lineTo(0,yReal);ctx.stroke();ctx.restore();// 画圈ctx.beginPath();ctx.arc(xReal,yReal,4,0,Math.PI*2,false);ctx.closePath(); ctx.stroke();// 写文字var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,xRealtextWidth2,yReal-5,color,12);
}// 连点成线画曲线
function paintCurve(ctx,color,cds){ctx.save();ctx.strokeStyle color;ctx.lineWidth1;ctx.beginPath(); for(var i0; icds.length; i){let ycds[i].y;if(Math.abs(cds[i].y*SCALE_UNIT)300){ctx.lineTo(cds[i].x*SCALE_UNIT,cds[i].y*SCALE_UNIT);}} ctx.stroke(); ctx.restore();
}// 找到坐标数组的最大最小值
function findMaxMin(cds){if(cds.length1){return null;}var retval{max:-10000,max_x:0,min:10000,min_x:0};for(var i0;icds.length;i){var ycds[i].y;if(yretval.max){retval.maxy;retval.max_xcds[i].x;}if(yretval.min){retval.miny;retval.min_xcds[i].x;}} return retval;
}// 绘出最大最小值
function markMaxMin(ctx,mm,color){if(mmnull){return;}// 最大值var xmm.max_x;var ymm.max;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textmaxxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);// 最小值var xmm.min_x;var ymm.min;ctx.strokeStylecolor;ctx.beginPath();ctx.arc(x*SCALE_UNIT,y*SCALE_UNIT,5,0,Math.PI*2,false);ctx.closePath();ctx.stroke();var textminxx.toFixed(3) yy.toFixed(3);drawText(ctx,text,x*SCALE_UNIT,y*SCALE_UNIT,color,12);
}// 定点画实心圆
function drawSolidCircle(ctx,x,y,r,color){ctx.save();ctx.beginPath();ctx.arc(x,y,r,0,2*Math.PI);ctx.fillStylecolor;ctx.fill();ctx.restore();
}// 两点之间画线段
function drawLine(ctx,x1,y1,x2,y2,color){ctx.save();ctx.lineWidth0.25;ctx.strokeStylecolor;ctx.beginPath();ctx.moveTo(x1,y1);ctx.lineTo(x2,y2);ctx.stroke();ctx.closePath();ctx.restore();
}// 画横轴
function drawAxisX(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(start, 0);ctx.lineTo(end, 0);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(end-Math.cos(getRad(15))*10, Math.sin(getRad(15))*10);ctx.lineTo(end, 0);ctx.lineTo(end-Math.cos(getRad(15))*10, -Math.sin(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;y5;for(xstart;xend;xstep){if(x0){continue;}ctx.beginPath();ctx.moveTo(x, 0);ctx.lineTo(x, y);ctx.stroke();ctx.closePath();var textformatScale(x/SCALE_UNIT);drawText(ctx,text,x,y-20,AXISY_COLOR,12);}ctx.restore();
}// 画纵轴
function drawAxisY(ctx,start,end,step){const AXISY_COLORblack;ctx.save();ctx.lineWidth0.5;ctx.strokeStyleAXISY_COLOR;// 画轴ctx.beginPath();ctx.moveTo(0, start);ctx.lineTo(0, end);ctx.stroke();ctx.closePath();// 画箭头ctx.beginPath();ctx.moveTo(Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.lineTo(0, end);ctx.lineTo(-Math.sin(getRad(15))*10, end-Math.cos(getRad(15))*10);ctx.stroke();ctx.closePath();// 画刻度var x,y;x5;for(ystart;yend;ystep){ctx.beginPath();ctx.moveTo(x, y);ctx.lineTo(0, y);var textformatScale(y/SCALE_UNIT);var metrics ctx.measureText(text);var textWidth metrics.width;drawText(ctx,text,x-textWidth-5,y,AXISY_COLOR,12);ctx.stroke();ctx.closePath();}ctx.restore();
}//-------------------------------
// 得到整型后的刻度
//-------------------------------
function formatScale(scale){var sscale*10;if(s % 50){return scale;}else{return scale.toFixed(2);}
}// 画网格线
function drawGrid(ctx,x1,y1,step1,x2,y2,step2){ctx.save();ctx.lineWidth0.25;ctx.strokeStylelightgrey; // 分十格var x,y;for(xx1;xx2;xstep1/10){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();ctx.closePath();}for(yy1;yy2;ystep2/10){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();ctx.closePath();}// 十小格间的分割线ctx.lineWidth0.25;ctx.strokeStylegrey;ctx.setLineDash([5,5]);// 设置虚线,起止点间包含五空格五划线共十段for(xx1;xx2;xstep1){ctx.beginPath();ctx.moveTo(x, y1);ctx.lineTo(x, y2);ctx.stroke();}for(yy1;yy2;ystep2){ctx.beginPath();ctx.moveTo(x1, y);ctx.lineTo(x2, y);ctx.stroke();}ctx.restore();
}//-------------------------------
// 角度得到弧度
//-------------------------------
function getRad(degree){return degree/180*Math.PI;
}//-------------------------------
// 得到颜色
//-------------------------------
function getColor(index){var arr[maroon /* 栗色 */,orange /* 橙色 */,blue /* 蓝色 */,green /* 绿色 */, fuchsia/* 紫红 */, grey /* 灰色 */,lime /* 酸橙 */, navy /* 海蓝 */, purple /* 紫色 */,skyblue/* 天蓝 */,teal /* 蓝绿 */,yellow /* 亮黄 */,aqua /* 湖绿 */,red /* 红色 */, black /* 黑色 */, ];return arr[index % arr.length];
}//-------------------------------------
// 绘制文字,指定颜色
// ctx:绘图环境
// text:文字
// x,y:坐标
// color:颜色
// size:字体大小
//-------------------------------------
function drawText(ctx,text,x,y,color,size){ctx.save();ctx.translate(x,y)ctx.rotate(getRad(180))ctx.scale(-1,1)ctx.textBaselinebottom;ctx.textAligncenter;ctx.fillStylecolor;ctx.font sizepx consolas;ctx.fillText(text,0,0);ctx.restore();
}// JS开立方
function kaiLiFang(x){if(x0){return Math.pow(x,1/3);}else{return -Math.pow(-x,1/3);}
}
//--
/****************************************
遇到事情要学会沉住气在默默无闻中积攒
力量等待厚积薄发的一天。
****************************************/
/script END