WriteDataOutExpClassic.mw

This Maple file is called WriteDataOutExp and is used to calculate the analytical solution for an example problem and  to write the results to a text file (maple_output.txt). 

> Typesetting:-mrow(Typesetting:-mi(
 

Specify the values for x at which the analytical solution will be calculated and later exported.  Make sure
you have the whole range (i.e., 0 to 1) of x included.
 

> Typesetting:-mrow(Typesetting:-mi(
 

array( 1 .. 11, 1 .. 1, [( 9, 1 ) = .8000000000, ( 5, 1 ) = .4000000000, ( 1, 1 ) = 0., ( 8, 1 ) = .7000000000, ( 10, 1 ) = .9000000000, ( 7, 1 ) = .6000000000, ( 4, 1 ) = .3000000000, ( 2, 1 ) = .100... (1)
 

Input the Governing Equation and Boundary Conditions: 

> Typesetting:-mrow(Typesetting:-mi(
 

diff(diff(u(x), x), x) = u(x) (2)
 

> Typesetting:-mrow(Typesetting:-mi(
 

u(0) = .21, (D(u))(1) = 0 (3)
 

Solve the differential equation and rearrange the results to the desired form: 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`/`(`*`(`/`(21, 100), `*`(exp(1), `*`(exp(`+`(`-`(x)))))), `*`(`+`(exp(-1), exp(1)))), `/`(`*`(`/`(21, 100), `*`(exp(-1), `*`(exp(x)))), `*`(`+`(exp(-1), exp(1))))) (4)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`/`(`*`(`/`(21, 200), `*`(`+`(cosh(1), sinh(1)), `*`(`+`(cosh(x), `-`(sinh(x)))))), `*`(cosh(1))), `/`(`*`(`/`(21, 200), `*`(`+`(cosh(1), `-`(sinh(1))), `*`(`+`(cosh(x), sinh(x))))), `*`(cosh(1)))... (5)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`/`(`*`(`/`(21, 100), `*`(`+`(`*`(cosh(1), `*`(cosh(x))), `-`(`*`(sinh(1), `*`(sinh(x))))))), `*`(cosh(1)))) (6)
 

> Typesetting:-mrow(Typesetting:-mi(
 

`+`(`/`(`*`(`/`(21, 100), `*`(cosh(`+`(`-`(1), x)))), `*`(cosh(1)))) (7)
 

Make sure the solution satisfies the boundary conditions: 

> Typesetting:-mrow(Typesetting:-mi(
 

.2100000000 (8)
 

> Typesetting:-mrow(Typesetting:-mi(
 

0. (9)
 

Plot the results: 

> Typesetting:-mrow(Typesetting:-mi(
 

Plot_2d
 

> Typesetting:-mrow(Typesetting:-mi(
 

Save the analytical solution at the x values specified at the beginning of this worksheet as uana[i]. 

> Typesetting:-mrow(Typesetting:-mi(
 

 

 

 

 

 

 

 

 

 

 

.2100000000
.1950307288
.1820133908
.1708177041
.1613316181
.1534601934
.1471246498
.1422615792
.1388223103
.1367724217
.1360913975 (10)
 

Export the Analytical Solution from Maple into theText File: 

> Typesetting:-mrow(Typesetting:-mi(
 

array( 1 .. 11, 1 .. 2, [( 7, 2 ) = .1471246498, ( 9, 1 ) = .8000000000, ( 10, 2 ) = .1367724217, ( 5, 1 ) = .4000000000, ( 1, 1 ) = 0., ( 8, 1 ) = .7000000000, ( 6, 2 ) = .1534601934, ( 9, 2 ) = .138... (11)
 

Note:  To export to a text file, the formats compatible with Maple are Arrays, Matrices, etc.  For additional help please type ? writedata 

> Typesetting:-mrow(Typesetting:-mi(
 

Now, the output from the analytical solution is stored into a file called "maple_output.txt" in the folder where you saved this original Maple file.