Wolfram Mathematica-功能极值

时间:2018-08-24 09:54:48

标签: wolfram-mathematica

我正在用Wolfram Mathematica做一个项目。我想找到一个函数的极值,但是它不起作用。我不知道为什么请帮我。它适用于某些功能,但不适用于功能Abs[x^2-5x+6]。我真的不知道为什么 这是问题所在:

enter image description here

   Clear[f, der1]
Manipulate[Grid
  [{{Column
     [{Row[{Framed[Style["Extrema of function", Bold, Red, 25],
          Background -> LightBlue, RoundingRadius -> 20]}]}]},        
   {Column
     [{
      InputField[Dynamic[f], Background -> LightYellow],    
      der1 = Simplify[D[f, x]],   (*the first derivative*)
      dom = Simplify[FunctionDomain[f, x, Reals]],     (*domain*)
      Reduce[der1 == y, y, Reals],   
      zeroder = Solve[der1 == 0, x ],     (*first derivative = 0*)
      discontin = 
       Solve[Denominator[Together[f]] == 0, 
        Reals], (*points of discontinuity*)
      noder = 
       Solve[Denominator[Together[der1]] == 0, 
        Reals],  (*points where the first derivative does not exist*)


      extr = 
       Union[Sort[
         Join[{axxfr}, {axxto}, {zeroder}, {noder}, {discontin}]]],  \
(*list of extrema*)
      Maximize[{f, axxfr <= x <= axxto}, x],        (*axxfr = 
      axis x from....,     axxto = axis x to....*)
      Minimize[{f, axxfr <= x <= axxto}, x], 
      Plot[f, {x, axxfr, axxto}, PlotRange -> {axyfr, axyto}, 
       Background -> LightGreen]    (*axyfr = axis y from....,    
      axyto =  axis y to....*)
      }]}}],
 {axxfr, -5}, {axxto, 5}, {axyfr, -2}, {axyto, 2}] 

0 个答案:

没有答案