Ask Your Question

Revision history [back]

(In your example, you could just replace abs(i*omega) by abs(omega), but I'm sure you gave a simpler example than the examples you really care about.)

It often helps to use a lambda function for plots, as in:

plot3d(lambda x, omega: 1+x+abs(i*omega), (x,0,5), (omega,0,5), viewer='tachyon')

I think the explanation is that functions applied to symbolic expressions often misbehave, while the lambda trick makes sure the functions only get applied to numerical input for plotting.

(In your example, you could just replace abs(i*omega) by abs(omega), but I'm sure you gave a simpler example than the examples you really care about.)

It often helps to use a lambda function for plots, as in:

plot3d(lambda x, omega: 1+x+abs(i*omega), (x,0,5), (omega,0,5), viewer='tachyon')

I think the explanation is that functions applied to symbolic expressions often misbehave, while the lambda trick makes sure the functions only get applied to numerical input for plotting.


EDIT: In the new problem described in your edit, you ask for a 3d plot of a function of omega and V_C, but this function depends only on omega, and not at all on V_C, so a 2d plot would suffice. But maybe that's again just because you used a simplified version of your input, for the sake of the question.

One way to make things work is to make 'G_do_ideal_qn' a function rather than just an expression. Below I'm shortening a tiny bit the names and the values just to make things fit on one line.

sage: G_do(om,V) = -31.*(0.03*I*om - 359.)/(-0.0003*om^2 + 1.03*I*om + 180.)
sage: plot3d(lambda om, V: 20*log(abs(G_do(om,V)), 10), (om, 10, 100e3), (V, 0, 400))