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.Wed, 07 Apr 2021 14:49:01 +0200Maxima wants to know whether %k1 is positive or negativehttps://ask.sagemath.org/question/56526/maxima-wants-to-know-whether-k1-is-positive-or-negative/Trying to solve a differential equation in Sage:
sage: de = -diff(y, x, 2) - G*M/y^2
sage: desolve(de, y, ics=[0, 1000])
I get a type error and a question:
TypeError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(%k1>0)', see `assume?` for more details)
Is %k1 positive or negative?
But when I use `assume(%k1>0)` I get a syntax error,
saying that there's something wrong with the percent sign.Dr. BananaWed, 07 Apr 2021 14:49:01 +0200https://ask.sagemath.org/question/56526/Error: list' object is not callablehttps://ask.sagemath.org/question/36563/error-list-object-is-not-callable/I am trying to run the following code :
x = var('x')
y = function('y')(x)
de= x*x*diff(y,x,2)+x*diff(y,x)+((12)*x*x-4)*y == 0
val_test=desolve(de,y,contrib_ode=true)
a=val_test(4)
a.n()
But a.n() shows "Error: list' object is not callable".AeimiSat, 11 Feb 2017 06:33:43 +0100https://ask.sagemath.org/question/36563/Differential Equations and Error of Estimationshttps://ask.sagemath.org/question/24330/differential-equations-and-error-of-estimations/ So I'm tasked with the following two questions:
1. For the initial value problem y′=y sin(x), y(0)=1, first find the exact solution. Then make log-log plots of the error versus n (the number of steps) at x=pi for Euler's method and the fourth-order Runge-Kutta method.
2. Repeat the above exercise for the IVP y′=y+sin(x), y(0)=−0.48.
So we have a defined function for funding the Euler estimation:
def EulerMethod(xstart, ystart, xfinish, nsteps, f):
'''
Returns a list of x and y values for the initial value problem
y' = f, y(xstart) = ystart, up to x=xfinish, using n steps of
Euler's Method.
EXAMPLE:
var('x,y')
f(x,y) = -y + cos(x)
EulerMethod(0,1,2,4,f)
[(0, 1), (0.500000000000000, 1), (1.00000000000000, 0.938791280945),
(1.50000000000000, 0.739546793407), (2.00000000000000, 0.405141997537)]
#If you just want to get the last value, you could do:
sol = EulerMethod(0,1,2,4,f)
sol[-1]
(2.00000000000000, 0.405141997537)
'''
sol = [ystart]
xvals = [xstart]
h = N((xfinish-xstart)/nsteps)
for step in range(nsteps):
sol.append(sol[-1] + h*f(xvals[-1],sol[-1]))
xvals.append(xvals[-1] + h)
return zip(xvals,sol)
As written by the teacher. We are given that and no function for the RK4 so I assume we are to use the built in Sage RK4 estimation.
Anyways I have no idea what to do. I'm absolutely lost. Can anyone please help me? Massive thanks in advance.HankSpankTue, 30 Sep 2014 00:45:08 +0200https://ask.sagemath.org/question/24330/