- #1

- 18

- 0

## Homework Statement

For a following differential equation

d^2y/dx^2-4y=(e^x)/x

Find the solution using numerical methods

## Homework Equations

d^2y/dx^2-4y=(e^x)/x

## The Attempt at a Solution

Matlab:

```
%num
dx=0.01;
x=1:dx:3;
l=zeros(1,length(x));
m=zeros(1,length(x));
l(1)=1;
m(1)=0.25;
for ii=2:length(x)
l(ii) = l(ii-1)+m(ii-1)*dx;
m(ii) = m(ii-1) -(1/4) * (l(ii-1)) * dx +(exp(2*x*(ii-1)/(x(ii-1))))*dx;<----- this line keeps throwing an error
end
plot(x,l);
```

Last edited by a moderator: