# How to plot the data where y is a function?

how can I plot the data (x,y)by knowing a and b and x values?

x = {0.2, 11, 16};
y = Exp[(-a*x - b*x^2)];
a = {0.510, 0.280, 0.250};
b = {0.380, 0.240, 0.330};

• Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
– Community Bot
Jun 29 at 3:50

Clear["Global*"]

x = {0.2, 11, 16};
a = {0.510, 0.280, 0.250};
b = {0.380, 0.240, 0.330};
y[a_, b_, x_] := Exp[(-a*x - b*x^2)];

Manipulate[
Show[
LogPlot[y[av, bv, xv], {xv, 0, 20},
PlotRange -> All,
AxesLabel -> (Style[#, 14] & /@ {"x", "y"}),
PlotLabel -> StringForm["y = ", y[av, bv, "x"]]],
ListLogPlot[
Tooltip[{#, y[av, bv, #]},
{#, y[av, bv, #]} /.
z_Real :> NumberForm[z, {5, 2}]] & /@ x,
PlotStyle -> Red],
PlotRangeClipping -> False],
{{av, a[[1]], "a"}, a},
{{bv, b[[1]], "b"}, b}]


I'm going to assume that we want a and b values to be more like parameters and that we want x to be our function argument. You could certainly just munge them all together, but I'll proceed with my assumptions.

Let's first take a look at the Table function. You can use it to create a list by evaluating some given expression for a set of values specified for some variable that appears in the expression. So, we can provide values for a and b like this (the {a,b} is just for illustration at this point--we'll replace it with your actual function later):

Table[{a, b}, {a, {0.510, 0.280, 0.250}}, {b, {0.380, 0.240, 0.330}}]


The result looks like this:

{{{0.51, 0.38}, {0.51, 0.24}, {0.51, 0.33}}, {{0.28, 0.38}, {0.28, 0.24}, {0.28, 0.33}}, {{0.25, 0.38}, {0.25, 0.24}, {0.25, 0.33}}}


Notice the structure. We have three larger "chunks" and each consists of three pairs. This is all because of the size of your value sets for a and b. Okay, so it's easy to replace {a,b} with your exponential expression (I'm going to save this to the variable functions):

functions =
Table[Exp[(-a*x - b*x^2)], {a, {0.510, 0.280, 0.250}}, {b, {0.380, 0.240, 0.330}}]


The first "chunk" of data is where we fixed the value of a and let the value of b range over the values you provided. And so forth for the other "chunks". We can access any one of these chunks easily--here's the first "chunk":

functions[[1]]


The result is:

{E^(-0.51*x - 0.38*x^2), E^(-0.51*x - 0.24*x^2), E^(-0.51*x - 0.33*x^2)}


Now we're ready to move on to plotting. There are tons of plotting functions, but I'm guessing that the one you want is DiscretePlot. We can plot the first "chunk" as points where x takes on the values you provided:

DiscretePlot[functions[[1]], {x, {0.2, 11, 16}}]


You should see a plot with nine points. If you want all 27 points, then let's remove the "chunk" structure with Flatten, and plot all of them:

DiscretePlot[Flatten[functions], {x, {0.2, 11, 16}}]
`

You should now see 27 points. When I did this, some points were too close together to easily distinguish. Not sure if that's intentional (or maybe I made a mistake in the above).

Your question was a bit vague, so it's entirely likely that this isn't what you wanted. There are many, many other ways to "plot" things, so if you want to provide more detail, we can give better answers.