How do I plot a function that is in a list? [closed]

I am trying to plot a function that I had converted from the returned list of rule assignments from Solve[ ]. I am trying to plot this, but the resulting graph is empty. Does anyone know what I am doing wrong?

I see that the function that I am trying to plot is in a list. However, after returning the first index, the equation, my plot with it is still empty.

deltaO = O == Q + P*V;
Qsolved = Solve[deltaO, Q][] /. Rule -> Equal;
Qsolved
Qrules = Qsolved /. {O -> 27.1, V -> (19.6 - 6.43)}
Qrules[]
Plot[Qrules[], {P, 0, 1}] I also tried converting it into a Function, like the following, but it doesn't work either.

deltaO = O == Q + P*V;
Qsolved = Solve[deltaO, Q][] /. Rule -> Equal;
Qsolved
Qrules = Qsolved /. {O -> 27.1, V -> (19.6 - 6.43)}
function[P_] := Evaluate[Qrules[]]
Plot[function[P_], {P, 0, 1}]

This may just be a math error on my part, but I figured that the plot would return autoscale the y-axis to show the values.

• Thank you
• O is a reserved symbol, so I would suggest avoiding the use of it as a variable. Jan 29 '21 at 19:08
• In deltaO = O == Q + P*V you use the character "O" instead of zero. Jan 29 '21 at 19:30
• I used other symbols besides O in the past, such as [CapitalDelta]E, but they didn't work either. Also, I intended for it to be an O, since I was under the assumption that the O was written to a number through the rule assignment. Jan 29 '21 at 19:35

Here's one way to do it:

deltaO = o == q + p*v;
qsolved = q /. First@Solve[deltaO, q]
qrules = qsolved /. {o -> 27.1, v -> (19.6 - 6.43)}
Plot[
qrules, {p, 0, 1}
] It's best to avoid beginning variable names or function names with capital letters. Mathematica symbols always begin with capital letters. C, D, E, I, K, N, and O all have built-in meaning. If you're lucky, whatever you're trying to do with them won't break your code, but try evaluating E = 5 and you'll immediately get an error since E is Euler's number and Mathematica considers E = 5 to be the same as something like 1 = 2.

The second thing is that the function provided to Plot should not have any equal signs in it. If you would like to, you could do something like:

ContourPlot[
q == qrules,
{p, 0, 1}, {q, 0, 40}
]

where qrules comes from the earlier code.

While I find your approach somewhat of an overkill, you can get the result you want by correcting your Part specification as such:

deltaO = Oh == Q + P*V;
Qsolved = Solve[deltaO, Q][] /. Rule -> Equal;
Qsolved
Qrules = Qsolved /. {Oh -> 27.1, V -> (19.6 - 6.43)}
Qrules[]
Plot[Qrules[[1, 2]], {P, 0, 1}]

That is, note the 2nd index in Qrules[[1,2]]. This is needed because Qrules[] alone is an equation, whereas what you want to plot is the RHS of the same. It can be as simple as this:

deltaΟ = Ο == Q + P V;
Qsolved[P_] = Solve[deltaO, Q][[1, 1, 2]];
Plot[Qsolved[P] /. {Ο -> 27.1, V -> 19.6 - 6.43}, {P, 0, 1},
AxesLabel -> {"P", "Q"}] Note: What looks like $$O$$ in the above code is actually \[CapitalOmicron], so it does not conflict with any predefined Mathematica symbols.