{"id":10456,"date":"2025-09-29T14:29:51","date_gmt":"2025-09-29T12:29:51","guid":{"rendered":"https:\/\/spgoo.org\/?page_id=10456"},"modified":"2025-09-29T14:29:51","modified_gmt":"2025-09-29T12:29:51","slug":"fonctions-concaves-demo","status":"publish","type":"page","link":"https:\/\/spgoo.org\/?page_id=10456","title":{"rendered":"Fonctions concaves &#8211;d\u00e9mo"},"content":{"rendered":"<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/katex\/dist\/katex.min.js\"><\/script>\r\n<link href=\"https:\/\/cdn.jsdelivr.net\/npm\/katex\/dist\/katex.min.css\" rel=\"stylesheet\">\r\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/jsxgraph\/distrib\/jsxgraphcore.min.js\"><\/script>     \r\n\r\n<script>\r\n  window.MathJax = {\r\n    tex: {\r\n      inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\r\n      displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ],\r\n      packages: ['base', 'ams']\r\n    },\r\n    options: {\r\n      ignoreHtmlClass: 'tex2jax_ignore',\r\n      processHtmlClass: 'tex2jax_process'\r\n    }\r\n  };\r\n<\/script>  \r\n\r\n<script type=\"text\/javascript\" id=\"MathJax-script\"   src=\"https:\/\/cdn.jsdelivr.net\/npm\/mathjax@3\/es5\/tex-mml-chtml.js\"><\/script>\r\n<div style=\"margin:0px 0px 0px 150px;text-align:center;\">\r\n\t<h2>Fonction concave <\/h2>\r\n\t<div id=\"box1\" class=\"jxgbox\" style=\"width:500px; height:500px;margin:0px 0px 0px 180px;\"><\/div>\r\n\t<div id=\"box2\" class=\"jxgbox\" style=\"width:500px; height:100px;margin:0px 0px 0px 180px;\"><\/div>\r\n<\/div>\r\n<script type=\"text\/javascript\">\r\nJXG.Options.text.useKatex = true; \/\/ going to use Katex for all labels\r\nJXG.Options.text.cssDefaultStyle = 'font-family:KaTeX_Main, serif;font-size:4 vmin';\r\nJXG.Options.text.highlightCssDefaultStyle = 'font-family:KaTeX_Main, serif;font-size:4 vmin';\r\n\r\nvar boardCommandes = JXG.JSXGraph.initBoard(\"box2\", {pan: {enabled:false},boundingbox: [-1,4, 15,-1],\r\nwithLines:true,keepaspectratio: false, axis:false, showNavigation:false,showInfobox: false,showCopyright:false});\r\nboardCommandes.renderer.container.style.backgroundColor='#C5ADC5';\r\n\r\n\/\/ D\u00e9finition des lignes de niveau et de leur projection\r\nfunction drawLevel(view, c,a) {\r\n  var R = Math.sqrt(Math.log(a - c));\r\n  if (isNaN(R)) return;\r\n  view.create('curve3d', [(t) => 2 + R*Math.cos(t),(t) => 2 + R*Math.sin(t),(t) => c,[0, 2*Math.PI]],{strokeWidth:2, strokeColor:'#C80815', dash:2});\r\n  view.create('curve3d', [(t) => 2 + R*Math.cos(t),(t) => 2 + R*Math.sin(t),(t) => -1,[0, 2*Math.PI]], {strokeWidth:2, strokeColor:'#AE181E'});\r\n}\r\n\r\n\/* \r\nCr\u00e9ation d'un board 500 par 500 pixels utilisant MathJax\r\nA l'int\u00e9rieur de ce board (tableau) on d\u00e9finit une bo\u00eete (a,b,c,d) de la forme (a,c)(a,b)(c,b)(c,d)=(-10,-20)(-10,450)(100,450)(100,-20)\r\navec axes mais pas de lignes (donc pas de quadrillage) et pas de tics sur les axes\r\n*\/\r\nvar board=null; \r\nconst fonction_trace=function(a, niveaux) {\r\n  if (board!=null) {\r\n\t\tJXG.JSXGraph.freeBoard(board);\r\n\t}\r\n  board = JXG.JSXGraph.initBoard(\"box1\", {pan: {enabled:false},boundingbox: [-2.5,6, 10,-1],\r\n  withLines:true,keepaspectratio: true, axis:false,showNavigation:false,showInfobox: false,showCopyright:false});\r\n  board.renderer.container.style.backgroundColor='#C5ADC5';\r\n  let box = [-1, 4];\r\n  let view = board.create('view3d',[[-1, -1], [8, 8],[box, box, box]],\r\n  {\r\n    xPlaneRear: {visible: false},\r\n    yPlaneRear: {visible: false},\r\n    slider:{visible:false}\r\n  });\r\n  \/\/ Positionnement des labels \r\n  let xlabel = view.create(\"point3d\",[1.2 * box[1], 0, 1.4 * box[0] + 0.35 * box[1]], {size: 0,name: \"x\"}); \r\n  let Ylabel = view.create(\"point3d\",  [0, 1.025 * box[1], 0.6 * box[0] + 0.15 * box[1]], {size: 0,name: \"y\"});\r\n  let Zlabel = view.create(\"point3d\",[0.7 * (0.6 * box[0] + .4 * box[1]),0.7 * (0.6 * box[0] + 0.3 * box[1]),1.05 * box[1],], {size: 0,name: \"z\"});  \r\n  \/\/ Function F to be plotted\r\n  let F = (x, y) => {\r\n    let val = a - Math.exp(Math.pow(x - 2, 2) + Math.pow(y - 2,2));\r\n    return Math.max(val, 0); \/\/ Ne descend jamais sous 2\r\n  };\r\n  \r\n  \/\/ 3D surface\r\n  let surface = view.create('functiongraph3d', [F,box,box,], {strokeColor:\"#5F9EA0\",strokeWidth: 1,stepsU: 120,stepsV: 120});\r\n  for (let i=0; i<niveaux;i++) {\r\n      drawLevel(view,i*3\/niveaux,a);\r\n  }\r\n  const Xmax=2+Math.sqrt(Math.log(a));\r\n  const max=a-Math.exp(Math.pow(Xmax-2,2));\r\n  console.log(Xmax, max);\r\n\t\r\n\t\r\n}\r\n\r\n\/\/ creation du board de controle \r\nboardCommandes.create(\"text\",[-0.8,1,\"\\\\textrm{Param\u00e8tre}\"]);\r\nconst sl1=boardCommandes.create(\"slider\",[[2,1],[4,1],[4,1,10]],{snapWidth: 1,});\r\nboardCommandes.create(\"text\",[6,1,\"\\\\textrm{Niveaux}\"]);\r\nconst sl2=boardCommandes.create(\"slider\",[[8,1],[12,1],[4,0.5,10]],{snapWidth: 1,});\r\nsl1.on(\"up\",function(event) {\r\n  \/\/ on redessine l'ensemble du graphe en passant la pente \r\n  fonction_trace(sl1.Value(), sl2.Value());\r\n})\r\nsl2.on(\"up\",function(event) {\r\n  \/\/ on redessine l'ensemble du graphe en passant la pente \r\n  fonction_trace(sl1.Value(), sl2.Value());\r\n})\r\nfonction_trace(sl1.Value(), sl2.Value());\r\n<\/script>\r\n\r\n\r\n\r\n ","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-10456","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spgoo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10456"}],"version-history":[{"count":1,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10456\/revisions"}],"predecessor-version":[{"id":10457,"href":"https:\/\/spgoo.org\/index.php?rest_route=\/wp\/v2\/pages\/10456\/revisions\/10457"}],"wp:attachment":[{"href":"https:\/\/spgoo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}