Akshay
Akshay

Reputation: 11

How to plot the solution to a second order differential equation in maple

My code is attached in the pictures. How can I plot the solution y(x) as a function of x? The solution to this BVP y(x) is given by the command dsolve({de, ics}) enter image description here

with(DEtools);

      w := 20
      t := 5
      L := 200
      Base_TD := 0
      End_TD := 100
      x0 := 100
      K := 350*10^(-6)
      h := 850*10^(-12)
      de := diff(y(x), x, x) = 2*h*(w + t)*y(x)/(K*w*t) - (x - x0)^2
      dsolve(de)
      ics := y(0) = Base_TD, D(y)(100) = -h*End_TD/K
      dsolve({de, ics})

Upvotes: 1

Views: 522

Answers (1)

acer
acer

Reputation: 7246

You can solve this exactly, or numerically.

The plot of those agree with each other quite well.

restart;
w := 20: t := 5: L := 200:
Base_TD := 0: End_TD := 100: x0 := 100:
K := 350*10^(-6): h := 850*10^(-12):

de := diff(y(x), x, x)
      = 2*h*(w + t)*y(x)/(K*w*t)
        - (x - x0)^2:

ics := y(0) = Base_TD,
       D(y)(100) = -h*End_TD/K:

Solved exactly, and then plot constructed,

exactsol := dsolve({de, ics}):

PE := plot(rhs(exactsol), x=0..100):

Solved numerically (ie. generating a procedure, which solves numerically at points in time on demand), and then plot constructed,

numericsol := dsolve({de, ics}, numeric):

PN := plots:-odeplot(numericsol,[x,y(x)],
                     x=0..100,
                     thickness=5,color=green):

Showing both together, for comparison,

plots:-display(PN,PE);

enter image description here

Checking the second boundary condition,

evalf(ics);
numericsol(100);
plots:-odeplot(numericsol,[x,diff(y(x),x)],
               x=90 .. 100,
               thickness=5,color=green);

Upvotes: 0

Related Questions