0
$\begingroup$

I am having some issues using PlotPoints in ContourPlot. In the following code, depending on the PlotPoints the plot looks very different and having more points doesn't necessarily give the correct plot.

c = 3; f1 = 91.8; f2 = 89.9; A = 56; B = 50;
T12 = (1/(1 + (0.63*A)^2*(Sin[Pi/(x1*10^-9)*c/f1])^2))*(1/(1 + (0.63*B)^2*(Sin[Pi/(x2*10^-9)*c/f2])^2));
Show[ContourPlot[T12, {x1, 941.2, 941.8}, {x2, 941.2, 941.8}, ContourShading -> None, Axes -> False, Frame -> True, Contours -> 50, PlotPoints -> 40, PlotRange -> All]]

enter image description here

Plotpoints are 70, 60, 50, 40 from left to right.

$\endgroup$
  • $\begingroup$ Try to use PerformanceGoal->"Quality" instead of PlotPoints. $\endgroup$ – demm Jun 9 '16 at 12:48
  • $\begingroup$ @demm that doesn't seem to help $\endgroup$ – crossingsymmetry Jun 9 '16 at 13:26
3
$\begingroup$

Your evaluation suffers from loss of precision. Compare instead with the following, where all constants have been made into arbitrary precision numbers, so arbitrary-precision calculations and error-tracking can be used:

c = 3; f1 = 918/10; f2 = 899/10; A = 56; B = 50;

T12 = (1/(1 + (63/100*A)^2*(Sin[Pi/(x1*10^-9)*c/f1])^2))*(1/(1 +
        (63/100*B)^2*(Sin[Pi/(x2*10^-9)*c/f2])^2));

ContourPlot[
 T12, {x1, 9412/10, 9418/10}, {x2, 9412/10, 9418/10},
 ContourShading -> None, Axes -> False, Frame -> True,
 Contours -> 50, WorkingPrecision -> 50
]

enter image description here

This shows the highest contours clipped; adding PlotRange -> All as you had originally:

ContourPlot[
 T12, {x1, 9412/10, 9418/10}, {x2, 9412/10, 9418/10},
 ContourShading -> None, Axes -> False, Frame -> True,
 Contours -> 50, WorkingPrecision -> 50,
 PlotRange -> All
]

Mathematica graphics

These seem in keeping with the 3D shape of the expression:

Plot3D[
 T12, {x1, 9412/10, 9418/10}, {x2, 9412/10, 9418/10},
 PlotRange -> All,
 WorkingPrecision -> 50
]

Mathematica graphics

$\endgroup$

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.