Are software bugs categorised as “that is the way it is”

For a few years, I thought that the shame was only on financial companies to have dragged us through the economic mess.  Whether the mess is now affecting our software industry or if it is the new attitude of software companies, remains to be seen.  Three different pieces of software that I use for teaching and research in a large university in the Southeast USA, have serious flaws which the companies are taking semi-seriously or as a matter of “life goes on”. 

One of them is a finite element program.  Running the input file in a new version gives segmentation fault and the company acknowledges that it is a problem.  To stop wasting our time and not having to use the features of the new version, we requested that they give us the license for the older version until they fix the problem.  It took more than a couple of weeks of reminders (what else our IT group had to do) to get the older version.  Then they did not give us the parallel version of the program and we are still waiting for that.

Second is a program that makes interactive quizzes for mathematics courses.  This software gives the result as incorrect even for correct answers if the correct answer is a negative number.  This makes the program useless for what I want to do.  Their take on it – we cannot update it right away.  Hey, this is making your program useless to me – wake up.  Even after pointing out to them where the potential bug can be (without looking at the program) and which it was, they still did not help me.  I even told them how to fix it.  Only after much wrangling and waiting for two months, they are promising the update in October.  I hope they test it with the test file I sent them; otherwise, I am at square one until December.

Third is a computational package.  They updated their symbolic package with a different package and my students now get two different sets of answers using two different versions.  The answers are correct but one version gives only one solution while the other version gives multiple solutions.  I need the multiple solutions so that students can pick the most appropriate answer.  What I heard from them was -“That is the way it is”.  Only after much wrangling and calling their reply a “cop out” did they acknowledge it as a problem and gave me an alternate solution.  See I am teaching the first programming course to engineers and I cannot teach them to work around the bugs of the software itself.  Their confidence is shaken and I have to be extra vigilant now – is it the software or is it the students.  Nothing can be taken at face value anymore.  And these students are the future industrial users of the software.

Bugs are part of life for any software but when you are making millions of dollars of profit, you have an obligation to work on the bugs that make your software unusable.  What I am finding out is the software companies attitude is that they are safe in treating their customer any way they like – they may not be “too big to fail” but they are “too entrenched to fail”.  Good day!

 _________________________________________________________________________________________________________________________

This post is brought to you by

You can watch the numerical methods videos on a mobile device

We are in the process of putting appropriate content of the numerical methods website so that it can be viewed on mobile devices.  So far we have checked that it works on the Itouch, Iphone, Blackberry, LG New.

The mobile website is at http://nm.mathforcollege.com/mobile.  Let me know what you think about this development.

_________________________________________________________________________________________________________________________

This post is brought to you by

How do I solve simultaneous linear equations given in equation form?

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to solve simultaneous linear equations given in equation form.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I solve a set of simultaneous linear equations
% given in equation form?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/sle_equations.m;
% Last Revised : August 22, 2009;
% Abstract: This program shows you how to solve a set of
%     simultaneous linear equations given in equation form?
%           .
clc
clear all
clf

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to solve a’)
disp(‘   set of simultaneous linear equations given in equation form’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/sle_equations.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   August 22, 2009’)
disp(‘ ‘)

%% INPUTS
% Enter the equations
eqn1=’12*a+23*b+39*c=29′;
eqn2=’13*a+17*b+19*c=37′;
eqn3=’21*a+23*b+29*c=59’;
%% DISPLAYING INPUTS
disp(‘  ‘)
disp(‘INPUTS’)
disp(‘________________________’)
disp(‘Equations’)
disp(‘________________________’)
disp(eqn1)
disp(eqn2)
disp(eqn3)

%% THE CODE
% The solution
X=solve(eqn1,eqn2,eqn3);
% Assigning the output
a=double(X.a);
b=double(X.b);
c=double(X.c);
%% DISPLAYING OUTPUTS
disp(‘  ‘)
disp(‘OUTPUTS’)
disp(‘________________________’)
disp(‘Solution Vector’)
disp(‘________________________’)
fprintf(‘\nValue of a= %g’,a)
fprintf(‘\nValue of b= %g’,b)
fprintf(‘\nValue of c= %g’,c)
disp(‘  ‘)
disp(‘________________________’)

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I solve a set of simultaneous linear equations given in matrix form?

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to solve simultaneous linear equations given in matrix form.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I solve a set of simultaneous linear equations?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/sle.m;
% Last Revised : August 12, 2009;
% Abstract: This program shows you how to solve a set of simultaneous linear
% equations?
%           .
clc
clear all
clf

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to solve a’)
disp(‘   set of simultaneous linear equations’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/sle.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   August 12, 2009’)
disp(‘ ‘)

%% INPUTS
% Enter the coefficient matrix of the equation [A][X]=[C]
A=[12  23  39; 13  17  19; 21  23  29];
% Enter the right hand side vector
C=[29;   37;  59];
%% DISPLAYING INPUTS
disp(‘  ‘)
disp(‘INPUTS’)
disp(‘________________________’)
disp(‘Coefficient Matrix’)
disp(‘________________________’)
dataval=[A];
disp(dataval)
disp(‘________________________’)
disp(‘Right hand side vector’)
disp(‘________________________’)
dataval=[C];
disp(dataval)
disp(‘________________________’)

%% THE CODE
% The solution
X=A\C;

%% DISPLAYING OUTPUTS
disp(‘  ‘)
disp(‘OUTPUTS’)
disp(‘________________________’)
disp(‘Solution Vector’)
disp(‘________________________’)
dataval=[X];
disp(dataval)
disp(‘________________________’)

his post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I do polynomial regression in MATLAB?

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to do polynomial regression.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES MAY NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR OR IT MAY NOT PASTE HARD RETURNS.  DOWNLOAD THE MATLAB PROGRAM DIRECTLY INSTEAD
%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I do polynomial regression?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/regression_polynomial.m;
% Last Revised : August 3, 2009;
% Abstract: This program shows you how to do polynomial regression?
%           .
clc
clear all
clf

%% INTRODUCTION

disp('ABSTRACT')
disp('   This program shows you how to do polynomial regression')
disp(' ')
disp('AUTHOR')
disp('   Autar K Kaw of http://autarkaw.wordpress.com')
disp(' ')
disp('MFILE SOURCE')
disp('   http://nm.mathforcollege.com/blog/regression_polynomial.m')
disp(' ')
disp('LAST REVISED')
disp('   August 3, 2009')
disp(' ')

%% INPUTS
% y vs x data to regress
% x data
x=[-340 -280 -200 -120 -40 40 80];
% ydata
y=[2.45  3.33 4.30 5.09 5.72 6.24 6.47];
% Where do you want to find the values at
xin=[-300 -100 20  125];
%% DISPLAYING INPUTS
disp('  ')
disp('INPUTS')
disp('________________________')
disp('     x         y  ')
disp('________________________')
dataval=[x;y]';
disp(dataval)
disp('________________________')
disp('   ')
disp('The x values where you want to predict the y values')
dataval=[xin]';
disp(dataval)
disp('________________________')
disp('  ')

%% THE CODE
% Using polyfit to conduct polynomial regression to a polynomial of order 1
pp=polyfit(x,y,1);
% Predicting values at given x values
yin=polyval(pp,xin);
% This is only for plotting the regression model
% Find the number of data points
n=length(x);
xplot=x(1):(x(n)-x(1))/10000:x(n);
yplot=polyval(pp,xplot);
%% DISPLAYING OUTPUTS
disp('  ')
disp('OUTPUTS')
disp('________________________')
disp('   xasked   ypredicted  ')
disp('________________________')
dataval=[xin;yin]';
disp(dataval)
disp('________________________')

xlabel('x');
ylabel('y');
title('y vs x ');
plot(x,y,'o','MarkerSize',5,'MarkerEdgeColor','b','MarkerFaceColor','b')
hold on
plot(xin,yin,'o','MarkerSize',5,'MarkerEdgeColor','r','MarkerFaceColor','r')
hold on
plot(xplot,yplot,'LineWidth',2)
legend('Points given','Points found','Regression Curve','Location','East')
hold off
disp('  ')

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I display the data of an array in MATLAB?

When I give a MATLAB project, I ask my students that the command window can only show output from disp and frprintf statements.  All other statement outputs need to be suppressed.  This is done to get an aesthetically pleasing report.  So what is a student supposed to do when you may have y vs x data and one needs to show it as an output, especially when the number of y vs x data points can change.

For example, we may have

x=[1  4  5   7 ]

y=[12  23  34  100]

How do I display this with just disp and fprintf statements?

  • The MATLAB program link is here.
  • The Hhttp://nm.mathforcollege.com/blog/displaying_arrays.mTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I display arrays in MATLAB?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw and Jeremy Baker;
% Mfile available at
% http://nm.mathforcollege.com/blog/displaying_arrays.m;
% Last Revised : July 8, 2009;
% Abstract: This program shows you how to display arrays in MATLAB
clc
clear all

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to display arrays’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com and Jeremy Baker’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/displaying_arrays.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   July 8, 2009’)
disp(‘ ‘)

%% INPUTS
% Input x and y arrays, for example as y vs x data
x=[1  4  5   7 ];
y=[12  23  34  100];
%% DISPLAYING INPUTS METHOD 1
disp(‘INPUTS – Method 1’)
n=length(x);
fprintf(‘The number of data points is %g \n’,n)
disp(‘________________________’)
disp(‘  x-values    y values  ‘)
disp(‘________________________’)
for i=1:1:n
fprintf(‘      %g          %g \n’,x(i), y(i)’)
end
disp(‘________________________’)

%% DISPLAYING INPUTS METHOD 2
% Suggested by guest blogger Jeremy Baker
disp(‘  ‘)
disp(‘INPUTS – Method 2’)
n=length(x);
fprintf(‘The number of data points is %g \n’,n)
disp(‘________________________’)
disp(‘     x    y  ‘)
disp(‘________________________’)
dataval=[x;y]’;
disp(dataval)
disp(‘________________________’)

_____________________________________________

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

Poems on Numerical Methods

In Summer 2009, I gave a HW assignment of writing a poem to my mostly right-brained students.  The results were great; I think they think they are poets and they know it.  The poems were all compiled and can be viewed at http://nm.mathforcollege.com/EML3041/homework/poems2009summer.html.

So happy reading and let me know what you think.  I selected 14 poems out of the 60 or so submitted and am polling the class to select the best three.  The top three poem writers will get prizes including a dollar to get the 89c Chicken Burritto at Taco Bell for “thinking outside the bun” or the biggie fries at Wendy’s for thinking “square rather than round”.

_____________________________________________

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I do spline interpolation in MATLAB?

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to conduct spline interpolation.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I do spline interpolation?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/interpolate_spline.m;
% Last Revised : June 20, 2009;
% Abstract: This program shows you how to do spline interpolation?
%           .
clc
clear all
clf

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to do spline interpolation?’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/interpolation_spline.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   June 20, 2009’)
disp(‘ ‘)

%% INPUTS
% y vs x data to interpolate
% x data
x=[-1  -0.75  -0.5  -0.25   0.25  0.50 0.75  1];
% ydata
y=[-0.5  -0.5  -0.5  -0.5   0.5  0.5  0.5  0.5];
% Where do you want to interpolate at
xin=[-0.8  -0.7  0.7  0.8];
%% DISPLAYING INPUTS
disp(‘INPUTS’)
disp(‘The x data’)
x
disp(‘The y data’)
y
disp(‘The x values where you want to find the interpolated values’)
xin
disp(‘  ‘)

%% THE CODE
% Fitting to spline – it is cubic splines
yin=spline(x,y,xin);
% This is only for plotting the spline interpolants
% Find the number of data points
n=length(x);
xplot=x(1):(x(n)-x(1))/10000:x(n);
yplot=spline(x,y,xplot);

%% DISPLAYING OUTPUTS
disp(‘  ‘)
disp(‘OUTPUTS’)
disp(‘x values at which function is to be interpolated’)
xin
disp(‘y values at the xin values’)
yin
xlabel(‘x’);
ylabel(‘y’);
title(‘y vs x ‘);
plot(x,y,’o’,’MarkerSize’,10,’MarkerEdgeColor’,’b’,’MarkerFaceColor’,’b’)
hold on
plot(xin,yin,’o’,’MarkerSize’,10,’MarkerEdgeColor’,’r’,’MarkerFaceColor’,’r’)
hold on
plot(xplot,yplot,’LineWidth’,2)
legend(‘Points given’,’Points found’,’Spline Curve’,’Location’,’East’)
hold off
disp(‘  ‘)

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I do polynomial interpolation in MATLAB

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to do polynomial interpolation.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I do polynomial interpolation?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/interpolate_polynomial.m;
% Last Revised : June 10, 2009;
% Abstract: This program shows you how to do polynomial interpolation?
%           .
clc
clear all
clf

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to do polynomial interpolation?’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/interpolation_polynomial.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   June 10, 2009’)
disp(‘ ‘)

%% INPUTS
% y vs x data to interpolate
% x data
x=[-1  -0.6  -0.2  0.2  0.6  1];
% ydata
y=[0.0385    0.1000    0.5000    0.5000    0.1000    0.0385];
% Where do you want to interpolate at
xin=[-0.8  -0.7  0.7  0.8];
%% DISPLAYING INPUTS
disp(‘INPUTS’)
disp(‘The x data’)
x
disp(‘The y data’)
y
disp(‘The x values where you want to find the interpolated values’)
xin
disp(‘  ‘)

%% THE CODE
% Find the number of data points
n=length(x);
% Fitting to polynomial of order m=n-1
m=n-1
% pp consists of the coefficients of the polynomial
% pp(1)*x^m+pp(2)*x^m+…….+pp(m)
% pp(1) is coefficient of x^m
% pp(2) is coefficient of x^(m-1)
% and so on
pp=polyfit(x,y,m);
% Getting the values at xin
yin=polyval(pp,xin);
% This is only for plotting the interpolating polynomial
xplot=x(1):(x(n)-x(1))/10000:x(n);
yplot=polyval(pp,xplot);

%% DISPLAYING OUTPUTS
disp(‘  ‘)
disp(‘OUTPUTS’)
disp(‘x values at which function is to be interpolated’)
xin
disp(‘y values at the xin values’)
yin
disp(‘These are the coefficients of the polynomial interpolant’)
disp(‘pp(1) is coefficient of x^m, pp(2) is coefficient of x^(m-1) and so on’)
fprintf(‘Order of polynomial m =%g’,m)
pp
xlabel(‘x’);
ylabel(‘y’);
title(‘y vs x ‘);
plot(x,y,’o’,’MarkerSize’,10,’MarkerEdgeColor’,’b’,’MarkerFaceColor’,’b’)
hold on
plot(xin,yin,’o’,’MarkerSize’,10,’MarkerEdgeColor’,’k’,’MarkerFaceColor’,’k’)
hold on
plot(xplot,yplot,’LineWidth’,2)
legend(‘Points given’,’Points found’,’Polynomial Curve’)
hold off
disp(‘  ‘)

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.

How do I solve a boundary value ODE in MATLAB?

Many students ask me how do I do this or that in MATLAB.  So I thought why not have a small series of my next few blogs do that.  In this blog, I show you how to solve a boundary value ordinary differential equation.

  • The MATLAB program link is here.
  • The HTML version of the MATLAB program is here.
  • DO NOT COPY AND PASTE THE PROGRAM BELOW BECAUSE THE SINGLE QUOTES DO NOT TRANSLATE TO THE CORRECT SINGLE QUOTES IN MATLAB EDITOR.  DOWNLOAD THE MATLAB PROGRAM INSTEAD

%% HOW DO I DO THAT IN MATLAB SERIES?
% In this series, I am answering questions that students have asked
% me about MATLAB.  Most of the questions relate to a mathematical
% procedure.

%% TOPIC
% How do I solve a boundary value ordinary differential equation?

%% SUMMARY

% Language : Matlab 2008a;
% Authors : Autar Kaw;
% Mfile available at
% http://nm.mathforcollege.com/blog/ode_boundaryvalue.m;
% Last Revised : May 26, 2009;
% Abstract: This program shows you how to solve an
%           boundary value ordinary differential equation.
clc
clear all

%% INTRODUCTION

disp(‘ABSTRACT’)
disp(‘   This program shows you how to solve’)
disp(‘   a boundary value ordinary differential equation’)
disp(‘ ‘)
disp(‘AUTHOR’)
disp(‘   Autar K Kaw of http://autarkaw.wordpress.com’)
disp(‘ ‘)
disp(‘MFILE SOURCE’)
disp(‘   http://nm.mathforcollege.com/blog/ode_boundaryvalue.m’)
disp(‘ ‘)
disp(‘LAST REVISED’)
disp(‘   May 26, 2009’)
disp(‘ ‘)

%% INPUTS
% Solve the ordinary differential equation
% y”-0.0000002y=0.000000075*x*(75-x)
% Define x as a symbol
syms x
%The ODE
ode_eqn=’D2y-0.000002*y=0.000000075*x*(75-x)’;
% The initial conditions
iv_1=’y(0)=0′;
iv_2=’y(75)=0′;
% The value at which y is sought at
xval=37.5;
%% DISPLAYING INPUTS

disp(‘INPUTS’)
func=[‘  The ODE to be solved is ‘ ode_eqn];
disp(func)
iv_explain=[‘  The boundary conditions are ‘ iv_1 ‘    ‘ iv_2];
disp(iv_explain)
fprintf(‘  The value of y is sought at x=%g’,xval)
disp(‘  ‘)

%% THE CODE

% Finding the solution of the ordinary differential equation
soln=dsolve(ode_eqn,iv_1,iv_2,’x’);
% vpa below uses variable-precision arithmetic (VPA) to compute each
% element of soln to 5 decimal digits of accuracy
soln=vpa(soln,5);

%% DISPLAYING OUTPUTS
disp(‘  ‘)
disp(‘OUTPUTS’)
output=[‘  The solution to the ODE is ‘ char(soln)];
disp(output)
value=subs(soln,x,xval);
fprintf(‘  The value of y at x=%g is %g’,xval,value)
disp(‘  ‘)

This post is brought to you by Holistic Numerical Methods: Numerical Methods for the STEM undergraduate at http://nm.mathforcollege.com, the textbook on Numerical Methods with Applications available from the lulu storefront, and the YouTube video lectures available at http://nm.mathforcollege.com/videos and http://www.youtube.com/numericalmethodsguy

Subscribe to the blog via a reader or email to stay updated with this blog. Let the information follow you.