0
$\begingroup$

I have a function $f(m,n)$ where m and n are positive integers. Suppose $f(m,n)$ is like a black box, I can get values of it when I enter values of m and n. I want to scan over a region for example $4<m<100, 4<n<1000$ to find where $f(m,n)<0$. Then make a plot of the region where it satisfies the requirement.

For the plot part, I think I can directly use the Listplot if I can successfully generate a parameter list for m and n where $f(m,n)<0$. For the first part, I could use the command For to generate the list satisfying the requirement. I guess this is not the most ideal command I want to use in Mathematica.

$\endgroup$
1
  • $\begingroup$ So if you have something like this with 9025 randomly positive and negative points would you be interested in defining positive/negative parametric regions, shown in two colors? $\endgroup$
    – Syed
    May 10, 2022 at 15:57

1 Answer 1

2
$\begingroup$

Does RegionPlot work for what you need? It takes an inequality and a range as input and shows the regions in which that function is true. Below, I have included code that gives an example.

RegionPlot[Sin[x]^y - 10 < 0, {x, 0, 1000}, {y, 0, 1000}] displays plot goes here

$\endgroup$
5
  • $\begingroup$ Thanks for the help. I should be more precise with my question. My function is sort of like a black box. When I enter values of m and n, it returns me some value. $\endgroup$
    – Vayne
    May 10, 2022 at 14:58
  • 1
    $\begingroup$ It's not perfect, but you could do something like this: f[x_, y_] := RandomReal[{0, x}] - RandomReal[{0, y}]*2 ListPlot@ Table[If[f[x, y] < 0, {x, y}, Nothing], {x, 0, 10, .1}, {y, 0, 10, .1}] $\endgroup$
    – Romanp
    May 10, 2022 at 15:08
  • $\begingroup$ @Vayne You only have to substitude Sin[x]^y - 10 by your mystical f[x,y] in @Romanp 's nice answer and it should work! $\endgroup$ May 10, 2022 at 15:26
  • $\begingroup$ That won't work if there's random number generation or something involved in f, but otherwise, should be fine. $\endgroup$
    – Romanp
    May 10, 2022 at 15:26
  • $\begingroup$ @Romanp Clearly , but OP speaks of a function which returns a hopefully unique value! $\endgroup$ May 10, 2022 at 15:30

Your Answer

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

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