0
$\begingroup$

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 withenter image description here The shape of the curves are as predicted. Notice that when g2 = 20there is a smooth transition in gradient intensity between the blue and yellow. However, near g2 = 0the 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]

enter image description here 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.

$\endgroup$
3
  • 1
    $\begingroup$ Why haven't you already tried to increase the PlotPoints setting? $\endgroup$ Oct 9, 2018 at 17:09
  • 1
    $\begingroup$ @J.M.issomewhatokay. I'm an idiot. Thanks. $\endgroup$
    – kowalski
    Oct 9, 2018 at 17:13
  • 1
    $\begingroup$ To help maintain precision, use Rationalize and Simplify in the definition of f. Compare LeafCount /@ {f, f // Rationalize // Simplify}. In addition to or instead of increasing PlotPoints you could increase MaxRecursion. $\endgroup$
    – Bob Hanlon
    Oct 9, 2018 at 17:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.