ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 29 Jun 2021 13:38:26 +0200differential equationhttps://ask.sagemath.org/question/57804/differential-equation/hi
we are discovering Sagemaths and trying to solve and graph a diff equation x^2*y'=y
we tryed to agglomerate two sheets of code :
- the one which solves (and works alone)
- the other one which draws (and works alone)
but together they dont work (maybe because of _C ?)
any help welcome
Vinz+Erw
x = var('x'); y = function('y')
yprime=diff(y(x),x)
EqDf = (x**2)*yprime==y(x)
g(x)=desolve(EqDf, [y(x),x])
g(x)
#dessin = plot([g(x) for _C in srange(-8, 8, 0.4)], (x, -3, 3))
dessin = plot(g(x), (x, -3, 3))
y = var('y')
dessin += plot_vector_field((x^2, y), (x,-3,3), (y,-5,5))`
dessin.show(aspect_ratio = 1, ymin = -3, ymax = 3)ErWinzTue, 29 Jun 2021 13:38:26 +0200https://ask.sagemath.org/question/57804/How to solve Second order Non linear differential equations?https://ask.sagemath.org/question/54048/how-to-solve-second-order-non-linear-differential-equations/ Hello, Am new to sage math
I need to solve a Second order Differential equation , of the form
y''+Q*y'+sin(y) = C. , differentiation w.r.t 't'
I rewrote the equation as a system of first order DE.
y'=v
v'+Q*v+sin(v.t)=C
But i cant figure out how to proceed further, How can i solve The system of equations Numerically? Thanks in advanceSouXOXOXOWed, 28 Oct 2020 04:48:02 +0100https://ask.sagemath.org/question/54048/solving a physic problem using sagehttps://ask.sagemath.org/question/10625/solving-a-physic-problem-using-sage/Hi, I'm new in this community.
I want to solve a physic problem which requires differential equation system solutions.
I don't know if my equations are correctly set. Any suggestion is good. My problem is described by this image: http://img805.imageshack.us/img805/7043/lllzm.png
I have two masses (1/3m the first, 2/3m the second) linked with a rope. The rope is free to slide around a nail (the big black point in the image). The image shows the starting condition: a man keeps the first mass stopped and so the rope is kept stretched by the second mass.
I search three functions describing the kinematics of two masses after the man will leave the fist mass: vertical movement of mass A y(t), vertical movement of mass B j(t), and horizontal movement of mass B x(t).
My Cartesian reference system is x-y system in the image.
I have to solve the following equations:
1. $-\frac{2}{3}mg+T=\frac{2}{3}m \frac{d^2y}{dt^2}$
2. $-\frac{1}{3}mg+S_y=\frac{1}{3}m\frac{d^2j}{dt^2}$
3. $S_x=\frac{1}{3}m\frac{d^2x}{dt^2}$
4. $|T|=\sqrt{S_x^2+S_y^2}$
5. $|y(t)|=\sqrt{x(t)^2+j(t)^2}$
From the forth and the fifth equations I obtain two equations, so I have 5 equations in 5 unknowns. They are:
1) T force sustaining the second mass
2) Sx x-component of force sustaining the first mass
3) Sy y-component of force sustaining the first mass
4) y(t) position of the second mass
5) x(t) x-position of the first mass
6) j(t) y-position of the first mass
I hope my explanation is clear.
How can I obtain my solutions using Sage?
Thank you very much!!pspFri, 18 Oct 2013 14:33:59 +0200https://ask.sagemath.org/question/10625/System of differential equationshttps://ask.sagemath.org/question/36754/system-of-differential-equations/Hi! I am doing a project on pursuit curves, and I am trying to plot the system:
de1 = diff(x,t) == 2*(-x)/sqrt(x^2+(t-y)^2)
de2 = diff(y,t) == 2*(t-y)/sqrt(x^2+(t-y)^2)
with *x(t)* and *y(t)* being my *i* and *j* components for the trajectory a an object.
I wrote:
t = var('t')
x = function('x',t)
y = function('y',t)
de1 = diff(x,t) == 2*(-x)/sqrt(x^2+(t-y)^2)
de2 = diff(y,t) == 2*(t-y)/sqrt(x^2+(t-y)^2)
f,g = desolve_system([de1, de2],[x,y],ics = [0,10,0])
show(f)
show(g)
It gives me a solution for my system, *x(t)* and *y(t)* (that I don't understand, since I hacen't seen Laplace), but I can't figure out how to plot the vector equation *A(t)* = *x(t)**i + *y(t)**j.
I wanted to use
**parametric_plot(x(t),y(t),(t,0,20))**
but it doesn't work.
Could anyone help me?
Thank you!carlotaaa2Tue, 28 Feb 2017 04:25:07 +0100https://ask.sagemath.org/question/36754/Infinite initial conditions in ODE and arbitrary constanthttps://ask.sagemath.org/question/36493/infinite-initial-conditions-in-ode-and-arbitrary-constant/Is it possible to include infinite initial conditions in an ODE? For example,
ode_soln = desolve(ode, q, ics[0, -Infity])
throws and error.
Alternatively, I can leave the initial condition blank:
ode_soln = desolve(ode, q)
soln = solve(ode_soln, q)
show(soln[0])
Then output Includes an arbitrary constant written C
$$
q\left(t\right) = -\frac{p}{C {\left(p + 1\right)} + {\left(p + 1\right)} t}
$$
I tried to set a value for $C$ via,
show(soln[0].substitute(C = 0))
but it made no difference. Here $p$ I declared as a variable, and I can do things like
show(soln[0].substitute(p = 1))
to produce the expected output
$$
q\left(t\right) = -\frac{1}{2 {\left(C + t\right)}}
$$
So it seems that I need to refer to the arbitrary constant by some other name than $C$. How can I do this?Paul BryanThu, 09 Feb 2017 02:37:45 +0100https://ask.sagemath.org/question/36493/solve differential equationhttps://ask.sagemath.org/question/24486/solve-differential-equation/I need to solve this third-order linear partial differential equation:
d^2/dx^2 d/dy f(x,y) = f(x,y) - x*y
Could you please help me to do this?
Thank you very much for your advise!Martin MaxaWed, 15 Oct 2014 00:10:24 +0200https://ask.sagemath.org/question/24486/Compact output of solution of DEhttps://ask.sagemath.org/question/26316/compact-output-of-solution-of-de/ When I'm trying to solve DE:
t = var('t')
y = function('y', t)
de = t*(y^2)*diff(y,t) + y^3 == 1
sol = desolve(de,[y,t], [1,2])
the output is pretty ugly:
-1/3*log(y(t)^2 + y(t) + 1) - 1/3*log(y(t) - 1) == -1/3*log(7) + log(t)
When I'm solving this in matlab:
clear;
syms y(t)
y(t) = dsolve(t*(y^2)*diff(y,t) + y^3 == 1, y(1) ==2)
The output looks much better:
y(t) = (exp(log(7) - 3*log(t)) + 1)^(1/3)
Can I see output in sage looking similiar to this from matlab? Simplify(sol) dosen't work. Maybe I've made mistake somewhere, but I can't determine without knowing the form y(t) from sage.
And btw, typing:
t*(y^2)*y'+ y^3 = 1, y(1) = 2
into wolframalpha.com results yet another solution. I'm lost...PhotonTue, 24 Mar 2015 21:51:52 +0100https://ask.sagemath.org/question/26316/Solving PDEshttps://ask.sagemath.org/question/25676/solving-pdes/Hello can I solve equations of the following form in sage?
E.g. $$A\frac{\partial ^ n f}{\partial x^n} + B \frac{\partial^kf}{\partial y^k} = 0, \quad f=f(x,y) $$
Meaning a PDE that contains the n-th derivative with respect to x and the k-th derivative with respect to y.
Marios PapachristouMon, 02 Feb 2015 17:36:18 +0100https://ask.sagemath.org/question/25676/Defining constants after solving ODE/PDEhttps://ask.sagemath.org/question/25373/defining-constants-after-solving-odepde/Hello
Solving the differential equation $f'(x) = f(x)$ the answer leads to $f(x) = ce^x$ where $c$ is a constant. How can I generically solve this ODE in SAGE and define $c$ afterwards (I don't want to use `ics`)?
Consider this script
x = var('x')
f = function('f',x)
f = desolve(diff(f,x) == f(x), f, ival=x)
print str(f(x))
>> ce^x
#I want to define c afterwards
A method I found:
#continue the previous prompt
f(x,c) = f(x)
h(x) = f(x,10)
Is there something else that I can do?
Marios PapachristouThu, 01 Jan 2015 21:26:59 +0100https://ask.sagemath.org/question/25373/Solve the following system of ODE's and plot its solutionhttps://ask.sagemath.org/question/24852/solve-the-following-system-of-odes-and-plot-its-solution/Solve the following system of ordinary differential equations
d^2x/dt^2 + 5x + 2y = 0
d^2y/dt^2 + 2x + 8y = 0
with initial conditions x(0)=1, y(0)=2, x'(0)=-4, y'(0)=2
and plot its solution as a curve in the {x,y} plane.fomel_sergeyThu, 13 Nov 2014 02:21:22 +0100https://ask.sagemath.org/question/24852/solving a system of DEs numerically and plotting the solutionhttps://ask.sagemath.org/question/24766/solving-a-system-of-des-numerically-and-plotting-the-solution/Hi everyone. I want to hand Sage a system of nonlinear DEs with initial values, and I'd like a plot of the solutions. Is there a best way to do this? For example, to solve this system: ds/dt=-si, di/st=si-2i, dr/dt=2i, s(0)=1, i(0)= 0.00000127, r(0)=0, I did this in Sage:
sage: (s,i,r)=var('s,i,r')
sage: des=[-1*s*i, s*i-2*i, i]
sage: desolve_system_rk4(des, [s,i,r], ics=[0, 1, 0.00000127, 0], ivar=t, end_points=20)
Sage gave me a list of points, but I couldn't figure out a way to plot s, i, and r using the points it gave me. Thanks!
strangelove1661Mon, 03 Nov 2014 21:32:05 +0100https://ask.sagemath.org/question/24766/Plot solution for y' + 2xy = 1https://ask.sagemath.org/question/9121/plot-solution-for-y-2xy-1/f = desolve(diff(y,x) + 2*x*y - 1, y, ics=[0,0]); f
plot(f) # error message ... unable to simplify to float approximation.
Tried plotting real_part of solution: -1/2*I*sqrt(pi)*e^(-x^2)*erf(I*x),
but get same error message.
Tried using list_plot, but error about symbolic expression.
Haven't been able to get implicit_plot or sol.simplify_full to work.
Thanks for any hints.bbtpSun, 01 Jul 2012 22:29:48 +0200https://ask.sagemath.org/question/9121/