
!distribute items $wims_read_parm into gl_notion,gl_typExple
!readproc data/glossary/mathematics/analysis/macro/randalphanum_gen
!set gl_a=$gl_rd
!readproc data/glossary/mathematics/analysis/macro/randalphanum_gen
!set gl_b=$gl_rd
!!!! Fction (ax+b)exp(cx) a!=0 et c!=0
!! a,b,c,d,borne_inf,borne_sup
!! pour exemple1 : bornes intervalle abscisse du pt d'inflexion et cette abscisse + d
!! pour exemple2 et sup : bornes borne_inf et borne_sup

!set gl_convexe_expo=-10,-5,-1/2,-5,-1,9\
10,5,1/2,11/2,-9,1\
-10,10,-1,-2,1,8\
-8,-4,-1,-5/2,-1,5\
-8,8,1,-5,-6,1\
8,-8,1,2,-6,1\
6,-5,3/5,7/2,-9,1\
-5,5,-1,-3,0,6\
-4,8,-1/4,-10,0,20\
4,-8,1/4,8,-20,2\
4,-10,1/4,19/2,-20,4\
3,-8,3/10,7,-16,3\
3,0,1,7,-7,0\
1,1,1/2,5,-12,0\

!set gl_concave_expo=10,5,-1/2,-5,-1,9\
-10,-5,1/2,11/2,-9,1\
10,-10,-1,-2,1,8\
8,4,-1,-5/2,-1,5\
8,-8,1,-5,-6,1\
-8,8,1,2,-6,1\
-6,5,3/5,7/2,-9,1\
5,-5,-1,-3,0,6\
4,-8,-1/4,-10,0,20\
-4,8,1/4,8,-20,2\
-4,10,1/4,19/2,-20,4\
-3,8,3/10,7,-16,3\
-3,0,1,7,-7,0\
-1,-1,1/2,5,-12,0\

!!set gl_convexe_expo=-8,-4,-1,-5/2,-1,5

!!set gl_concave_expo=8,4,-1,-5/2,-1,5

!!!! Fction ax^3+bx^2+cx+d = a(x^3/3-(x1+x2)x^2/2+x1*x2*x+c) a!=0
!! a,x1,x2,c,borne_inf,borne_sup
!! pour exemple1 : bornes intervalle abscisse du pt d'inflexion et cette abscisse + d
!! pour exemple2 et sup : bornes borne_inf et borne_sup
!set gl_convexe_poly=1,-2,-3,0,-6,2\
1,-1,-5,5,-7,9\
1,-4,-5,5,-9,7\
2,5,-2,0,-5,3\
2,-3,-4,-1,-5,1\
2,0,-4,-3,-6,0\
2,-5,-2,3,-4,5\
2,1,-3,2,-4,4\
2,3,-3,0,-5,1\
2,5,-2,3,-3,4\
3,4,1,4,-1,6\
3,2,1,4,0,6\
3,4,-1,1,-3,3\
3,-4,0,2,-2,4\
3,-5,-5,-1,-7,0\
4,4,-2,2,-3,3\
4,-4,1,3,0,5\
4,4,-3,-1,-5,1\
4,5,-3,-1,-5,1

!set gl_concave_poly=-1,1,-4,-2,-7,0\
-1,0,-1,0,-3,2\
-1,5,-4,1,-7,3\
-1,-5,-4,-3,-6,1\
-1,4,-5,-2,-7,0\
-2,-5,-2,2,-4,4\
-2,-3,-5,0,-7,2\
-2,1,-3,1,-5,2\
-2,0,-2,2,-4,4\
-2,-4,-5,-1,-6,0\
-2,5,-5,-1,-7,1\
-2,0,-1,1,-3,3\
-2,5,-1,2,-3,4\
-2,-3,-3,-1,-5,1\
-3,-4,-4,1,-5,2\
-3,-2,1,5,0,7\
-4,-2,-1,2,-2,4\
-4,-3,-2,3,-4,4\
-4,-3,2,7,0,8

!set gl_expo1=!randline $(gl_convexe_expo)
!set gl_expo2=!randline $(gl_concave_expo)
!set gl_expo=$gl_expo1 $\
$gl_expo2

!set gl_poly1=!randline $(gl_convexe_poly)
!set gl_poly2=!randline $(gl_concave_poly)
!set gl_poly=$gl_poly1 $\
$gl_poly2

!set gl_xsize=1
!set gl_ysize=1

!set gl_fonction_expo=
!for gl_i=1 to 2
  !set gl_affine=!exec pari $(gl_expo[$gl_i;1])*x+$(gl_expo[$gl_i;2])
  !set gl_affine2=!exec pari $(gl_expo[$gl_i;3])*x
  !if $(gl_expo[$gl_i;2])=0
    gl_func=$gl_affine*exp($(gl_expo[$gl_i;3])*x)
  !else
    gl_func=($gl_affine)*exp($(gl_expo[$gl_i;3])*x)
  !endif
  !set gl_fJs=!replace exp by Math.exp in $gl_func
  !!set gl_fAff=!replace * by $ $ in $gl_func
  !set gl_fAff=!replace exp by e^ in $gl_func
  !set gl_fAff=!texmath $gl_fAff
  !set gl_fAff=!replace e ^ by \\mathrm{e}^ in $gl_fAff
  !set gl_daffine=!exec pari $(gl_expo[$gl_i;1])*$(gl_expo[$gl_i;3])*x+$(gl_expo[$gl_i;1])+($(gl_expo[$gl_i;2])*$(gl_expo[$gl_i;3]))
  !if $[$(gl_expo[$gl_i;1])+($(gl_expo[$gl_i;2])*$(gl_expo[$gl_i;3]))]=0
    gl_dfunc=$gl_daffine*exp($(gl_expo[$gl_i;3])*x)
  !else
    gl_dfunc=($gl_daffine)*exp($(gl_expo[$gl_i;3])*x)
  !endif
  !set gl_dfuncJs=!replace exp by Math.exp in $gl_dfunc
  !set gl_dfAff=!replace exp by e^ in $gl_dfunc
  !set gl_dfAff=!texmath $gl_dfAff
  !set gl_dfAff=!replace e ^ by \\mathrm{e}^ in $gl_dfAff
  !set gl_d2affine=!exec pari $(gl_expo[$gl_i;1])*($(gl_expo[$gl_i;3]))^2*x+2*$(gl_expo[$gl_i;1])*($(gl_expo[$gl_i;3]))+($(gl_expo[$gl_i;2])*($(gl_expo[$gl_i;3]))^2)
  !if $[2*$(gl_expo[$gl_i;1])*($(gl_expo[$gl_i;3]))+($(gl_expo[$gl_i;2])*($(gl_expo[$gl_i;3]))^2)]=0
    gl_d2func=$gl_d2affine*exp($(gl_expo[$gl_i;3])*x)
  !else
    gl_d2func=($gl_d2affine)*exp($(gl_expo[$gl_i;3])*x)
  !endif
  !set gl_d2fAff=!replace exp by e^ in $gl_d2func
  !set gl_d2fAff=!texmath $gl_d2fAff
  !set gl_d2fAff=!replace e ^ by \\mathrm{e}^ in $gl_d2fAff
  gl_fonction_expo=$gl_fonction_expo $\
  $gl_func,$gl_fJs,$gl_fAff,$gl_dfunc,$gl_dfuncJs,$gl_dfAff,$gl_d2func,$gl_d2fAff,$gl_affine,$gl_affine2
!next $gl_i

!set gl_fonction_poly=
!for gl_ii=1 to 2
  !set gl_func=!exec pari ($(gl_poly[$gl_ii;1])*(((x)^3)/3-((x)^2)/2*($(gl_poly[$gl_ii;3])+$(gl_poly[$gl_ii;4]))+$(gl_poly[$gl_ii;3])*$(gl_poly[$gl_ii;4])*(x)+$(gl_poly[$gl_ii;2])))
  !set gl_fJs=!replace x^3 by Math.pow(x,3) in $gl_func
  !set gl_fJs=!replace x^2 by Math.pow(x,2) in $gl_fJs
  !!set gl_fAff=!replace * by $ $ in $gl_func
  !set gl_fAff=!texmath $gl_func
  !set gl_dfunc=!exec pari $(gl_poly[$gl_ii;1])*(x^2-($(gl_poly[$gl_ii;3])+$(gl_poly[$gl_ii;4]))*x+$(gl_poly[$gl_ii;3])*$(gl_poly[$gl_ii;4]))
  !set gl_dfuncJs=!replace x^2 by Math.pow(x,2) in $gl_dfunc
  !set gl_dfAff=!texmath $gl_dfunc
  !set gl_d2func=!exec pari deriv($gl_dfunc,{x})
  !set gl_d2fAff=!texmath $gl_d2func
  gl_fonction_poly=$gl_fonction_poly $\
  $gl_func,$gl_fJs,$gl_fAff,$gl_dfunc,$gl_dfuncJs,$gl_dfAff,$gl_d2func,$gl_d2fAff
!next $gl_ii


!!!Choix famille de fonctions
!set gl_choix=!randint 0,1
!if $gl_choix=0
  !set gl_elem=$gl_expo
  !set gl_fonction=$gl_fonction_expo
!else
  !set gl_elem=$gl_poly
  !set gl_fonction=$gl_fonction_poly
!endif

gl_fonction= !translate internal $\
$ to ; in $gl_fonction

gl_fonction=$(gl_fonction[2..-1;])

gl_elem= !translate internal $\
$ to ; in $gl_elem

!!gl_elem=$(gl_elem[2..-1;])

!!! Data pour fonction avec changement de concavit
!!! 1 pour convexe et 2 pour concave
!set gl_choixConv=!randint 1,2
!set gl_compl=!listcomplement $gl_choixConv in 1,2
!set gl_elemtyp3=$(gl_elem[$gl_choixConv;])
!set gl_fonctiontyp3=$(gl_fonction[$gl_choixConv;])

!!! On ajoute
!set gl_elem=$gl_elem $\
$gl_elemtyp3

!set gl_fonction=$gl_fonction $\
$gl_fonctiontyp3

gl_fonction= !translate internal $\
$ to ; in $gl_fonction

gl_elem= !translate internal $\
$ to ; in $gl_elem

!!!! gl_typExple= i pour exemple dynamique i
!!!! si gl_num=1 --> convexe, si gl_num=2 --> concave, si gl_num=3 --> pt inf
!!!! gl_fin indique le nombre d'applets  crer
!!!! si secTgte=1 --> scante si secTgte=2 --> tangente

!if $gl_notion=convexity
  !if $gl_typExple=1
    !set gl_num=0
    !set gl_secTgte=1
    !set gl_fin=2
    !set gl_elem=$(gl_elem[1,2;])
    !set gl_fonction=$(gl_fonction[1,2;])
  !else
    !if $gl_typExple=2
      !set gl_num=0
      !set gl_secTgte=1
    	!set gl_fin=1
    	!set gl_elem=$(gl_elem[3;])
      !set gl_fonction=$(gl_fonction[3;])
    !else
      !if $gl_typExple isin 345
        !set gl_num=!randint 1,3
    	  !set gl_secTgte=2
        !set gl_fin=1
        !set gl_elem=$(gl_elem[$gl_num;])
    	  !set gl_fonction=$(gl_fonction[$gl_num;])
  	  !endif
    !endif
  !endif
!else
  !if $gl_notion=inflexion
    !set gl_num=3
    !set gl_secTgte=2
    !set gl_fin=1
    !set gl_elem=$(gl_elem[$gl_num;])
    !set gl_fonction=$(gl_fonction[$gl_num;])
  !endif
!endif


!set gl_absimag=
!for gl_j=1 to $gl_fin
  !if $gl_choix=0
    !set gl_x0=!exec pari -2/($(gl_elem[$gl_j;3]))-($(gl_elem[$gl_j;2]))/$(gl_elem[$gl_j;1])
    !set gl_x1=!exec pari $gl_x0+$(gl_elem[$gl_j;4])
  !else
    !set gl_x0=!exec pari ($(gl_elem[$gl_j;3])+($(gl_elem[$gl_j;4])))/2
    !set gl_x1=!exec pari (abs($(gl_elem[$gl_j;1])))*($(gl_elem[$gl_j;4])-($(gl_elem[$gl_j;3])))/2
  !endif
  !set gl_fdex0=!mathsubst x=($gl_x0) in $(gl_fonction[$gl_j;1])
  !set gl_fdex1=!mathsubst x=($gl_x1) in $(gl_fonction[$gl_j;1])
  !if ($gl_notion=convexity and ($gl_typExple=2 or ($gl_typExple isin 345 and $gl_num=3))) or ($gl_notion=inflexion)
    !set gl_xmin=$(gl_elem[$gl_j;5])
    !set gl_xmax=$(gl_elem[$gl_j;6])
  !else
    !set gl_xmin=!exec pari min($gl_x0,$gl_x1)
    !set gl_xmax=!exec pari max($gl_x0,$gl_x1)
  !endif
  !set gl_fdexmin=!mathsubst x=($gl_xmin) in $(gl_fonction[$gl_j;1])
  !set gl_fdexmax=!mathsubst x=($gl_xmax) in $(gl_fonction[$gl_j;1])
  !if ($gl_notion=convexity and ($gl_typExple=2 or ($gl_typExple isin 345 and $gl_num=3))) or ($gl_notion=inflexion)
    !set gl_xA=$[$gl_xmin+($gl_x0-$gl_xmin)/4]
    !set gl_xB=$[$gl_x0-($gl_x0-$gl_xmin)/4]
  !else
    !set gl_xA=$[$gl_x0+($gl_x1-$gl_x0)/4]
    !set gl_xB=$[$gl_x1-($gl_x1-$gl_x0)/4]
  !endif
  !set gl_fdexA=!mathsubst x=($gl_xA) in $(gl_fonction[$gl_j;1])
  !set gl_fdexB=!mathsubst x=($gl_xB) in $(gl_fonction[$gl_j;1])
  !if $gl_notion=convexity and $gl_typExple=2
    !set gl_xC=$[$gl_x0+($gl_xmax-$gl_x0)/4]
    !set gl_fdexC=!mathsubst x=($gl_xC) in $(gl_fonction[$gl_j;1])
    !set gl_xD=$[$gl_xmax-($gl_xmax-$gl_x0)/4]
    !set gl_fdexD=!mathsubst x=($gl_xD) in $(gl_fonction[$gl_j;1])
  !endif
  !if $gl_choix=0
    !set gl_z0=$[-($(gl_elem[$gl_j;2]))/($(gl_elem[$gl_j;1]))-1/($(gl_elem[$gl_j;3]))]
    !set gl_z1=1
  !else
    !set gl_z0=$[$(gl_elem[$gl_j;3])]
    !set gl_z1=$[$(gl_elem[$gl_j;4])]
  !endif
  !set gl_fdez0=!mathsubst x=($gl_z0) in $(gl_fonction[$gl_j;1])
  !set gl_fdez1=!mathsubst x=($gl_z1) in $(gl_fonction[$gl_j;1])
  !if ($gl_xmin<=$gl_z0 and $gl_z0<=$gl_xmax)
    !set gl_ymin=!exec pari min(min($[$gl_fdexmin],$[$gl_fdexmax]),$[$gl_fdez0])
    !set gl_ymax=!exec pari max(max($[$gl_fdexmin],$[$gl_fdexmax]),$[$gl_fdez0])
  !else
    !set gl_ymin=!exec pari min($[$gl_fdexmin],$[$gl_fdexmax])
    !set gl_ymax=!exec pari max($[$gl_fdexmin],$[$gl_fdexmax])
  !endif
  !if ($gl_xmin<=$gl_z1 and $gl_z1<=$gl_xmax and $gl_choix=1)
    !set gl_ymin=!exec pari min($gl_ymin,$[$gl_fdez1])
    !set gl_ymax=!exec pari max($gl_ymax,$[$gl_fdez1])
  !endif
  !if $gl_xmin>=0
    !set gl_xminbox=!exec pari min($gl_xmin,$[-0.05*abs($gl_xmax)])
  !else
    !set gl_xminbox=$gl_xmin
  !endif
  !if $gl_xmax<=0
    !set gl_xmaxbox=!exec pari max($gl_xmax,$[0.05*abs($gl_xmin)])
  !else
    !set gl_xmaxbox=$gl_xmax
  !endif
  !if $gl_ymin>=0
    !set gl_yminbox=!exec pari min($gl_ymin,$[-0.05*abs($gl_ymax)])
  !else
    !set gl_yminbox=$gl_ymin
  !endif
  !if $gl_ymax<=0
    !set gl_ymaxbox=!exec pari max($gl_ymax,$[0.05*abs($gl_ymin)])
  !else
    !set gl_ymaxbox=$gl_ymax
  !endif
  !set gl_margex=$[($gl_xmaxbox-$gl_xminbox)*0.07]
  !set gl_margey=$[($gl_ymaxbox-$gl_yminbox)*0.07]
  !if $gl_notion=convexity and $gl_typExple isin 1345
    gl_absimag=$gl_absimag $\
    $gl_x0,$[$gl_fdex0],$gl_x1,$[$gl_fdex1],$gl_xA,$[$gl_fdexA],$gl_xB,$[$gl_fdexB],$gl_xmin,$[$gl_fdexmin],$gl_xmax,$[$gl_fdexmax],$gl_z0,$[$gl_fdez0],$gl_ymin,$gl_ymax,$gl_xminbox,$gl_xmaxbox,$gl_yminbox,$gl_ymaxbox,$gl_margex,$gl_margey,$gl_z1,$[$gl_fdez1]
  !else
    gl_absimag=$gl_absimag $\
    $gl_x0,$[$gl_fdex0],$gl_x1,$[$gl_fdex1],$gl_xA,$[$gl_fdexA],$gl_xB,$[$gl_fdexB],$gl_xmin,$[$gl_fdexmin],$gl_xmax,$[$gl_fdexmax],$gl_z0,$[$gl_fdez0],$gl_ymin,$gl_ymax,$gl_xminbox,$gl_xmaxbox,$gl_yminbox,$gl_ymaxbox,$gl_margex,$gl_margey,$gl_z1,$[$gl_fdez1],$gl_xC,$[$gl_fdexC],$gl_xD,$[$gl_fdexD]
  !endif
!next $gl_j

gl_absimag= !translate internal $\
$ to ; in $gl_absimag

gl_absimag=$(gl_absimag[2..-1;])

!!! JSXGrapf


!set gl_JXGOptions=JXG.Options.text.cssDefaultStyle = '';\
JXG.Options.text.highlightCssDefaultStyle = '';\
JXG.Options.axis.lastArrow = false;\
JXG.Options.elements.highlight=false;\
JXG.Options.point.showInfobox=false;\
JXG.Options.text.useMathJax = true;\
JXG.Options.elements.tabindex = -1;

!set gl_BoardOptions=axis:true,\
grid:false,\
drawZero:true,\
showCopyright : false,\
showNavigation:false,\
showZoom : true,\
keepaspectratio : false,\
zoom: {factorX: 1.10,factorY: 1.10,wheel: true,needShift: true,eps: 0.001},\
pan: {\
needShift: true,\
enabled: true,\
needTwoFingers: true,\
pinchHorizontal: true,\
pinchVertical: true,\
pinchSensitivity: 7}

!set gl_code_1=
!set gl_code_2=
!for gl_k=1 to $gl_fin
  gl_code_$(gl_k)=const brd$(gl_a)$(gl_k) = JXG.JSXGraph.initBoard('id$(gl_a)$(gl_k)', {boundingbox:[$[$(gl_absimag[$gl_k;17])-$(gl_absimag[$gl_k;21])],$[$(gl_absimag[$gl_k;20])+$(gl_absimag[$gl_k;22])],$[$(gl_absimag[$gl_k;18])+$(gl_absimag[$gl_k;21])],$[$(gl_absimag[$gl_k;19])-$(gl_absimag[$gl_k;22])]],$gl_BoardOptions});\
    brd$(gl_a)$(gl_k).renderer.displayCopyright('Figure ralise avec JSXGraph v'+JXG.version,11);\
    let cf_$(gl_a)$(gl_k),cf1_$(gl_a)$(gl_k),cf2_$(gl_a)$(gl_k);\
    let ptO_$(gl_a)$(gl_k),ptA_$(gl_a)$(gl_k),ptB_$(gl_a)$(gl_k),ptC_$(gl_a)$(gl_k), ptD_$(gl_a)$(gl_k),ptQ_$(gl_a)$(gl_k),ptE_$(gl_a)$(gl_k),ptF_$(gl_a)$(gl_k),ptM_$(gl_a)$(gl_k),ptI_$(gl_a)$(gl_k),ptG_$(gl_a)$(gl_k),ptN_$(gl_a)$(gl_k);\
    let seg_$(gl_a)$(gl_k),seg2_$(gl_a)$(gl_k),secte_$(gl_a)$(gl_k),tgte_$(gl_a)$(gl_k),intervalle_$(gl_a)$(gl_k),vert1_$(gl_a)$(gl_k),vert2_$(gl_a)$(gl_k),vert3_$(gl_a)$(gl_k),vert4_$(gl_a)$(gl_k);\
    let secTgte$(gl_a)$(gl_k)=$gl_secTgte;\
    let typExple$(gl_a)$(gl_k)=$gl_typExple;\
    const notion$(gl_a)$(gl_k)="$gl_notion";\
    let kkJs$(gl_a)$(gl_k)=$gl_k;\
    let numJs$(gl_a)$(gl_k)=$gl_num;\
    ptO_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [0, 0],{size:2,face:'+',strokeWidth:2,color:"black",name:'O',label:{autoPosition:true,offset:[5,-10]},fixed:true});\
    if (notion$(gl_a)$(gl_k)=="convexity" && (typExple$(gl_a)$(gl_k) ==1 || (typExple$(gl_a)$(gl_k)>=3 && numJs$(gl_a)$(gl_k)<3))){\
      cf_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('functiongraph',[function(x){ return $(gl_fonction[$gl_k;2]);}, $(gl_absimag[$gl_k;9]), $(gl_absimag[$gl_k;11])],{strokeWidth:2});\
      ptN_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;3]),$(gl_absimag[$gl_k;4])],{size:0,face:'',strokeWidth:2,color:"transparent",name:'\(\mathcal{C}\)',label:{autoPosition:true,offset:[5,10]},fixed:true});\
      ptA_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;5]), $(gl_absimag[$gl_k;6]), cf_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
      if(secTgte$(gl_a)$(gl_k)==1){\
        ptB_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;7]), $(gl_absimag[$gl_k;8]), cf_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        seg_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptA_$(gl_a)$(gl_k),ptB_$(gl_a)$(gl_k)],{strokeWidth:2,color:"orange"});\
        secte_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('line',[ptA_$(gl_a)$(gl_k),ptB_$(gl_a)$(gl_k)],{dash:2,color:"orange"});\
      }else{\
        ptQ_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point',[function(){return ptA_$(gl_a)$(gl_k).X()+1;},function() {return ptA_$(gl_a)$(gl_k).Y()+JXG.Math.Numerics.D(cf_$(gl_a)$(gl_k).Y)(ptA_$(gl_a)$(gl_k).X());}], { name:'Q',visible:false});\
        tgte_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('line',[ptA_$(gl_a)$(gl_k),ptQ_$(gl_a)$(gl_k)],{color:"orange"});\
      }\
      ptE_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;1]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
      ptF_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;3]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
      intervalle_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptE_$(gl_a)$(gl_k),ptF_$(gl_a)$(gl_k)],{strokeWidth:4,strokeColor:"green",name:'',label:{autoPosition:true,offset:[5,10],},fixed:true});\
      ptM_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('midpoint', [ptE_$(gl_a)$(gl_k), ptF_$(gl_a)$(gl_k)],{size:0,face:'',strokeWidth:2,color:"black",name:'I',label:{autoPosition:true,offset:[5,15],cssClass: 'myFont',strokeColor:'green',fontSize:16}});\
      vert1_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptE_$(gl_a)$(gl_k),[$(gl_absimag[$gl_k;1]),$(gl_absimag[$gl_k;2])]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
      vert2_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptF_$(gl_a)$(gl_k),[$(gl_absimag[$gl_k;3]),$(gl_absimag[$gl_k;4])]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
    }else{\
      cf_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('functiongraph',[function(x){ return $(gl_fonction[$gl_k;2]);}, $(gl_absimag[$gl_k;9]), $(gl_absimag[$gl_k;11])],{strokeWidth:2,strokeColor:'transparent'});\
      cf1_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('functiongraph',[function(x){ return $(gl_fonction[$gl_k;2]);}, $(gl_absimag[$gl_k;9]), $(gl_absimag[$gl_k;1])],{strokeWidth:2});\
      cf2_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('functiongraph',[function(x){ return $(gl_fonction[$gl_k;2]);}, $(gl_absimag[$gl_k;1]), $(gl_absimag[$gl_k;11])],{strokeWidth:2,strokeColor:'red'});\
      if(secTgte$(gl_a)$(gl_k)==2){\
        ptA_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;5]), $(gl_absimag[$gl_k;6]), cf_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        ptQ_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point',[function(){return ptA_$(gl_a)$(gl_k).X()+1;},function() {return ptA_$(gl_a)$(gl_k).Y()+JXG.Math.Numerics.D(cf_$(gl_a)$(gl_k).Y)(ptA_$(gl_a)$(gl_k).X());}], { name:'Q',visible:false});\
        tgte_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('line',[ptA_$(gl_a)$(gl_k),ptQ_$(gl_a)$(gl_k)],{color:"orange"});\
      }else{\
        ptA_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;5]), $(gl_absimag[$gl_k;6]), cf1_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        ptB_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;7]), $(gl_absimag[$gl_k;8]), cf1_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        seg_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptA_$(gl_a)$(gl_k),ptB_$(gl_a)$(gl_k)],{strokeWidth:2,color:"orange"});\
        ptC_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;25]), $(gl_absimag[$gl_k;26]), cf2_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        ptD_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('glider', [$(gl_absimag[$gl_k;27]), $(gl_absimag[$gl_k;28]), cf2_$(gl_a)$(gl_k)],{size:2,strokeWidth:2,color:"orange",tabindex:10,label:{autoPosition:true,offset:[5,10]}});\
        seg2_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptC_$(gl_a)$(gl_k),ptD_$(gl_a)$(gl_k)],{strokeWidth:2,color:"orange"});\
      }\
      ptI_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point',[$(gl_absimag[$gl_k;1]),$(gl_absimag[$gl_k;2])],{face:'+',color:"black",strokeWidth:2,label:{visible:false},fixed:true});\
      ptE_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;9]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
      ptF_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;11]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
      ptG_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;1]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
      vert1_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptE_$(gl_a)$(gl_k),[$(gl_absimag[$gl_k;9]),$(gl_absimag[$gl_k;10])]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
      vert2_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptF_$(gl_a)$(gl_k),[$(gl_absimag[$gl_k;11]),$(gl_absimag[$gl_k;12])]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
      vert3_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptI_$(gl_a)$(gl_k),ptG_$(gl_a)$(gl_k)],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
      vert4_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptI_$(gl_a)$(gl_k),[0,$(gl_absimag[$gl_k;2])]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
      intervalle_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('segment',[ptE_$(gl_a)$(gl_k),ptF_$(gl_a)$(gl_k)],{strokeWidth:4,strokeColor:"green",name:'I',label:{autoPosition:true,offset:[5,10]},fixed:true});\
      ptN_$(gl_a)$(gl_k)=brd$(gl_a)$(gl_k).create('point', [$(gl_absimag[$gl_k;11]),$(gl_absimag[$gl_k;12])],{size:0,face:'',strokeWidth:2,color:"transparent",name:'\(\mathcal{C}\)',label:{autoPosition:true,offset:[5,10]},fixed:true});\
    }\
    ptA_$(gl_a)$(gl_k).on('over',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grab';}});\
    ptA_$(gl_a)$(gl_k).on('down',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grabbing';}});\
    ptA_$(gl_a)$(gl_k).on('up',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
    ptA_$(gl_a)$(gl_k).on('out',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
    if(secTgte$(gl_a)$(gl_k)==1){\
      ptB_$(gl_a)$(gl_k).on('over',(e) => {if (! ptB_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grab';}});\
      ptB_$(gl_a)$(gl_k).on('down',(e) => {if (! ptB_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grabbing';}});\
      ptB_$(gl_a)$(gl_k).on('up',(e) => {if (! ptB_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
      ptB_$(gl_a)$(gl_k).on('out',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
    }\
    if(notion$(gl_a)$(gl_k)=="convexity" && typExple$(gl_a)$(gl_k) ==2){\
      ptC_$(gl_a)$(gl_k).on('over',(e) => {if (! ptC_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grab';}});\
      ptC_$(gl_a)$(gl_k).on('down',(e) => {if (! ptC_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grabbing';}});\
      ptC_$(gl_a)$(gl_k).on('up',(e) => {if (! ptC_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
      ptC_$(gl_a)$(gl_k).on('out',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
      ptD_$(gl_a)$(gl_k).on('over',(e) => {if (! ptD_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grab';}});\
      ptD_$(gl_a)$(gl_k).on('down',(e) => {if (! ptD_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'grabbing';}});\
      ptD_$(gl_a)$(gl_k).on('up',(e) => {if (! ptD_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
      ptD_$(gl_a)$(gl_k).on('out',(e) => {if (! ptA_$(gl_a)$(gl_k).visProp.fixed) {brd$(gl_a)$(gl_k).containerObj.style.cursor = 'default';}});\
    }
!next $gl_k

!if $gl_notion=convexity
  !if $gl_typExple=1
    !set gl_script$(gl_a)1=$gl_JXGOptions\
    $gl_code_1
    !set gl_script$(gl_a)2=$gl_JXGOptions\
    $gl_code_2
    !set gl_aa1=!texmath $(gl_absimag[1;9])
    !set gl_bb1=!texmath $(gl_absimag[1;11])
    !set gl_aa2=!texmath $(gl_absimag[2;9])
    !set gl_bb2=!texmath $(gl_absimag[2;11])
  !else
    !if $gl_typExple=2
      !set gl_script$(gl_a)1=$gl_JXGOptions\
      $gl_code_1
      !if $(gl_absimag[1;3])>$(gl_absimag[1;1])
        !set gl_typeConv=$gl_compl,$gl_choixConv
      !else
        !set gl_typeConv=$gl_choixConv,$gl_compl
      !endif
      !set gl_infl=!texmath $(gl_absimag[1;1])
      !set gl_aa1=!texmath $(gl_absimag[1;9])
      !set gl_bb1=!texmath $(gl_absimag[1;11])
    !else
      !if $gl_typExple isin 345
        !set gl_script$(gl_a)1=$gl_JXGOptions\
        $gl_code_1
        !set gl_aa1=!texmath $(gl_absimag[1;9])
        !set gl_bb1=!texmath $(gl_absimag[1;11])
        !if $gl_num=3
          !set gl_infl=!texmath $(gl_absimag[1;1])
          !if $(gl_absimag[1;3])>$(gl_absimag[1;1])
            !set gl_typeConv=$gl_compl,$gl_choixConv
          !else
            !set gl_typeConv=$gl_choixConv,$gl_compl
          !endif
        !endif
      !endif
    !endif
  !endif
!else
  !set gl_script$(gl_a)1=$gl_JXGOptions\
       $gl_code_1
  !set gl_aa1=!texmath $(gl_absimag[1;9])
  !set gl_bb1=!texmath $(gl_absimag[1;11])
  !set gl_infl=!texmath $(gl_absimag[1;1])
  !if $gl_choix=1
    !set gl_infly=!exec pari subst($(gl_fonction[1;1]),x,($(gl_absimag[1;1])))
    gl_infly=!texmath $gl_infly
  !else
    !set gl_af1=!exec pari subst($(gl_fonction[1;9]),x,($(gl_absimag[1;1])))
    !set gl_af2=!exec pari subst($(gl_fonction[1;10]),x,($(gl_absimag[1;1])))
    !if $gl_af2=1
      !set gl_infly=$gl_af1*e
      gl_infly=!texmath $gl_infly
      gl_infly=!replace e by \\mathrm{e} in $gl_infly
    !else
      !set gl_infly=$gl_af1*exp($gl_af2)
      gl_infly=!replace exp by e^ in $gl_infly
      gl_infly=!texmath $gl_infly
      gl_infly=!replace e ^ by \\mathrm{e}^ in $gl_infly
    !endif
  !endif
  !if $(gl_absimag[1;3])>$(gl_absimag[1;1])
    !set gl_typeConv=$gl_compl,$gl_choixConv
  !else
    !set gl_typeConv=$gl_choixConv,$gl_compl
  !endif
!endif

!if $gl_notion=convexity and $gl_typExple=4
  !! Courbe de la drive
  !set gl_dfdex0=!mathsubst x=($(gl_absimag[1;1])) in $(gl_fonction[1;4])
  !set gl_dfdexmin=!mathsubst x=($(gl_absimag[1;9])) in $(gl_fonction[1;4])
  !set gl_dfdexmax=!mathsubst x=($(gl_absimag[1;11])) in $(gl_fonction[1;4])
  !set gl_dymin=!exec pari min(min($[$gl_dfdexmin],$[$gl_dfdexmax]),$[$gl_dfdex0])
  !set gl_dymax=!exec pari max(max($[$gl_dfdexmin],$[$gl_dfdexmax]),$[$gl_dfdex0])
  !if $(gl_absimag[1;9])>=0
    !set gl_dxminbox=!exec pari min($(gl_absimag[1;9]),$[-0.05*abs($(gl_absimag[1;11]))])
  !else
    !set gl_dxminbox=$(gl_absimag[1;9])
  !endif
  !if $(gl_absimag[1;11])<=0
    !set gl_dxmaxbox=!exec pari max($(gl_absimag[1;11]),$[0.05*abs($(gl_absimag[1;9]))])
  !else
    !set gl_dxmaxbox=$(gl_absimag[1;11])
  !endif
  !if $gl_dymin>=0
    !set gl_dyminbox=!exec pari min($gl_dymin,$[-0.05*abs($gl_dymax)])
  !else
    !set gl_dyminbox=$gl_dymin
  !endif
  !if $gl_dymax<=0
    !set gl_dymaxbox=!exec pari max($gl_dymax,$[0.05*abs($gl_dymin)])
  !else
    !set gl_dymaxbox=$gl_dymax
  !endif
  !set gl_dmargex=$[($gl_dxmaxbox-$gl_dxminbox)*0.07]
  !set gl_dmargey=$[($gl_dymaxbox-$gl_dyminbox)*0.07]

  !set gl_deriv=const brd$gl_b = JXG.JSXGraph.initBoard('id$gl_b', {boundingbox:[$[$gl_dxminbox-$gl_dmargex],$[$gl_dymaxbox+$gl_dmargey],$[$gl_dxmaxbox+$gl_dmargex],$[$gl_dyminbox-$gl_dmargey]],$gl_BoardOptions});\
    brd$gl_b.renderer.displayCopyright('Figure ralise avec JSXGraph v'+JXG.version,11);\
    brd$(gl_a)1.addChild(brd$gl_b);\
    let numJs$gl_b=$gl_num;\
    let cf_$gl_b,cf1_$gl_b,cf2_$gl_b;\
    let ptO_$gl_b,ptN_$gl_b,ptM_$gl_b,ptR_$gl_b,ptE_$gl_b,ptF_$gl_b,ptI_$gl_b;\
    let intervalle_$gl_b,vert1_$gl_b,vert2_$gl_b,vert3_$gl_b,horiz_$gl_b;\
    ptO_$gl_b=brd$gl_b.create('point', [0, 0],{size:2,face:'+',strokeWidth:2,color:"black",name:'O',label:{autoPosition:true,offset:[5,-10]},fixed:true});\
    if(numJs$gl_b<3){\
      cf_$gl_b=brd$gl_b.create('functiongraph',[function(x){ return $(gl_fonction[1;5]);}, $(gl_absimag[1;9]), $(gl_absimag[1;11])],{strokeWidth:2});\
    }else{\
      cf_$gl_b=brd$gl_b.create('functiongraph',[function(x){ return $(gl_fonction[1;5]);}, $(gl_absimag[1;9]), $(gl_absimag[1;11])],{strokeWidth:2,strokeColor:'transparent'});\
      cf1_$gl_b=brd$gl_b.create('functiongraph',[function(x){ return $(gl_fonction[1;5]);}, $(gl_absimag[1;9]), $(gl_absimag[1;1])],{strokeWidth:2});\
      cf2_$gl_b=brd$gl_b.create('functiongraph',[function(x){ return $(gl_fonction[1;5]);}, $(gl_absimag[1;1]), $(gl_absimag[1;11])],{strokeWidth:2,strokeColor:'red'});\
    }\
    ptN_$gl_b=brd$gl_b.create('point', [$(gl_absimag[1;11]),$[$gl_dfdexmax]],{size:0,face:'',strokeWidth:2,color:"transparent",name:'\(\mathcal{C}_{f'}\)',label:{autoPosition:true,offset:[5,10]},fixed:true});\
    ptM_$gl_b=brd$gl_b.create('point',[function(){return ptA_$(gl_a)1.X();},function(){return JXG.Math.Numerics.D(cf_$(gl_a)1.Y)(ptA_$(gl_a)1.X());}],{size:2,face:'+',strokeWidth:2,color:"orange",name:'M',label:{autoPosition:true,offset:[5,-10]},fixed:true});\
    ptR_$gl_b=brd$gl_b.create('point',[0,function(){return ptM_$gl_b.Y();}],{size:2,face:'+',strokeWidth:2,color:"orange",name:'',label:{visible:false}});\
    ptE_$gl_b=brd$gl_b.create('point', [$(gl_absimag[1;9]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
    ptF_$gl_b=brd$gl_b.create('point', [$(gl_absimag[1;11]),0],{size:5,face:'+',strokeWidth:2,color:"green",name:'',label:{visible:false},fixed:true});\
    horiz_$gl_b=brd$gl_b.create('segment',[ptR_$gl_b,ptM_$gl_b],{strokeWidth:2,color:"orange",name:'',dash:2,fixed:true});\
    vert1_$gl_b=brd$gl_b.create('segment',[ptE_$gl_b,[$(gl_absimag[1;9]),$[$gl_dfdexmin]]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
    vert2_$gl_b=brd$gl_b.create('segment',[ptF_$gl_b,[$(gl_absimag[1;11]),$[$gl_dfdexmax]]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
    intervalle_$gl_b=brd$gl_b.create('segment',[ptE_$gl_b,ptF_$gl_b],{strokeWidth:4,strokeColor:"green",name:'I',label:{autoPosition:true,offset:[5,10]},fixed:true});\
    if(numJs$gl_b==3){\
      ptI_$gl_b=brd$gl_b.create('point',[$(gl_absimag[1;1]),$[$gl_dfdex0]],{face:'+',color:"black",strokeWidth:2,label:{visible:false},fixed:true});\
      vert3_$gl_b=brd$gl_b.create('segment',[ptI_$gl_b,[$(gl_absimag[1;1]),0]],{strokeWidth:2,color:"lightgreen",name:'',dash:2,fixed:true});\
    }\
    brd$gl_b.fullUpdate();

  !set gl_script$(gl_b)=$gl_JXGOptions\
  $gl_deriv
!endif



!!set gl_result0=$gl_infly01
!!set gl_result1=$gl_infly02
!!set gl_result2=\($gl_infly03\)
!!set gl_result3=\($gl_infly04\)
!!set gl_result4=id$(gl_a)1
