I two functions:
f(x) = x**2
g(x) = -(x-4)*x
I need to calculate the area between these two curves, for that I would like to have visualization. WolframAlpha has exactly what I want: https://www.wolframalpha.com/input/?i=area+between+the+curves+y%3Dx%5E2+and+y%3D-x%5E2%2B4x, however, I need to make the graphics in gnuplot. Here is my code so far:
set border linewidth 1
set style line 1 linecolor rgb '#0060ad' linetype 1 linewidth 1
set style line 2 linecolor rgb '#dd181f' linetype 1 linewidth 1
set key at 6.1,1.3
set xlabel 'x'
set ylabel 'y'
set xrange [-0.5:3]
set yrange [0:5]
set xtics 2
set ytics 2
set tics scale 2
f(x) = x**2
g(x) = -(x-4)*x
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
plot f(x) title 'f(x)' with lines linestyle 1, \
g(x) title 'g(x)' with lines linestyle 2
It produces this output:
Is there any way I can highlight the area between these two curves like in WolframAlpha? Assuming that we know where they intersect (0 and 2), unless gnuplot can do that on its own.
If this is not something vanilla gnuplot is capable of I apologize, in that case some pointers to resources that can do that would be appreciated.
