# Question:How to differentiate numerical solution of differential equation

## Question:How to differentiate numerical solution of differential equation

Maple 18

Cannot calculate derivative (gradient) of a procedure returned by dsolve.

Say, I solve the equation:

S1 := dsolve([diff(y(x), x\$2)-1.0325*diff(y(x), x)+1.36*y(x)=sin(2*x), y(0)=0, y(1)=1], numeric, y(x), 'output' = listprocedure);

Its solution easily can be retrieved and looks fine:

H:=rhs(S1[2]);

plot(H(t), t = 0..1, thickness = 4);

But when I try to calculate the gradient of H, I receive the error:

H1 := codegen[GRADIENT](H);

Error, (in intrep/statement) unable to translate Array(1..4, {(1) = proc (outpoint) local X, Y, YP, yout, errproc, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; X := Vector(8, {(1) = .0, (2) = .14817993189456188, (3) = .31785812820433257, (4) = .47163479035679234, (5) = .6130306894371967, (6) = .7460958115245858, (7) = .8741894219027533, (8) = 1.0}, datatype = float[8], order = C_order); Y := Matrix(8, 2, {(1, 1) = .0, (1, 2) = .47692145669848085, (2, 1) = 0.7710429970702501e-1, (2, 2) = .5707930170882397, (3, 1) = .1866916935738028, (3, 2) = .7299040171277492, (4, 1) = .3128649714509215, (4, 2) = .9171936...

Gradient of procedures defined by  ":= proc()" is calculated properly.

﻿