<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Deriving coefficients for the implicit scheme
The ice sheet energy balance model uses an implicit scheme to solve the
heat equation for $N$ layers. It uses the Crank-Nicholson scheme to discretise
the equations. For an equation in one space dimension $x$
$\frac{df}{dt} = F$,
the Crank-Nicholson scheme discretises the equation as
$\frac{f^{i+1}_x - f^{i}_x}{\Delta t} = 0.5\left [ F^{i+1}_x + F^{i}_x \right ]$
where the superscript is time and the subscript is space.
Step1:  The coefficients for the $i+1$ temperature (predicted) are
Step2:  The coefficients for the $i$ temperature (current) are
<ASSISTANT_TASK:>
Python Code:
from sympy import *
init_printing()
tnew_x = Symbol('T^{i+1}_x')
tnew_xprev = Symbol('T^{i+1}_{x-1}')
tnew_xafter = Symbol('T^{i+1}_{x+1}')
told_x = Symbol('T^{i}_x')
told_xprev = Symbol('T^{i}_{x-1}')
told_xafter = Symbol('T^{i}_{x+1}')
u_x = Symbol('\kappa_x')
u_xprev = Symbol('\kappa_{x-1}')
u_xafter = Symbol('\kappa_{x+1}')
delta_t = Symbol('\Delta t')
delta_x = Symbol('\Delta x')
told_x, u_xprev, tnew_xafter, delta_x
lhs = (tnew_x - told_x)/delta_t
lhs # The time derivative
rhs_new = 0.5*(u_x*(tnew_xprev - 2*tnew_x + tnew_xafter)/delta_x**2 + 
               ((tnew_x - tnew_xprev)/(delta_x))*((u_x - u_xprev)/(delta_x)))
rhs_old = 0.5*(u_x*(told_xprev - 2*told_x + told_xafter)/delta_x**2 + 
               ((told_x - told_xprev)/(delta_x))*((u_x - u_xprev)/(delta_x)))
rhs_new, rhs_old # The two parts of the crank-nicholson RHS.
expr = lhs - rhs_new - rhs_old
expr
poly_form = Poly(expr, tnew_x, tnew_xafter, tnew_xprev, told_x, told_xafter, told_xprev)
poly_form
Explanation: Deriving coefficients for the implicit scheme
The ice sheet energy balance model uses an implicit scheme to solve the
heat equation for $N$ layers. It uses the Crank-Nicholson scheme to discretise
the equations. For an equation in one space dimension $x$
$\frac{df}{dt} = F$,
the Crank-Nicholson scheme discretises the equation as
$\frac{f^{i+1}_x - f^{i}_x}{\Delta t} = 0.5\left [ F^{i+1}_x + F^{i}_x \right ]$
where the superscript is time and the subscript is space.
End of explanation
(poly_form.coeff_monomial(tnew_xprev)*delta_t).simplify(), (poly_form.coeff_monomial(tnew_x)*delta_t).simplify(), (poly_form.coeff_monomial(tnew_xafter)*delta_t).simplify()
Explanation: The coefficients for the $i+1$ temperature (predicted) are
End of explanation
-(poly_form.coeff_monomial(told_xprev)*delta_t).simplify(), (poly_form.coeff_monomial(told_x)*-delta_t).simplify(), -(poly_form.coeff_monomial(told_xafter)*delta_t).simplify()
Explanation: The coefficients for the $i$ temperature (current) are
End of explanation
<END_TASK>