What Science.dll can do

In text books, we find many concepts and the corresponding explanations. In relation with concepts, authors introduce terminologies. It is natural to make source codes for the terminologies. Integration of the codes is Science Code .Net. There are many examples of problems in text books in order to exercise students in understanding concepts. As far as students understand the concepts or the terminologies in some subject, they should solve exercises using Science Code .Net without pencil and paper. The purpose of using Science Code .Net is not simply to solve a problem, but to make students acquaint with object-oriented programming for Science. Thus, the role of Science Code .Net is to provide us with a library with which one can solve exercise problems given in text books.

As an example, we present how to solve a set of linear equations in Calculus. The famous text book for Calculus may be the book written by S. Lang. Using terminologies in the book, we have to use the names of Matrix and Vector. We here present the source codes to solve:

2.0 x  +  4.0 y  +  3.0 z  =  5.3

1.0 x  +  4.0 y  +  3.0 z  =  6.3

1.0 x  +  4.0 y  +  8.0 z  =  7.3

In the following code, we use the class LinearEquation which is constructed by using a Matrix and a Vector:

 

using System;

using L=Science.Mathematics.LinearAlgebra;

 

namespace ScienceTest.MathematicsTest.LinearAlgebraTest

{

/// <summary>

/// LinearEquationTest

/// </summary>

        public class LinearEquationTest

       {

                public LinearEquationTest()

               {

                }

                private string result;

                public string Result

               {

                        get{return result;}

                }

                public void Compute()

               {

                        double[,] a = new Double[3,3];

                        a[0,0]=2.0;

                        a[0,1]=4.0;

                        a[0,2]=3.0;

                        a[1,0]=1.0;

                        a[1,1]=4.0;

                        a[1,2]=3.0;

                        a[2,0]=1.0;

                        a[2,1]=4.0;

                        a[2,2]=8.0;

                        L.Matrix m = new L.Matrix(a);

 

                        double[] c = new Double[3];

                        c[0] = 5.3;

                        c[1] = 6.3;

                        c[2] = 7.3;

                        L.Vector v = new L.Vector(c);

 

                        L.LinearEquation eq = new L.LinearEquation(m,v);

 

                        eq.Solve();

 

                        foreach(double k in eq.Solution)

                        result += k.ToString()+"\r\n";

                }

         }

}

Then we can get the result in the string of Result.
-1
1.675
0.2

As another example, we present a problem in Physics. Using the textbook written by R. Serway, we denote many class names. Using the classes Circuit, ElectricCurrent, ElelctricPotential in Science.Physics.GeneralPhysics, we find the currents I1, I2, I3 in the circuit shown as the following figure:



 

using System;

using GP = Science.Physics.GeneralPhysics;

 

namespace ScienceTest.PhysicsTest.GeneralPhysicsTest

{

/// <summary>

/// KirchhoffTest

/// </summary>

       public class CircuitTest

      {

             public CircuitTest()

            {

             }

             private string result;

             public string Result

            {

                     get{return result;}

             }

             public void Compute()

            {

                     GP.Circuit cir = new GP.Circuit();

                     cir.NumberOfJunctions = 2;

                     GP.ElectricPotential[] V = new GP.ElectricPotential[2];

                     V[0] = new GP.ElectricPotential();

                     V[0].V = 0.0;

                     V[1] = new GP.ElectricPotential();

                     V[1].VariableQ = true;

                     cir.PotentialAtJunction = V;

 

                     cir.NumberOfSegments = 3;

                     GP.ElectricCurrent[] I = new GP.ElectricCurrent[3];

                      I[0] = new GP.ElectricCurrent();

                      I[0].VariableQ = true;

                      I[0].FromJunction = 0;

                      I[0].ToJunction = 1;

                      I[1] = new GP.ElectricCurrent();

                      I[1].VariableQ = true;

                      I[1].FromJunction = 0;

                      I[1].ToJunction = 1;

                      I[2] = new GP.ElectricCurrent();

                      I[2].VariableQ = true;

                      I[2].FromJunction = 1;

                      I[2].ToJunction = 0;

                      cir.Current = I;

 

                      cir.Segment = 0;

                      GP.ElectricPotentialDifference v1

                            = new GP.ElectricPotentialDifference();

                      v1.V = 10.0;

                      GP.Resistance r1 = new GP.Resistance();

                      r1.Ohm = 6.0;

                      cir.Add(v1);

                      cir.Add(r1);

 

                      cir.Segment = 1;

                      GP.ElectricPotentialDifference v2

                           = new GP.ElectricPotentialDifference();

                      v2.V = -14.0;

                      GP.Resistance r2 = new GP.Resistance();

                      r2.Ohm = 4.0;

                      cir.Add(v2);

                      cir.Add(r2);

 

                      cir.Segment = 2;

                      GP.Resistance r3 = new GP.Resistance();

                      r3.Ohm = 2.0;

                      cir.Add(r3);

 

                      cir.KirchhoffRule();

 

                      result += Convert.ToString(I[0].A)+"\r\n"+

                                      Convert.ToString(I[1].A) + "\r\n " +

                                      Convert.ToString(I[2].A) + "\r\n " +

                                      Convert.ToString(V[0].V) + "\r\n " +

                                      Convert.ToString(V[1].V) + "\r\n ";

             }

       }

}

 

Then, we can see the results in the string of Result. Once again, it should be emphasized that the exercise problems are solved by using the single library, Science.dll.