1
$\begingroup$

I've got a way to calculate Gaussian curvature from here (which was written by J. M.). But when I applied it to the following function, I got a lot of error messages.

GaussianCurvature[f_, {u_, v_}] := 
  Simplify[(Det[{D[f, {u, 2}], D[f, u], D[f, v]}] Det[{D[f, {v, 2}], 
         D[f, u], D[f, v]}] - 
      Det[{D[f, u, v], D[f, u], 
         D[f, v]}]^2)/(D[f, u].D[f, u] D[f, v].D[f, 
          v] - (D[f, u].D[f, v])^2)^2];

Options[gccolor]=DeleteCases[Options[ParametricPlot3D],\
ColorFunctionScaling\[Rule]_];
(gccolor[f_, {u_, ura__}, {v_, vra__}, opts : OptionsPattern[]] := 
   Module[{cf = OptionValue[ColorFunction], gc}, 
    If[cf === Automatic, cf = ColorData["ThermometerColors"]];
    gc[u_, v_] = GaussianCurvature[f, {u, v}];
    ParametricPlot3D[f, {u, ura}, {v, vra}, 
     ColorFunction -> 
      Function[{x, y, z, u, v}, cf[1/(1 + Exp[-2 gc[u, v]])]], 
     ColorFunctionScaling -> False, 
     Evaluate[FilterRules[{opts}, Options[gccolor]]], 
     Lighting -> "Neutral"]]) // Quiet

gccolor[{x, 
   y, (x^4 - 6 x^2 y^2 + y^4)/(x^2 + y^2)^2 BesselJ[4, 
     17 Sqrt[x^2 + y^2]]} /. {x -> u, y -> v}, {u, -1, 1}, {v, -1, 1}]

How can I modify these codes to avoid corresponding errors (such as replacing 1 / 0. Curvature with 10 ^ 5).

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ The errors you are seeing are due to a change in version 12 regarding the handling of underflow, see e.g. this. You might consider increasing the WorkingPrecision setting if this bothers you. $\endgroup$ Jan 30 '20 at 2:43
  • $\begingroup$ In version 12.0, I set SetSystemOptions["CheckMachineUnderflow"->False], this setting disable detection of machine underflow.Thank you very much. $\endgroup$ Jan 30 '20 at 3:15
2
$\begingroup$

J. M. is in limbo♦ code seems to work when sections not commented out.

enter image description here

MMA v11.2

$\endgroup$
3
  • $\begingroup$ I'm not sure why the OP commented out that line either. O well. In any case, it looks like I need to do better at localizing variables; I'll have to think about this. $\endgroup$ Jan 30 '20 at 2:33
  • $\begingroup$ Did you turn off the general warning message? $\endgroup$ Jan 30 '20 at 2:54
  • 2
    $\begingroup$ Manuel is working in 11.2, which did not have the underflow trouble you are seeing in version 12. $\endgroup$ Jan 30 '20 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.