I have a really long multi parameter Lorentzian function:
f = (38.4 g1^2 g2^2 Sqrt[κ2^2])/(16 g2^4 (1/10000 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (1/100 - 4 ω^2) + (1/10000 + 4 ω^2) (1 + 4 ω^2)) + 8 g2^2 ((κ2 - 4 ω^2) (1/10000 + 4 ω^2) + 4 g1^2 (κ2/100 + 4 ω^2))) + (9.6 g1^2 (κ2^2 + 4 ω^2))/(16 g2^4 (1/10000 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (1/100 - 4 ω^2) + (1/10000 + 4 ω^2) (1 + 4 ω^2)) + 8 g2^2 ((κ2 - 4 ω^2) (1/10000 + 4 ω^2) + 4 g1^2 (κ2/100 + 4 ω^2))) + (12.02 (16 g2^4 + 8 g2^2 (κ2 - 4 ω^2) + (1 + 4 ω^2) (κ2^2 + 4 ω^2)))/(16 g2^4 (1/10000 + 4 ω^2) + (κ2^2 + 4 ω^2) (16 g1^4 + 8 g1^2 (1/100 - 4 ω^2) + (1/10000 + 4 ω^2) (1 + 4 ω^2)) + 8 g2^2 ((κ2 - 4 ω^2) (1/10000 + 4 ω^2) + 4 g1^2 (κ2/100 + 4 ω^2)))
with the parameters: g1
,g2
,ω
,κ2
. I intend to do a density plot with x = g2
, y = ω
, and z = f
with fixed values of g1
and κ2
:
DensityPlot[(f/.{g1->10,κ2->10}),{g2,0,20},{ω,-25,25},AxesOrigin->{0,0},PlotRange->All,PlotLegends->Automatic]
And I'm returned with
The shape of the curves are as predicted. Notice that when g2 = 20
there is a smooth transition in gradient intensity between the blue and yellow. However, near g2 = 0
the curves appear to be box-shaped with crosses along the line. I suspect that it's a numerical error. I further plotted it with a smaller g2
range:
DensityPlot[(f/.{g1->10,κ2->10}),{g2,0,5},{ω,-25,25},AxesOrigin->{0,0},PlotRange->All,PlotLegends->Automatic]
It's clear that there must be some kind of numerical error or instability in the curves, but I'm unsure of how to remedy this. Any help would be appreciated.
PlotPoints
setting? $\endgroup$Rationalize
andSimplify
in the definition off
. CompareLeafCount /@ {f, f // Rationalize // Simplify}
. In addition to or instead of increasingPlotPoints
you could increaseMaxRecursion
. $\endgroup$