解:

当x→∞时,y也→∞,所以y没有最大值。

y=x3-6x2+15=-4*(x/2)*(x/2)*(6-x)+15

而根据几何平均数小于等于算术平均数的定理,(x/2)*(x/2)*(6-x)在x/2=6-x时取得最大值,同时y取得最小值。

而x/2=6-x可以得出x=4,此时ymin=16*(-2)+15=-17

上述结果的正确性可以用微分验证,当y的导数y'=3x2-12x=0时,y有极值。

而3x2-12x=0也可以得出x=4.

下图可以直观看出y=x3-6x2+15的极值

曲线:

代码:

<!DOCTYPE html>
<html lang="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<head>
     <title>绘制函数y=x^3-6x^2+15曲线</title>
    </head>

     <body onload="draw()">
        <canvas id="myCanvus" width="1300px" height="640px" style="border:1px dashed black;">
            出现文字表示你的浏览器不支持HTML5
        </canvas>
     </body>
</html>
<script type="text/javascript">
<!--
    function draw(){
        var canvas=document.getElementById("myCanvus");
        var canvasWidth=1300;
        var canvasHeight=640;

        var context=canvas.getContext("2d");

        context.fillStyle = "white";
        context.fillRect(0, 0, canvasWidth, canvasHeight);

        context.strokeStyle = "black";
        context.fillStyle = "black";

        // 进行坐标变换:把原点放在左下角,东方为X轴正向,北方为Y轴正向
        var offsetY=320;// Y向偏移值,正值向上偏,用来画坐标轴
        var offsetX=650;// X向偏移值,正值向右偏,用来画坐标轴

        context.save();
        context.translate(0+offsetX,canvasHeight-offsetY);

        drawAxisXText(context);// 文字和线分开画比较好处理
        drawAxisYText(context);
        drawTitleText(context);

        context.rotate(getRad(180));
        context.scale(-1,1);        

        drawAxisX(context);
        drawAxisY(context);
        drawCurve(context);       

        context.restore();
    }

    function drawTitleText(ctx){
        ctx.lineWidth=0.5;
        ctx.strokeStyle='navy';
        ctx.fillStyle='navy';

        var x=350;
        var y=-250;

        // 写文字
        ctx.fillText("y=x^3-6x^2+15 红色",x,y);
        //ctx.fillText("y=x*x-4*x+4 绿色",x,y+20);
        //ctx.fillText("y=x*x 黄色",x,y+40);
        //ctx.fillText("y=x*x+4*x+5 青柠色",x,y+60);
        //ctx.fillText("y=-(x*x-7*x+12)/5 紫色",x,y+80);
        //ctx.fillText("y=-(x*x+2*x+2)*4 栗色",x,y+100);

        ctx.fillText("  作者:逆火狂飙",x+170,y+30);
    }

    function drawCurve(ctx){
        var cds=[{}];
        var cds1=[{}];
        var cds2=[{}];
        var cds3=[{}];
        var cds4=[{}];
        var cds5=[{}];
        var cds6=[{}];

        var ymax=-1000,ymin=1000,xmax,xmin;

        var x,y;
        for(x=-13;x<=13;x+=0.01){
            y=Math.pow(x,3)-6*Math.pow(x,2)+15;//
            var arr={"x":x,"y":y};
            cds.push(arr);
        }

        paintCurve(ctx,"red",cds);

        for(var i=0; i<cds.length; i++){
            // 求y最大值
            if(cds[i].x<0 && cds[i].y>ymax){
                ymax=cds[i].y;
                xmax=cds[i].x;
            }

            // 求y最小值
            if(cds[i].x>=0 && cds[i].y<ymin){
                ymin=cds[i].y;
                xmin=cds[i].x;
            }
        } 

        console.log("ymin="+ymin+" xmin="+xmin+" ymax="+ymax+" ymin="+ymin+" xmax="+xmax);
        var SU=50;// Scale Unit
        // 极大值
        ctx.beginPath();
        ctx.moveTo(xmax*SU,ymax*5-5);
        ctx.lineTo(xmax*SU,ymax*5+5);

        ctx.save();
        ctx.scale(1,-1);
        ctx.fillText("ymax="+cutShort(ymax.toString(),8),xmax*SU,-ymax*5);
        ctx.restore();

        ctx.stroke();
        ctx.closePath();

        // 极小值
        ctx.beginPath();
        ctx.moveTo(xmin*SU,ymin*5-5);
        ctx.lineTo(xmin*SU,ymin*5+5);

        ctx.save();
        ctx.scale(1,-1);
        ctx.fillText("ymin="+ymin,xmin*SU,-ymin*5);
        ctx.restore();

        ctx.stroke();
        ctx.closePath();

        /*paintCurve(ctx,"green",cds1);
        paintCurve(ctx,"yellow",cds2);
        paintCurve(ctx,"lime",cds3);
        paintCurve(ctx,"purple",cds4);
        paintCurve(ctx,"maroon",cds5);*/
        //paintCurve(ctx,"maroon",cds6);*/
    }

    function paintCurve(ctx,color,cds){
        var SU=50;// Scale Unit

        ctx.strokeStyle = color;
        ctx.beginPath();
        for(var i=0; i<cds.length; i++){
            ctx.lineTo(cds[i].x*SU,cds[i].y*5);// 注意y轴比例
        }
        ctx.stroke();
        ctx.closePath();
    }

    function drawAxisX(ctx){
        ctx.save();

        ctx.lineWidth=0.5;
        ctx.strokeStyle='navy';
        ctx.fillStyle='navy';

        var start=-650;
        var end=650;

        // 画轴
        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;
        y=5;
        for(x=start;x<end;x+=50){
            ctx.beginPath();
            ctx.moveTo(x, 0);
            ctx.lineTo(x, y);

            ctx.stroke();
            ctx.closePath();
        }

        ctx.restore();
    }

    function drawAxisXText(ctx){
        ctx.lineWidth=0.5;
        ctx.strokeStyle='navy';
        ctx.fillStyle='navy';

        var start=-650;
        var end=650;

        // 写文字
        var x,y=5;
        for(x=start;x<end;x+=50){
            ctx.fillText(x/50,x,y+10);
        }
    }

    function drawAxisY(ctx){
        ctx.save();

        ctx.lineWidth=0.5;
        ctx.strokeStyle='navy';
        ctx.fillStyle='navy';

        var start=-300;
        var end=300;

        // 画轴
        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;
        x=5;
        for(y=start;y<end;y+=5){// 注意y轴比例
            ctx.beginPath();
            ctx.moveTo(x, y);
            ctx.lineTo(0, y);

            ctx.stroke();
            ctx.closePath();
        }
    }

    function drawAxisYText(ctx){
        ctx.lineWidth=0.5;
        ctx.strokeStyle='navy';
        ctx.fillStyle='navy';

        var start=-250;
        var end=350;

        // 写文字
        var x=-19,y=5;
        for(y=start;y<end;y+=50){

            if(y!=0){
                ctx.fillText(-y/5,x,y);// 注意y轴比例
            }
        }
    }

    function getRad(degree){
        return degree/180*Math.PI;
    }

    function cutShort(str,length){
        if(str.length>length){
            str=str.substr(0,length)+"...";
        }

        return str;
    }
//-->
</script>

求x>0时,y=x^3-6x^2+15的极值的更多相关文章

  1. 求x>0时,y=x^3-6x^2+15的极值

    解: 当x→∞时,y也→∞,所以y没有最大值. y=x3-6x2+15=-4*(x/2)*(x/2)*(6-x)+15 而根据几何平均数小于等于算术平均数的定理,(x/2)*(x/2)*(6-x)在x ...

  2. chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法[bubuko.com]

    chart.js插件生成折线图时数据普遍较大时Y轴数据不从0开始的解决办法,原文:http://bubuko.com/infodetail-328671.html 默认情况下如下图 Y轴并不是从0开始 ...

  3. 2017-12-15python全栈9期第二天第七节之x or y ,x 为 非 0时,则返回x

    #!/user/bin/python# -*- coding:utf-8 -*-# x or y ,x 为 非 0时,则返回xprint(1 or 2)print(3 or 2)print(0 or ...

  4. 编写一函数用来实现左右循环移位。函数原型为move(value,n);n>0时右移n位,n<0时左移|n|位。

    #include<stdio.h> #include<stdlib.h> int main(){ setbuf(stdout,NULL); int move(int,int); ...

  5. 给定n,求1/x + 1/y = 1/n (x<=y)的解数~hdu-1299~(分解素因子详解)

    链接:https://www.nowcoder.com/acm/contest/90/F来源:牛客网 题目描述 给定n,求1/x + 1/y = 1/n (x<=y)的解数.(x.y.n均为正整 ...

  6. MySQL relay_log_purge=0 时的风险

    转自: http://xiezhenye.com/2015/12/mysql-relay_log_purge0-%E6%97%B6%E7%9A%84%E9%A3%8E%E9%99%A9.html 有时 ...

  7. .net4.0切换2.0时,SplitContainer”的对象强制转换为类型

    问 题:将dotnet framework 4.0 切换到2.0时,编译没有问题,在运行时出现如下错误:System.InvalidCastException: 无法将类型为“System.Windo ...

  8. mybatis查询参数为0时无法识别问题

    最近在工作中遇到一个mybatis参数问题,主要是列表查询按照状态进行过滤,其中已完成状态值是0,被退回是1.如图所示 , 然后Mapper里面是和平常一样的写法<if test="s ...

  9. Shell脚本中字符串判空:使用-z 字符串长度为0时,为真,-n字符串长度不为0,为真。这两个都不靠谱【转】

    最近发现使用  -z   和  -n  来判断字符串判空,或不空时,很不靠谱. 使用下面的方法最可靠: if [ "x${value}" == "x" ]    ...

随机推荐

  1. Codeforces 1104 D. Game with modulo-交互题-二分-woshizhizhang(Codeforces Round #534 (Div. 2))

    D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. SecureCRT、Xmanager对Linux上传下载文件或文件夹

    (1).SecureCRT SecureCRT对Linux上传下载文件或文件夹拥有一个专门的软件SecureFXPortable.对于它来说只有两个的难题,一个是版本问题,尽量去官网下载最近版本:另一 ...

  3. 用Chrome在手机上调试本地网页代码

    本文摘自Google 原文地址1:https://developers.google.com/web/tools/chrome-devtools/remote-debugging/?utm_sourc ...

  4. wannafly挑战赛14

    第一次打wannafly..觉得自己好菜啊... 题目描述 在三维空间中,平面 x = 0, y = 0, z = 0,以及平面 x + y + z = K 围成了一个三棱锥. 整天与整数打交道的小明 ...

  5. hdu 3547 (polya定理 + 小高精)

    DIY CubeTime Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Sub ...

  6. [xsy3241]暴风士兵

    题意:一个血量为$h$的人,它会被攻击$n$次,第$i$次有$p$的概率$-1$滴血(每次的$p$不同),问每次攻击后他的血量期望,强制在线 若一个人被扣了$i$滴血的概率为$p_i$,那么记多项式$ ...

  7. 【朱-刘算法】【最小树形图】hdu6141 I am your Father!

    题意:给你一张带权有向图,让你求最大树形图.并在此前提下令n号结点父亲的编号最小. 比赛的时候套了个二分,TLE了. 实际上可以给每个边的权值乘1000,对于n号结点的父边,加上(999-父结点编号) ...

  8. 【2-SAT(最小字典序/暴力染色)】HDU1814-Peaceful Commission

    [题目大意] 和平委员会每个党派有2个人,只能派出其中1个,其中有一些人之间互相讨厌不能同时派出.求出派遣方案,如果有多种方案输出字典序最小的方案. [思路] 最小字典序只能用暴力染色.初始时均没有染 ...

  9. [转]jquery后代和子元素的区别

    这是<锋利的jquery>书里的内容 <div>     <p>         <span></span>         <a&g ...

  10. 手Q游戏中心上线 完美释放娱乐基因

        今年A股市场上手游概念股的表现可谓“独当一面”,不少和手游沾边的公司股价都翻了倍.在笔者看来,这些手游企业的股价明显高得离谱,这轮行情可以证明资本市场对手游的关注度非常高,但并不意味着这些手游 ...