Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 110

Q1.

y = function('y', x) desolve(diff(y, x) == y, y)
_C*e^x
k = var('k') desolve(diff(y, x) == k * y, y, ivar=x)
_C*e^(k*x)

Q2.

y = function('y', x) soln(x) = desolve(diff(y, x) == y, y) plot(soln(x).subs(_C=2), x, -10, 10)
p = plot(soln(x).subs(_C=0), x, -10, 10, color=rainbow(11)[0], legend_label="c=0") for C in range(1, 11): p += plot(soln(x).subs(_C=C), x, -10, 10, color=rainbow(11)[C], legend_label="c=%s" % C) p.show()
soln(x) = desolve(diff(y, x) == x * y, y) p = plot(soln(x).subs(_C=0), x, -10, 10, color=rainbow(11)[0], legend_label="c=0") for C in range(1, 11): p += plot(soln(x).subs(_C=C), x, -10, 10, color=rainbow(11)[C], legend_label="c=%s" % C) p.show()

Q3.

y = function('y', x) m, c, k =var('m, c, k') assume(c > 0) desolve(m * diff(y, x, 2) + c * diff(y, x) + k * x == 0, y, ivar = x)
c = 0 desolve(m * diff(y, x, 2) + c * diff(y, x) + k * x == 0, y, ivar = x)

Q4.

desolve?
desolve(diff(y, x) + 4 * y == e ^ x, y, ics=[0, 3]) # This makes use of the `ics` optional argument (which is easily found using the above help command)
desolve(diff(y, x) + x * (2 * y - 3) / (x ^ 2 + 1) == sin(x), y, ics=[0, 4])
desolve(diff(y, x, 2) - y == sin(5 * x), y, ics=[3, 1, 0])
desolve(diff(y, x, 2) + 2 * diff(y, x) + 2 * y == cosh(x), y, ics=[1, 2, 72])

Q5.

t = var('t') y = function('y', t) x = function('x', t) desolve_system([diff(x, t) == 1 - y, diff(y, t) == 1 - x], [y,x])

Q6.

t = var('t') y = function('y', t) x = function('x', t) sols = desolve_system([diff(x, t) == - y, diff(y, t) == - 5 * x], [y,x], ics=[0,100,700]) sols
soly = sols[0].rhs() solx = sols[1].rhs() p = plot(solx, 0,1, legend_label='x') p += plot(soly, 0,1, color='red', legend_label='y') p # The plot shows that x wins the battle.

Q7

t = var('t') y = function('y', t) x = function('x', t) sols = desolve_system([diff(x, t) == - y, diff(y, t) == .7 * x], [y,x], ics=[0, 1, 0]) sols
[y(t) == cos(1/10*sqrt(70)*t), x(t) == -1/7*sqrt(70)*sin(1/10*sqrt(70)*t)]
soly = sols[0].rhs() solx = sols[1].rhs() p = plot(solx, 0,10, legend_label='x') p += plot(soly, 0,10, color='red', legend_label='y') p # We see that the relationship is unstable
t = var('t') y = function('y', t) x = function('x', t) sols = desolve_system([diff(x, t) == - y, diff(y, t) == .7 * x], [y,x], ics=[0, 0, 0]) sols soly = sols[0].rhs() solx = sols[1].rhs() p = plot(solx, 0,10, legend_label='x') p += plot(soly, 0,10, color='red', legend_label='y') p # We see that the relationship is stable

Q8.

x = var('x') y = function('y', x) desolve(diff(y, x) + y * (y - 1) == abs(x - 2), y) # This gives an error
Error in lines 3-3 Traceback (most recent call last): File "/projects/c5be8454-3f27-4e5a-865c-590833f25333/.sagemathcloud/sage_server.py", line 865, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/usr/local/sage/sage-6.4/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 463, in desolve raise NotImplementedError("Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.") NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.
desolve_rk4(diff(y, x) + y * (y - 1) == abs(x- 2), y, ics=[0,1], end_points=100, output='plot')
desolve?
desolve_system?