Python Forum
Comparing three functions and plotting specific regions - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Comparing three functions and plotting specific regions (/thread-20335.html)



Comparing three functions and plotting specific regions - japrap - Aug-05-2019

Hi guys,

Assume that we have the following functions:
    f_1 = ((x[2]/(5+x[1]))**((x[1]+5)/4))
    f_2 = (5+x[1]*((x[2]-5)/x[1])**((x[1]+5)/4)))/(5+x[1])
    f_3 = (5*((X[2]-X[1])/5)**((x[1]+5)/4))+X[1])/(5+X[1])
[Image: e7qjh.png]

In addition, let's assume that:
 
x[1] = np.linspace(0,7,0.001)
x[2]= np.linspace(0,5+x[1],0.001)
I need to draw a plot which clarifies region under which each function is greater than the other two functions. x-axis = x[1], y-axis = x[2]

In fact, I need a plot like the following picture which shows the regions under which each function has a greater value in comparison with the other two functions. For example, in the following picture we can see that when c < x[2] < a and x[1]< b (i.e the green region) then f_1 is greater than f_2 and f_3.

**It should be mentioned that if x[2] < 5 then f_2 is undefined and if x[2] < x[1] then f_3 is undefined. In these cases we just need to compare the other two functions. For instance, suppose that x[1] = 4 and x[2] = 3, since x[2] < 5 and x[2] < x[1], then both f_2 and f_3 are undefined and we only need to consider f_1.


[Image: 2NwHI.png]


RE: Comparing three functions and plotting specific regions - scidam - Aug-05-2019

It looks like an assignment. What did you try so far?


RE: Comparing three functions and plotting specific regions - japrap - Aug-06-2019

First, thanks for your reply. I know that it seems that it's an assignment:D, but it's not. The whole problem is far beyond these functions. However, since I am new to python I just post a numerical example to see how can I code this problem to gain some hints for the main problem which is totally parametric.