Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to plot stream lines of an ODE with one single variable?

I want to see the stream line plot for y' = -sin(x).

The solution of this ODE is coded as:

x = var('x')
y = function('y')(x)
de = diff(y,x) == -sin(x)
h = desolve(de,y)
solution = h.function(x)
show(solution)

However, I am not able to get the right expression in the code for the stream line plot using the functions already defined above.

I can make it happen like this:

x,y=var('x','t')
streamline_plot(cos(x),(t,-10,10),(x,-5,5))

But it is not elegant, nor does it take advantage of the variables h, solution or y already defined.

What would be the more natural expression for the general (and a particular solution) plots?

How to plot stream lines of an ODE with one single variable?

I want to see the stream line plot for y' = -sin(x).

The solution of this ODE is coded as:

x = var('x')
y = function('y')(x)
de = diff(y,x) == -sin(x)
h = desolve(de,y)
solution = h.function(x)
show(solution)

However, I am not able to get the right expression in the code for the stream line plot using the functions already defined above.

I can make it happen like this:

x,y=var('x','t')
streamline_plot(cos(x),(t,-10,10),(x,-5,5))

But it is not elegant, nor does it take advantage of the variables above: h, solution or y already defined.

What would be the more natural expression for the general (and a particular solution) plots?

How to plot stream lines of an ODE with one single variable?

I want to see the stream line plot for y' = -sin(x).

The solution of this ODE is coded as:

x = var('x')
y = function('y')(x)
de = diff(y,x) == -sin(x)
h = desolve(de,y)
solution = h.function(x)
show(solution)

I can produce the desired slope field ad hoc like this:

f(x,y)= - sin(x)
streamline_plot(f(x,y),(x,-10,10),(y,-5,5))

However, I am not able to get the right expression in the code for the stream line plot using the functions already defined above: h, solution or y

What would be the more natural expression for the general (and a particular solution) plots?