last day (15 days later) » 

03:27
1
Q: ContourPlot fails with composite condition?

Ulrich NeumannIn this very simple example I try to evaluate the contours of x^2+y^2==1||x^2+y^2==2 (two circles) but Mathematica ContourPlot[x^2 + y^2 == 1 || x^2 + y^2 == 2, {x, -2, 2}, {y, -2, 2}] doesn't evaluate ! Evaluate doesn't help. What's wrong here? Thanks!

Try: ContourPlot[{x^2 + y^2 == 1, x^2 + y^2 == 2}, {x, -2, 2}, {y, -2, 2}]
Maybe x^2 + y^2 == 1 || x^2 + y^2 == 2 is not a function about x and y.
@DanialHuber Tahnks for your comment. The example is very simple, but my purpose is to consider composite conditions.
@cvgmt Thanks, the condition behaves like a function I think.
If you insist on the usage ||, then Region[ImplicitRegion[x^2 + y^2 == 1 || x^2 + y^2 == 2, {x, y}], PlotRange -> {{-2, 2}, {-2, 2}}, Frame -> True] does the job.
@user64494 Thanks! I'm still hoping to understand why ContourPlot doesn't handle composite condition.
03:27
@UlrichNeumann: See the above comment of cvgmt to this end. Up to the documetation, "ContourPlot[f,{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}] generates a contour plot of f as a function of x and y." and "ContourPlot[f==g,{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}] plots contour lines for which f=g. " and "ContourPlot[{Subscript[f, 1]==Subscript[g, 1],Subscript[f, 2]==Subscript[g, 2],[Ellipsis]},{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}] plots several contour lines".
@user64494 The comment you mention is misleading I think: Condition x^2 + y^2 == 1 || x^2 + y^2 == 2 is very much a function in x,y . But not an equation, which ContourPlot seems to expect.
A Boolean expression is not an equation, so ContourPlot would try to find numeric level sets of the expression. However, a Boolean expression evaluates to True or False rather than a numeric value so there are no numeric level sets. In your example, Evaluate[List@@expr] would provide a List of equations which ContourPlot is designed to handle.
@UlrichNemann: Can you ground your emotional claim " Condition x^2 + y^2 == 1 || x^2 + y^2 == 2 is very much a function in x,y"?
@user64494 - It is a Boolean function as opposed to a numeric function. See the documentation for BooleanFunction
@BobHanlon Thanks, that is the explanation I was looking for. There seems to be a difference between a single equation x^2+y^2==1(which is boolean expression too!) and a composite condition .
03:27
@BobHanlon : As I understand it, the documentation to ContourPlot says about numerical functions and the examples in the documentation confirm it.
@user64494 The documentation only partially confirms it.For example ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 4 Pi}, {y, 0, 4 Pi}] has a boolean function as first argument!
@UlrichNemann: Up to the documentation, ContourPlot treats Cos[x] + Cos[y] == 1/2 as the second case "ContourPlot[f==g,{x,Subscript[x, min],Subscript[x, max]},{y,Subscript[y, min],Subscript[y, max]}] plots contour lines for which f=g. ", not any boolean expression.
ContourPlot only support the two forms,that is "must be a function f or an equality of the form f == g", it means that f==g is not a boolean expression.
For example, ContourPlot[x^2 + y^2 == 1/2 == x^2 + y^2, {x, 0, 1}, {y, 0, 1}] can not work, so ContourPlot can not accept Boolean expression. The error messages as below : "must be a function f or an equality of the form f == g"
@cvgmt Thanks, but an equality f==g returns True if fullfilled, False otherwise! Where is the difference to a boolean expression?
I think ContoutPlot rewrite f==g as f-g==0 and do with the function f-g
03:27
Probably yes, thanks for your support!

last day (15 days later) »