├── Laboratory ├── Global.asax ├── Fakes │ └── MathParser.fakes ├── packages.config ├── About.aspx.cs ├── Default.aspx.cs ├── Modules.aspx.cs ├── Site.Master.cs ├── Account │ ├── ChangePassword.aspx.cs │ ├── ChangePasswordSuccess.aspx.cs │ ├── Web.config │ ├── Login.aspx.cs │ ├── ChangePasswordSuccess.aspx.designer.cs │ ├── ChangePasswordSuccess.aspx │ ├── Register.aspx.cs │ ├── ChangePassword.aspx.designer.cs │ ├── Login.aspx.designer.cs │ ├── Register.aspx.designer.cs │ └── Login.aspx ├── Module │ ├── MConverter.aspx │ ├── MConverter.aspx.cs │ ├── MConverter.aspx.designer.cs │ ├── Factorial.aspx.cs │ ├── Factorial.aspx │ ├── DataAnalysis │ │ ├── PolynomSeq.aspx │ │ ├── LinearRegression.aspx.cs │ │ ├── PolynomSeq.aspx.designer.cs │ │ ├── LinearRegression.aspx │ │ └── PolynomSeq.aspx.cs │ ├── NumberChecker.aspx │ ├── NumberChecker.aspx.cs │ ├── Triangle.aspx.cs │ ├── Finance │ │ ├── FinanceFutureValue.aspx.cs │ │ ├── FinancePresentValue.aspx.cs │ │ ├── FinanceAnnuityPaymentFutureValue.aspx.cs │ │ ├── FinanceAnnuityPaymentPresentValue.aspx.cs │ │ ├── FinancePresentValue.aspx │ │ ├── FinanceFutureValue.aspx │ │ ├── FinanceFutureValueOfAnAnnuity.aspx.cs │ │ ├── FinancePresentValueOfAnAnnuity.aspx.cs │ │ ├── FinanceFutureValueOfAnAnnuity.aspx │ │ ├── FinancePresentValueOfAnAnnuity.aspx │ │ ├── FinanceAnnuityPaymentFutureValue.aspx │ │ ├── FinanceAnnuityPaymentPresentValue.aspx │ │ ├── FinanceRemainingBalanceOfAnnuity.aspx.cs │ │ ├── FinanceNetPresentValue.aspx.cs │ │ ├── FinanceRemainingBalanceOfAnnuity.aspx │ │ ├── FinanceNetPresentValue.aspx │ │ ├── FinanceFutureValue.aspx.designer.cs │ │ ├── FinancePresentValue.aspx.designer.cs │ │ ├── FinanceNetPresentValue.aspx.designer.cs │ │ └── FinanceAnnuityPaymentFutureValue.aspx.designer.cs │ ├── Uncertainty.aspx │ ├── Triangle.aspx │ ├── Converter.aspx │ ├── Factorial.aspx.designer.cs │ ├── NumberChecker.aspx.designer.cs │ ├── Uncertainty.aspx.designer.cs │ ├── Uncertainty.aspx.cs │ └── EquationSolver.aspx.cs ├── About.aspx.designer.cs ├── About.aspx ├── Modules.aspx.designer.cs ├── Default.aspx.designer.cs ├── Global.asax.cs ├── Web.Debug.config ├── Web.Release.config ├── Properties │ └── AssemblyInfo.cs ├── Site.Master.designer.cs ├── Web.config ├── Default.aspx └── Site.Master ├── Notes └── Calculus-Derivative │ ├── x2.fig │ ├── x2.png │ ├── exp.png │ ├── x10.png │ └── derivativeerror.m ├── ProjectWebsite ├── packages.config ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── Properties │ └── AssemblyInfo.cs ├── Default.aspx.designer.cs └── Default.aspx ├── Interactive Mathematics ├── packages.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ └── Resources.Designer.cs ├── App.xaml ├── App.xaml.cs ├── frmTable.xaml.cs ├── frmTable.xaml └── removedCode.txt ├── Mathos ├── Arithmetic │ ├── Numbers │ │ ├── IReal.cs │ │ ├── IInteger.cs │ │ ├── INatural.cs │ │ ├── IRational.cs │ │ ├── IComplex.cs │ │ ├── IImaginary.cs │ │ ├── IIrrational.cs │ │ ├── IWhole.cs │ │ ├── Convert.cs │ │ └── Check.cs │ └── PhysicalConstants.cs ├── TraceAndTestImpact.testsettings ├── Geometry │ ├── Shapes │ │ ├── IShape2D.cs │ │ ├── IShape3D.cs │ │ ├── Torus.cs │ │ └── Ring.cs │ ├── Pythagorean.cs │ └── Trigonometry.cs ├── Mathos.vsmdi ├── Properties │ └── AssemblyInfo.cs ├── SpecialFunctions │ └── Antiderivatives.cs ├── Converter │ ├── ConversionObjects.cs │ └── TemperatureConverter.cs ├── PreCalculus │ ├── ArithmeticSequence.cs │ └── GeometricSequence.cs ├── Calculus │ └── Elementary.Complex.cs ├── LICENSE.md ├── Statistics │ └── Statistical Distributions │ │ └── HypergeometricDistribution.cs └── Algebra.cs ├── MathosTest ├── Geometry │ └── Trigonometry.cs ├── Arithmetic │ ├── DecimalArithmetic.cs │ ├── SingleArthimeticTest.cs │ └── IntegerArthimeticTest.cs ├── SpecialFunctions │ ├── Antiderivatives.cs │ ├── GammaTests.cs │ └── ElementaryTests.cs ├── Statistics and DiceSim │ ├── LinearModels.cs │ └── DiceSimulatorTest.cs ├── VectorTest.cs ├── BenchmarkUtil.cs ├── PreCalculus │ └── PreCalculus.cs ├── Properties │ ├── AssemblyInfo.cs │ └── Resources.Designer.cs ├── Algebra │ └── EquationSolver.cs ├── Finance.cs ├── SetTest.cs └── syntaxTest.cs ├── TraceAndTestImpact.testsettings ├── Mathos.vsmdi ├── README.md └── LICENSE.md /Laboratory/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="Laboratory.Global" Language="C#" %> -------------------------------------------------------------------------------- /Notes/Calculus-Derivative/x2.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathosProject/Mathos-Project/HEAD/Notes/Calculus-Derivative/x2.fig -------------------------------------------------------------------------------- /Notes/Calculus-Derivative/x2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathosProject/Mathos-Project/HEAD/Notes/Calculus-Derivative/x2.png -------------------------------------------------------------------------------- /Laboratory/Fakes/MathParser.fakes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathosProject/Mathos-Project/HEAD/Laboratory/Fakes/MathParser.fakes -------------------------------------------------------------------------------- /Notes/Calculus-Derivative/exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathosProject/Mathos-Project/HEAD/Notes/Calculus-Derivative/exp.png -------------------------------------------------------------------------------- /Notes/Calculus-Derivative/x10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MathosProject/Mathos-Project/HEAD/Notes/Calculus-Derivative/x10.png -------------------------------------------------------------------------------- /Laboratory/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ProjectWebsite/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Interactive Mathematics/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IReal.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents a real number. 5 | /// 6 | public interface IReal : IComplex 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IInteger.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents an integer. 5 | /// 6 | public interface IInteger : IRational 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/INatural.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents a natural number. 5 | /// 6 | public interface INatural : IWhole 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IRational.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents a rational number. 5 | /// 6 | public interface IRational : IReal 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /MathosTest/Geometry/Trigonometry.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace MathosTest.Geometry 4 | { 5 | [TestClass] 6 | public class Trigonometry 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IComplex.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents a complex number. 5 | /// 6 | public interface IComplex 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IImaginary.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents an imaginary number. 5 | /// 6 | public interface IImaginary : IComplex 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IIrrational.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents an irrational number. 5 | /// 6 | public interface IIrrational : IReal 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/IWhole.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// Represents a whole number. 5 | /// 6 | public interface IWhole : IInteger 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Laboratory/About.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory 5 | { 6 | public partial class About : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /MathosTest/Arithmetic/DecimalArithmetic.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace MathosTest.Arithmetic 4 | { 5 | [TestClass] 6 | public class DecimalArithmetic 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Laboratory/Default.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory 5 | { 6 | public partial class Default : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Laboratory/Modules.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory 5 | { 6 | public partial class Modules : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Interactive Mathematics/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Laboratory/Site.Master.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory 5 | { 6 | public partial class SiteMaster : MasterPage 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Laboratory/Account/ChangePassword.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory.Account 5 | { 6 | public partial class ChangePassword : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Laboratory/Account/ChangePasswordSuccess.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory.Account 5 | { 6 | public partial class ChangePasswordSuccess : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /Interactive Mathematics/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Interactive Mathematics/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Windows; 7 | 8 | namespace Interactive_Mathematics 9 | { 10 | /// 11 | /// Логика взаимодействия для App.xaml 12 | /// 13 | public partial class App : Application 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Laboratory/Account/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /TraceAndTestImpact.testsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Это параметры для трассировки и влияния тестирования 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Mathos/TraceAndTestImpact.testsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | Это параметры для трассировки и влияния тестирования 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Laboratory/Module/MConverter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MConverter.aspx.cs" Inherits="Laboratory.Module.MConverter" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Laboratory/Account/Login.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Account 6 | { 7 | public partial class Login : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + 12 | HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Mathos/Geometry/Shapes/IShape2D.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Geometry.Shapes 2 | { 3 | /// 4 | /// Represents a two-dimensional shape. 5 | /// 6 | public interface IShape2D 7 | { 8 | /// 9 | /// Area of the shape. 10 | /// 11 | double Area { get; } 12 | 13 | /// 14 | /// Perimeter of the shape. 15 | /// 16 | double Perimeter { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Mathos/Geometry/Shapes/IShape3D.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Geometry.Shapes 2 | { 3 | /// 4 | /// Represents a three-dimensional shape. 5 | /// 6 | public interface IShape3D 7 | { 8 | /// 9 | /// Volume of the shape. 10 | /// 11 | double Volume { get; } 12 | 13 | /// 14 | /// Surface area of the shape. 15 | /// 16 | double SurfaceArea { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Laboratory/About.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory 11 | { 12 | 13 | 14 | public partial class About 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Mathos.vsmdi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Mathos/Mathos.vsmdi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Interactive Mathematics/frmTable.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Interactive_Mathematics 4 | { 5 | /// 6 | /// Логика взаимодействия для Window1.xaml 7 | /// Logic of interaction for Window1.xaml 8 | /// 9 | public partial class FrmTable 10 | { 11 | public FrmTable() 12 | { 13 | InitializeComponent(); 14 | dataGrid1.ItemsSource = Funcs; 15 | } 16 | 17 | public Dictionary Funcs = new Dictionary(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Laboratory/Account/ChangePasswordSuccess.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Account 11 | { 12 | 13 | 14 | public partial class ChangePasswordSuccess 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Laboratory/Account/ChangePasswordSuccess.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 2 | CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="Laboratory.Account.ChangePasswordSuccess" %> 3 | 4 | 5 | 6 | 7 |

8 | Change Password 9 |

10 |

11 | Your password has been changed successfully. 12 |

13 |
-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mathos Project 2 | ## About 3 | Mathos is a collection of tools for any kinds of mathematical calculations. It allows you to work with shapes, finance, unit conversions, and more! 4 | 5 | > PM> Install-Package Mathos 6 | 7 | #### [Java Port](https://github.com/MathosProject/Mathos-Project-Java) 8 | 9 | *Mathos is single library that contains different functions in areas like: Arithmetic, Coordinate Geometry, Fractions. For the moment, it's not quite finished, and more features will be added.* 10 | 11 | **Documentation: http://mpapidocs.azurewebsites.net/mathos-core-library/** 12 | -------------------------------------------------------------------------------- /Laboratory/About.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 2 | CodeBehind="About.aspx.cs" Inherits="Laboratory.About" %> 3 | 4 | 5 | 6 | 7 |

About

8 |

9 | This page is designed for users to test all of the features included in Mathos 10 | Core. 11 |

12 |

Please visit our about page here!

13 |
-------------------------------------------------------------------------------- /MathosTest/SpecialFunctions/Antiderivatives.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | using Mathos.SpecialFunctions; 4 | 5 | namespace MathosTest.SpecialFunctions 6 | { 7 | [TestClass] 8 | public class UnitTest1 9 | { 10 | [TestMethod] 11 | public void Erf() 12 | { 13 | Assert.AreEqual(Antiderivatives.Erf(5), 0.99999999999846378); 14 | } 15 | 16 | [TestMethod] 17 | public void Erfc() 18 | { 19 | Assert.AreEqual(Antiderivatives.Erfc(5), 1 - Antiderivatives.Erf(5)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Notes/Calculus-Derivative/derivativeerror.m: -------------------------------------------------------------------------------- 1 | NET.addAssembly('C:\Users\Artem\Documents\GitHub\Mathos-Project\Mathos\bin\Debug\Mathos.dll'); 2 | table = []; 3 | 4 | syms x 5 | df = diff(sin(x)); 6 | a= 10 7 | val = subs(df,a); 8 | 9 | 10 | % Double has precision 15-16 digits: https://msdn.microsoft.com/en-us/library/678hzkk9.aspx 11 | for i=1:30 12 | value = Mathos.Calculus.DifferentialCalculus.FirstDerivative(@(d) sin(d), a,10^(-i)); 13 | row = [10^(-i) val value abs(value-val)]; 14 | table=[table;row]; 15 | end 16 | table; 17 | ind = table(:,1); 18 | dep = table(:,3); 19 | 20 | 21 | loglog(ind,dep) 22 | title('sin(x)') -------------------------------------------------------------------------------- /MathosTest/Arithmetic/SingleArthimeticTest.cs: -------------------------------------------------------------------------------- 1 | using Mathos.Arithmetic; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace MathosTest.Arithmetic 5 | { 6 | [TestClass] 7 | public class SingleArthimeticTest 8 | { 9 | private const float Epsilon = 0.01f; 10 | 11 | [TestMethod] 12 | public void TestSqrt() 13 | { 14 | const float number = Constants.Single.PI; 15 | 16 | var root = SingleArithmetic.Sqrt(number); 17 | 18 | Assert.IsTrue(number.ApproximatelyEquals(root * root, Epsilon)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Laboratory/Module/MConverter.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | 4 | namespace Laboratory.Module 5 | { 6 | public partial class MConverter : Page 7 | { 8 | protected void Page_Load(object sender, EventArgs e) 9 | { 10 | //Length 1 11 | //Speed 2 12 | //Mass 3 13 | //Area 4 14 | //Volume 5 15 | //Base 6 16 | if (Request["t"] == "1" && Request["u1"] == "1" && Request["u2"] == "2") 17 | { 18 | //Mathos.Conversion.Converter.From(Enum.GetName(Length,0), "3").To(Length.Foot); 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /MathosTest/Statistics and DiceSim/LinearModels.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Mathos.Statistics; 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace MathosTest.Statistics_and_DiceSim 6 | { 7 | [TestClass] 8 | public class LinearModelsTest 9 | { 10 | [TestMethod] 11 | public void PredictionTest() 12 | { 13 | var x = new List {1, 2, 3, 4, 5, 6, 7}; 14 | var y = new List {2, 4, 6, 8, 10, 12, 14}; 15 | var res = LinearModels.LinearRegression(x, y); 16 | var b = res.Predict(10); 17 | 18 | Assert.AreEqual(b, 20); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/Convert.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic.Numbers 2 | { 3 | /// 4 | /// 5 | /// 6 | public class Convert 7 | { 8 | /// 9 | /// 10 | /// 11 | /// 12 | /// 13 | public static long ToPositive(long num) 14 | { 15 | return num < 0 ? num*-1 : num; 16 | } 17 | 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | public static long ToNegative(long num) 24 | { 25 | return num > 0 ? num*-1 : num; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Mathos/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("Mathos")] 5 | [assembly: AssemblyDescription("http://mathosproject.com/")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("Mathos Project")] 8 | [assembly: AssemblyProduct("Mathos Core Library")] 9 | [assembly: AssemblyCopyright("Copyright © 2012-2018, Mathos Project.")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: Guid("a5b49b06-0dfc-49cb-b599-7bd14dbaa1a8")] 16 | 17 | // [assembly: AssemblyVersion("1.0.*")] 18 | [assembly: AssemblyVersion("1.0.6.0")] 19 | [assembly: AssemblyFileVersion("1.0.6.0")] 20 | -------------------------------------------------------------------------------- /Laboratory/Modules.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory { 11 | 12 | 13 | public partial class Modules { 14 | 15 | /// 16 | /// Table1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.Table Table1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Laboratory/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory { 11 | 12 | 13 | public partial class Default { 14 | 15 | /// 16 | /// HyperLink1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.HyperLink HyperLink1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Laboratory/Account/Register.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.Security; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Account 6 | { 7 | public partial class Register : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; 12 | } 13 | 14 | protected void RegisterUser_CreatedUser(object sender, EventArgs e) 15 | { 16 | FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); 17 | 18 | var continueUrl = RegisterUser.ContinueDestinationPageUrl; 19 | 20 | if (string.IsNullOrEmpty(continueUrl)) 21 | { 22 | continueUrl = "~/"; 23 | } 24 | 25 | Response.Redirect(continueUrl); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Laboratory/Module/MConverter.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module { 11 | 12 | 13 | public partial class MConverter { 14 | 15 | /// 16 | /// returnvalue control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlGenericControl returnvalue; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Laboratory/Account/ChangePassword.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Account 11 | { 12 | 13 | 14 | public partial class ChangePassword 15 | { 16 | 17 | /// 18 | /// ChangeUserPassword control. 19 | /// 20 | /// 21 | /// Auto-generated field. 22 | /// To modify move field declaration from designer file to code-behind file. 23 | /// 24 | protected global::System.Web.UI.WebControls.ChangePassword ChangeUserPassword; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MathosTest/Arithmetic/IntegerArthimeticTest.cs: -------------------------------------------------------------------------------- 1 | using Mathos.Arithmetic; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace MathosTest.Arithmetic 5 | { 6 | [TestClass] 7 | public class IntegerArthimeticTest 8 | { 9 | [TestMethod] 10 | public void TestSqrt() 11 | { 12 | Assert.AreEqual(9, IntegerArithmetic.Sqrt(81)); 13 | Assert.AreEqual(9, IntegerArithmetic.Sqrt(99)); 14 | } 15 | 16 | // TODO: Make faster 17 | //[TestMethod] 18 | //public void TestIfSqrtIsFasterThanMathSqrt() 19 | //{ 20 | // int iter = 250000; 21 | 22 | // double avgSqrt = BenchmarkUtil.Benchmark(() => 23 | // { int r = IntegerArithmetic.Sqrt(28); }, 24 | // iter); 25 | 26 | // double avgMath = BenchmarkUtil.Benchmark(() => 27 | // { int r = (int)Math.Sqrt(28); }, 28 | // iter); 29 | 30 | // Assert.IsTrue(avgMath > avgSqrt); 31 | //} 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Interactive Mathematics/frmTable.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Laboratory/Global.asax.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web; 3 | 4 | namespace Laboratory 5 | { 6 | public class Global : HttpApplication 7 | { 8 | private void Application_Start(object sender, EventArgs e) 9 | { 10 | // Code that runs on application startup 11 | } 12 | 13 | private void Application_End(object sender, EventArgs e) 14 | { 15 | // Code that runs on application shutdown 16 | } 17 | 18 | private void Application_Error(object sender, EventArgs e) 19 | { 20 | // Code that runs when an unhandled error occurs 21 | } 22 | 23 | private void Session_Start(object sender, EventArgs e) 24 | { 25 | // Code that runs when a new session is started 26 | } 27 | 28 | private void Session_End(object sender, EventArgs e) 29 | { 30 | // Code that runs when a session ends. 31 | // Note: The Session_End event is raised only when the sessionstate mode 32 | // is set to InProc in the Web.config file. If session mode is set to StateServer 33 | // or SQLServer, the event is not raised. 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /MathosTest/VectorTest.cs: -------------------------------------------------------------------------------- 1 | using Mathos; 2 | 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace MathosTest 6 | { 7 | [TestClass] 8 | public class VectorTest 9 | { 10 | [TestMethod] 11 | public void ToStringTest() 12 | { 13 | var vector = new Vector(1, 2, 3, 4); 14 | 15 | Assert.AreEqual("1 2 3 4", vector.ToString()); 16 | } 17 | 18 | [TestMethod] 19 | public void OperationsTest() 20 | { 21 | var vecA = new Vector(1, 2, 3, 4, 5); 22 | var vecB = new Vector(3, 4, 5, 6, 7); 23 | var result = vecA + vecB; 24 | 25 | Assert.AreEqual(result, new Vector(4, 6, 8, 10, 12)); 26 | } 27 | 28 | [TestMethod] 29 | public void ComparisonTest() 30 | { 31 | var vecA = new Vector(1, 2, 3, 4, 5); 32 | var vecB = new Vector(1, 2, 3, 4, 5); 33 | 34 | Assert.AreEqual(vecA, vecB); 35 | 36 | var vecC = new Vector(1, 2, 3, 4, 5, 6); 37 | 38 | Assert.AreNotEqual(vecA, vecC); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Mathos/SpecialFunctions/Antiderivatives.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using Mathos.Calculus; 4 | using Mathos.Arithmetic; 5 | 6 | namespace Mathos.SpecialFunctions 7 | { 8 | /// 9 | /// 10 | /// 11 | public static class Antiderivatives 12 | { 13 | /// 14 | /// 15 | /// 16 | /// 17 | public static double Erf(double x) 18 | { 19 | return Constants.TwoOverSqrtOfPI * IntegralCalculus.Integrate(t => Math.Pow(Math.E, -(t * t)), 0, x); 20 | } 21 | 22 | /// 23 | /// 24 | /// 25 | /// 26 | public static double Erfc(double x) 27 | { 28 | return 1 - Erf(x); 29 | } 30 | 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | public static Complex Erfi(Complex z) 37 | { 38 | throw new NotImplementedException(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Interactive Mathematics/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.269 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Interactive_Mathematics.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Laboratory/Account/Login.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Account 11 | { 12 | 13 | 14 | public partial class Login 15 | { 16 | 17 | /// 18 | /// RegisterHyperLink control. 19 | /// 20 | /// 21 | /// Auto-generated field. 22 | /// To modify move field declaration from designer file to code-behind file. 23 | /// 24 | protected global::System.Web.UI.WebControls.HyperLink RegisterHyperLink; 25 | 26 | /// 27 | /// LoginUser control. 28 | /// 29 | /// 30 | /// Auto-generated field. 31 | /// To modify move field declaration from designer file to code-behind file. 32 | /// 33 | protected global::System.Web.UI.WebControls.Login LoginUser; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Laboratory/Account/Register.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Account 11 | { 12 | 13 | 14 | public partial class Register 15 | { 16 | 17 | /// 18 | /// RegisterUser control. 19 | /// 20 | /// 21 | /// Auto-generated field. 22 | /// To modify move field declaration from designer file to code-behind file. 23 | /// 24 | protected global::System.Web.UI.WebControls.CreateUserWizard RegisterUser; 25 | 26 | /// 27 | /// RegisterUserWizardStep control. 28 | /// 29 | /// 30 | /// Auto-generated field. 31 | /// To modify move field declaration from designer file to code-behind file. 32 | /// 33 | protected global::System.Web.UI.WebControls.CreateUserWizardStep RegisterUserWizardStep; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Laboratory/Module/Factorial.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Web.UI; 4 | using Mathos.Arithmetic.Numbers; 5 | using Convert = System.Convert; 6 | 7 | namespace Laboratory.Module 8 | { 9 | public partial class Factorial : Page 10 | { 11 | protected void Page_Load(object sender, EventArgs e) 12 | { 13 | } 14 | 15 | protected void CalculateButton_Click(object sender, EventArgs e) 16 | { 17 | try 18 | { 19 | if (NumberText.Text.Length < 5) 20 | { 21 | var watch = new Stopwatch(); 22 | watch.Start(); 23 | 24 | ResultTextbox.Text = 25 | Get.FactorialBigInteger(Convert.ToInt64(NumberText.Text)).ToString(); 26 | 27 | watch.Stop(); 28 | ElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds); 29 | } 30 | else 31 | { 32 | ErrorLabel.Text = "At this stage, the number is bigger than the set limit."; 33 | } 34 | } 35 | catch 36 | { 37 | ErrorLabel.Text = "Error!"; 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /MathosTest/BenchmarkUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace Mathos 5 | { 6 | /// 7 | /// A utility class for benchmarking. 8 | /// 9 | public class BenchmarkUtil 10 | { 11 | /// 12 | /// Perform an benchmark with . 13 | /// 14 | /// The action to perform. 15 | /// The amount of iterations. 16 | /// The amount of time taken. 17 | public static double Benchmark(Action action, int iterations) 18 | { 19 | double time = 0; 20 | const int innerCount = 5; 21 | 22 | GC.Collect(); 23 | GC.WaitForPendingFinalizers(); 24 | GC.Collect(); 25 | 26 | for (var i = 0; i < innerCount; i++) 27 | action.Invoke(); 28 | 29 | var watch = Stopwatch.StartNew(); 30 | 31 | for (var i = 0; i < iterations; i++) 32 | { 33 | action.Invoke(); 34 | time += Convert.ToDouble(watch.ElapsedMilliseconds) / Convert.ToDouble(iterations); 35 | } 36 | 37 | return time; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /MathosTest/Statistics and DiceSim/DiceSimulatorTest.cs: -------------------------------------------------------------------------------- 1 | using Mathos.Statistics; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace MathosTest.Statistics_and_DiceSim 5 | { 6 | [TestClass] 7 | public class DiceSimulatorTest 8 | { 9 | [TestMethod] 10 | public void TestRoll6Dice() 11 | { 12 | const int numDice = 6; 13 | 14 | var d = new DiceSimulator(numDice); 15 | var p = d.ToString(); 16 | 17 | System.Diagnostics.Trace.TraceInformation(p); 18 | System.Diagnostics.Trace.TraceInformation(d[1] + " " + d[2] +" " + d[3]); // testing indexer 19 | 20 | var sum = d.SumDiceRoll(); 21 | 22 | Assert.IsTrue(sum <= numDice * 6); 23 | 24 | var max = d.MaxDiceRoll(); 25 | 26 | Assert.IsTrue(max <= 6); 27 | } 28 | 29 | /* 30 | [TestMethod] 31 | public void DiceDiff() 32 | { 33 | var d = new DiceSimulator(2); 34 | int iter = 250000; 35 | 36 | double averageTime = BenchmarkUtil.Benchmark(() => d.DiffDiceRoll(), iter); 37 | 38 | System.Diagnostics.Debug.WriteLine("DiceDiffExecution time: " +averageTime + "ms"); 39 | } 40 | */ 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Laboratory/Module/Factorial.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Factorial.aspx.cs" Inherits="Laboratory.Module.Factorial" %> 2 | 3 | 4 | 5 | 6 |
7 | Factorial 8 |
9 | 10 |

11 | Factorial is the product of n terms, which usually is written as n!, which is the same as n! = 1 * 2 * ... * (n-1) * n. 12 |

13 | 14 | 15 | 16 | 19 | 22 | 23 |
17 | Number 18 | 20 | 21 |
24 | 25 |

26 | 28 |
29 |
30 | 31 | 32 |
33 | 34 |

35 | 36 |
-------------------------------------------------------------------------------- /Laboratory/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /MathosTest/PreCalculus/PreCalculus.cs: -------------------------------------------------------------------------------- 1 | using Mathos.PreCalculus; 2 | 3 | using Microsoft.VisualStudio.TestTools.UnitTesting; 4 | 5 | namespace MathosTest.PreCalculus 6 | { 7 | [TestClass] 8 | public class PreCalculus 9 | { 10 | [TestMethod] 11 | public void CalculateSum() 12 | { 13 | var s = Fibonacci.Sum(3, 5); 14 | 15 | Assert.AreEqual(10, s); 16 | } 17 | 18 | [TestMethod] 19 | public void ArithmeticSequence() 20 | { 21 | var a = new ArithmeticSequence 22 | { 23 | InitialTerm = 2, 24 | CommonDifference = 4 25 | }; 26 | 27 | Assert.AreEqual(18, a.NTerm(5)); 28 | } 29 | 30 | [TestMethod] 31 | public void GeometricSequence() 32 | { 33 | var g1 = new GeometricSequence 34 | { 35 | InitialTerm = 2, 36 | CommonRatio = 3 37 | }; 38 | 39 | Assert.AreEqual(486, g1.NTerm(5)); 40 | 41 | var g2 = new GeometricSequence 42 | { 43 | InitialTerm = 2, 44 | CommonRatio = 0.5 45 | }; 46 | 47 | Assert.AreEqual(4, g2.InfiniteSum()); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ProjectWebsite/Web.Debug.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | -------------------------------------------------------------------------------- /Mathos/Converter/ConversionObjects.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Converter 4 | { 5 | /// 6 | /// 7 | /// 8 | public class ConversionInfo 9 | { 10 | /// 11 | /// 12 | /// 13 | public Enum Unit; 14 | 15 | /// 16 | /// 17 | /// 18 | public double Value; 19 | 20 | /// 21 | /// 22 | /// 23 | /// 24 | /// 25 | public ConversionInfo(Enum unit, double value) 26 | { 27 | Unit = unit; 28 | Value = value; 29 | } 30 | } 31 | 32 | /// 33 | /// 34 | /// 35 | public class ConversionBase 36 | { 37 | /// 38 | /// 39 | /// 40 | public Base Unit; 41 | 42 | /// 43 | /// 44 | /// 45 | public string Value; 46 | 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | public ConversionBase(Base unit, string value) 53 | { 54 | Unit = unit; 55 | Value = value; 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Laboratory/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /ProjectWebsite/Web.Release.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | -------------------------------------------------------------------------------- /ProjectWebsite/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | 25 | 26 | 27 | 28 | 29 | 33 | -------------------------------------------------------------------------------- /Laboratory/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("Laboratory")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Laboratory")] 13 | [assembly: AssemblyCopyright("Copyright © 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | 25 | [assembly: Guid("9dc4df36-2f5c-47d3-8a39-d816806b42cb")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | // You can specify all the values or you can default the Revision and Build Numbers 35 | // by using the '*' as shown below: 36 | 37 | [assembly: AssemblyVersion("1.0.0.0")] 38 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Laboratory/Module/DataAnalysis/PolynomSeq.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PolynomSeq.aspx.cs" Inherits="Laboratory.Module.DataAnalysis.WebForm1" %> 2 | 3 | 4 | 5 |
Polynomial Sequences 6 |
7 |

8 | This application allows you to find a polynomial that generated a specific sequence and the closed form of the sum of that polynomial.

9 | 10 |

Find the nth term or the expression for the sum
11 | Enter the sequence below. Separate each term by a comma. For example, enter 1,2,3,4,5.

12 | 13 |
14 |
15 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 |

You can access FiniteCalculus class by including Mathos.Calculus.

27 | 28 | 29 | 30 | 31 | 32 |
33 | -------------------------------------------------------------------------------- /Laboratory/Module/NumberChecker.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="NumberChecker.aspx.cs" Inherits="Laboratory.Module.NumberChecker" %> 2 | 3 | 4 | 5 | 6 |
7 | Number checker 8 |
9 | 10 | 11 | 12 | 21 | 24 | 25 |
13 | 14 | Is Positive 15 | Is Negative 16 | Is Even 17 | Is Odd 18 | Is Prime 19 | 20 | 22 | 23 |
26 | 27 |

28 | 30 |
31 |
32 | 33 | 34 |
35 | 36 |

37 | 38 |
-------------------------------------------------------------------------------- /ProjectWebsite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("ProjectWebsite")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("ProjectWebsite")] 12 | [assembly: AssemblyCopyright("Copyright © 2012-2016")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("4fcbe6fb-b8a4-40b6-be80-3eccfdb16724")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /MathosTest/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // Общие сведения об этой сборке предоставляются следующим набором 5 | // атрибутов. Отредактируйте значения этих атрибутов, чтобы изменить 6 | // общие сведения об этой сборке. 7 | [assembly: AssemblyTitle("MathosTest")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("Artem Los")] 11 | [assembly: AssemblyProduct("MathosTest")] 12 | [assembly: AssemblyCopyright("Copyright © 2012-2017 Mathos Project")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Установка значения False в параметре ComVisible делает типы в этой сборке невидимыми 17 | // для компонентов COM. Если необходимо обратиться к типу в этой сборке через 18 | // COM, следует установить атрибут ComVisible в TRUE для этого типа. 19 | [assembly: ComVisible(false)] 20 | 21 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM 22 | [assembly: Guid("411590a0-5e75-407c-8add-88c511255162")] 23 | 24 | // Сведения о версии сборки состоят из следующих четырех значений: 25 | // 26 | // Основной номер версии 27 | // Дополнительный номер версии 28 | // Номер построения 29 | // Редакция 30 | // 31 | // Можно задать все значения или принять номер построения и номер редакции по умолчанию, 32 | // используя "*", как показано ниже: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /Laboratory/Module/NumberChecker.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Web.UI; 4 | using Mathos.Arithmetic.Numbers; 5 | using Convert = System.Convert; 6 | 7 | namespace Laboratory.Module 8 | { 9 | public partial class NumberChecker : Page 10 | { 11 | protected void Page_Load(object sender, EventArgs e) 12 | { 13 | } 14 | 15 | protected void CalculateButton_Click(object sender, EventArgs e) 16 | { 17 | if (TextBox1.Text == "") 18 | return; 19 | 20 | var watch = new Stopwatch(); 21 | watch.Start(); 22 | 23 | if (DropDownList1.SelectedIndex == 0) 24 | ResultLabel.Text = Check.IsPositive(Convert.ToInt64(TextBox1.Text)) ? "True!" : "False!"; 25 | if (DropDownList1.SelectedIndex == 1) 26 | ResultLabel.Text = Check.IsNegative(Convert.ToInt64(TextBox1.Text)) ? "True!" : "False!"; 27 | if (DropDownList1.SelectedIndex == 2) 28 | ResultLabel.Text = Check.IsEven(Convert.ToInt64(TextBox1.Text)) ? "True!" : "False!"; 29 | if (DropDownList1.SelectedIndex == 3) 30 | ResultLabel.Text = Check.IsOdd(Convert.ToInt64(TextBox1.Text)) ? "True!" : "False!"; 31 | if (DropDownList1.SelectedIndex == 4) 32 | ResultLabel.Text = Check.IsPrime(Convert.ToInt64(TextBox1.Text)) ? "True!" : "False!"; 33 | 34 | watch.Stop(); 35 | ElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /ProjectWebsite/Default.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace ProjectWebsite { 11 | 12 | 13 | public partial class Default { 14 | 15 | /// 16 | /// text control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlInputText text; 23 | 24 | /// 25 | /// Calc control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.HtmlControls.HtmlInputButton Calc; 32 | 33 | /// 34 | /// result control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.HtmlControls.HtmlGenericControl result; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Interactive Mathematics/removedCode.txt: -------------------------------------------------------------------------------- 1 | parser.LocalFunctions.Add("table", x => 2 | { 3 | //decimal m = 0; // y=mx+c 4 | //decimal c = 0; 5 | 6 | //if (x.Length == 1) 7 | //{ 8 | // m = x[0]; 9 | //} 10 | //else if (x.Length == 2) 11 | //{ 12 | // m = x[0]; 13 | // c = x[1]; 14 | //} 15 | 16 | //if (parser.LocalVariables["table_min"] > 10000) 17 | //{ 18 | // if (MessageBox.Show("You 'table_min' is bigger than 10,000, which might take a while to calculate. Are you sure you want to continue?", "Huge value", MessageBoxButton.YesNo) == MessageBoxResult.No) 19 | // { 20 | // return 0; 21 | // } 22 | //} 23 | 24 | //string expr = textBox1.Text; 25 | 26 | //frmTable _form = new frmTable(); 27 | 28 | //long min = (long)parser.LocalVariables["table_min"]; 29 | //long max = (long)parser.LocalVariables["table_max"]; 30 | //long step = (long)parser.LocalVariables["table_step"]; 31 | 32 | 33 | //Parallel.For(min, max+1, i => 34 | // { 35 | // i += step; 36 | // _form._funcs.Add(i, m * i + c); 37 | 38 | // }); 39 | 40 | //_form.Show(); 41 | 42 | return 0; 43 | }); -------------------------------------------------------------------------------- /Laboratory/Site.Master.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory { 11 | 12 | 13 | public partial class SiteMaster { 14 | 15 | /// 16 | /// HeadContent control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.ContentPlaceHolder HeadContent; 23 | 24 | /// 25 | /// NavigationMenu control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Menu NavigationMenu; 32 | 33 | /// 34 | /// MainContent control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContent; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MathosTest/Algebra/EquationSolver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Mathos; 4 | using Mathos.Arithmetic; 5 | 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | namespace MathosTest.Algebra 9 | { 10 | [TestClass] 11 | public class EquationSolverTest 12 | { 13 | [TestMethod] 14 | public void QuadraticEquationExTest() 15 | { 16 | //equation 2x^2+3x-1 17 | var result = EquationSolver.QuadraticEquationEx(2, 3, -1); 18 | 19 | Assert.IsTrue(result[0].ApproximatelyEquals(-1.78077640640442, 1e1-0)); 20 | Assert.IsTrue(result[1].ApproximatelyEquals(0.280776406404415, 1e-10)); 21 | } 22 | 23 | [Obsolete] 24 | [TestMethod] 25 | public void QuadraticEquationTest() 26 | { 27 | //equation 2x^2+3x-1 28 | var result = EquationSolver.QuadraticEquation(2, 3, -1); 29 | 30 | Assert.IsTrue(result[0].Real.ApproximatelyEquals(-1.78077640640442, 1e1 - 0)); 31 | Assert.IsTrue(result[0].Imaginary.ApproximatelyEquals(0, 1e1 - 0)); 32 | 33 | Assert.IsTrue(result[1].Real.ApproximatelyEquals(0.280776406404415, 1e-10)); 34 | Assert.IsTrue(result[1].Imaginary.ApproximatelyEquals(0, 1e1 - 0)); 35 | } 36 | 37 | [TestMethod] 38 | public void SystemOfTwoEquationsTest() 39 | { 40 | //equation 4x + 5y = 47 41 | // 2x + 9y = 69 42 | var solution = EquationSolver.SystemOfTwoEquations(4, 5, 2, 9, 47, 69); 43 | 44 | Assert.AreEqual(solution, new Vector(3, 7)); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Mathos/Converter/TemperatureConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Converter 4 | { 5 | /// 6 | /// 7 | /// 8 | public class TemperatureConversion 9 | { 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | public static double ConvertTemperature(ConversionInfo conversionInfo, Enum unit) 17 | { 18 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeC && (Temperature) unit == Temperature.DegreeK) 19 | return conversionInfo.Value + 273.15; 20 | 21 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeC && (Temperature) unit == Temperature.DegreeF) 22 | return conversionInfo.Value*9/5 + 32; 23 | 24 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeF && (Temperature) unit == Temperature.DegreeC) 25 | return (conversionInfo.Value - 32)*5/9; 26 | 27 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeF && (Temperature) unit == Temperature.DegreeK) 28 | return (conversionInfo.Value - 32)*5/9 + 273.15; 29 | 30 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeK && (Temperature) unit == Temperature.DegreeF) 31 | return (conversionInfo.Value - 273.15)*9/5 + 32; 32 | 33 | if ((Temperature) conversionInfo.Unit == Temperature.DegreeK && (Temperature) unit == Temperature.DegreeC) 34 | return conversionInfo.Value - 273.15; 35 | 36 | return conversionInfo.Value; 37 | } 38 | }; 39 | } -------------------------------------------------------------------------------- /Mathos/Geometry/Pythagorean.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Geometry 4 | { 5 | /// 6 | /// Used to find the length of a side of a right triangle. 7 | /// 8 | public static class Pythagorean 9 | { 10 | /// 11 | /// Get the hypotenuse given two sides of a right triangle. 12 | /// 13 | /// Length of the first side. 14 | /// Length of the second side. 15 | /// Length of the hypotenuse. 16 | public static double FindHypotenuse(double side1, double side2) 17 | { 18 | if (side1 <= 0) 19 | throw new ArgumentOutOfRangeException(nameof(side1)); 20 | if (side2 <= 0) 21 | throw new ArgumentOutOfRangeException(nameof(side2)); 22 | 23 | return Math.Sqrt(side1 * side1 + side2 * side2); 24 | } 25 | 26 | /// 27 | /// Get the length of a side given another side and the hypotenuse of a right triangle. 28 | /// 29 | /// Length of a side. 30 | /// Length of the hypotenuse. 31 | /// Length of the remaining side 32 | public static double SideFromHypotenuse(double side1, double hypotenuse) 33 | { 34 | if (side1 <= 0 || side1 >= hypotenuse) 35 | throw new ArgumentOutOfRangeException(nameof(side1)); 36 | if (hypotenuse <= 0) 37 | throw new ArgumentOutOfRangeException(nameof(hypotenuse)); 38 | 39 | return Math.Sqrt(hypotenuse * hypotenuse - side1 * side1); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Laboratory/Module/DataAnalysis/LinearRegression.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Web.UI; 6 | using Mathos.Statistics; 7 | 8 | namespace Laboratory.Module.DataAnalysis 9 | { 10 | public partial class LinearRegression : Page 11 | { 12 | protected void Page_Load(object sender, EventArgs e) 13 | { 14 | } 15 | 16 | protected void Button1_Click(object sender, EventArgs e) 17 | { 18 | if (TextBox1.Text != "" && TextBox2.Text != "") 19 | { 20 | var xIn = TextBox1.Text.Split(','); 21 | var yIn = TextBox2.Text.Split(','); 22 | 23 | List x; 24 | List y; 25 | 26 | try 27 | { 28 | x = Array.ConvertAll(xIn, decimal.Parse).ToList(); 29 | y = Array.ConvertAll(yIn, decimal.Parse).ToList(); 30 | } 31 | catch 32 | { 33 | Label1.Text = "Could not convert the sequence into an array."; 34 | 35 | return; 36 | } 37 | 38 | var res = LinearModels.LinearRegression(x, y); 39 | lblLinearEq.Text = res.ToString(); 40 | lblRVal.Text = res.R.ToString(CultureInfo.InvariantCulture); 41 | lblRSqVal.Text = res.R2.ToString(CultureInfo.InvariantCulture); 42 | lblRegCoeff.Text = res.B.ToString(CultureInfo.InvariantCulture); 43 | lblIntr.Text = res.Intercept.ToString(CultureInfo.InvariantCulture); 44 | } 45 | else 46 | { 47 | Label1.Text = "No sequence was entered."; 48 | } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Laboratory/Module/Triangle.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Globalization; 4 | using System.Web.UI; 5 | 6 | namespace Laboratory.Module 7 | { 8 | public partial class Triangle : Page 9 | { 10 | protected void Page_Load(object sender, EventArgs e) 11 | { 12 | } 13 | 14 | protected void CalculateButton_Click(object sender, EventArgs e) 15 | { 16 | try 17 | { 18 | var watch = new Stopwatch(); 19 | watch.Start(); 20 | 21 | var triangle = new Mathos.Geometry.Shapes.Triangle(ToDoubleC(TextBox1.Text), ToDoubleC(TextBox2.Text), 22 | ToDoubleC(TextBox3.Text), ToDoubleC(TextBox4.Text), ToDoubleC(TextBox5.Text), 23 | ToDoubleC(TextBox6.Text)); 24 | 25 | watch.Stop(); 26 | ElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds); 27 | 28 | TextBox1.Text = triangle.SideA.ToString(CultureInfo.InvariantCulture); 29 | TextBox2.Text = triangle.SideB.ToString(CultureInfo.InvariantCulture); 30 | TextBox3.Text = triangle.SideC.ToString(CultureInfo.InvariantCulture); 31 | TextBox4.Text = triangle.AngleA.ToString(CultureInfo.InvariantCulture); 32 | TextBox5.Text = triangle.AngleB.ToString(CultureInfo.InvariantCulture); 33 | TextBox6.Text = triangle.AngleC.ToString(CultureInfo.InvariantCulture); 34 | } 35 | catch 36 | { 37 | ErrorLabel.Text = "Not enough information!"; 38 | } 39 | } 40 | 41 | protected double ToDoubleC(string input) 42 | { 43 | return input == "" || input == "NaN" ? 0 : Convert.ToDouble(input); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceFutureValue.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Module.Finance 6 | { 7 | public partial class FinanceFutureValue : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void CalculateButton_Click(object sender, EventArgs e) 14 | { 15 | Calculate(); 16 | } 17 | 18 | private void Calculate() 19 | { 20 | decimal presentValue; 21 | 22 | if (!decimal.TryParse(PresentValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out presentValue)) 23 | presentValue = 0; 24 | 25 | decimal rateOfReturn; 26 | 27 | if (!decimal.TryParse(RateOfReturnText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out rateOfReturn)) 28 | rateOfReturn = 0; 29 | 30 | int numberOfPeriods; 31 | 32 | if ( 33 | !int.TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 34 | out numberOfPeriods)) 35 | numberOfPeriods = 0; 36 | 37 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 38 | 39 | try 40 | { 41 | var result = Mathos.Finance.Finance.FutureValue( 42 | presentValue, 43 | rateOfReturn, 44 | numberOfPeriods, 45 | roundToTwoDecimalPlaces); 46 | 47 | ResultLabel.Text = string.Format( 48 | "Future value: {0}", 49 | result.ToString(CultureInfo.CurrentCulture)); 50 | } 51 | catch 52 | { 53 | ErrorLabel.Text = "Error!"; 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinancePresentValue.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Module.Finance 6 | { 7 | public partial class FinancePresentValue : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void CalculateButton_Click(object sender, EventArgs e) 14 | { 15 | Calculate(); 16 | } 17 | 18 | private void Calculate() 19 | { 20 | decimal futureValue; 21 | 22 | if (!decimal.TryParse(FutureValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out futureValue)) 23 | futureValue = 0; 24 | 25 | decimal rateOfReturn; 26 | 27 | if (!decimal.TryParse(RateOfReturnText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out rateOfReturn)) 28 | rateOfReturn = 0; 29 | 30 | int numberOfPeriods; 31 | 32 | if ( 33 | !int.TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 34 | out numberOfPeriods)) 35 | numberOfPeriods = 0; 36 | 37 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 38 | 39 | try 40 | { 41 | var result = Mathos.Finance.Finance.PresentValue( 42 | futureValue, 43 | rateOfReturn, 44 | numberOfPeriods, 45 | roundToTwoDecimalPlaces); 46 | 47 | ResultLabel.Text = string.Format( 48 | "Present value: {0}", 49 | result.ToString(CultureInfo.CurrentCulture)); 50 | } 51 | catch 52 | { 53 | ErrorLabel.Text = "Error!"; 54 | } 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceAnnuityPaymentFutureValue.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | using static System.Int32; 5 | 6 | namespace Laboratory.Module.Finance 7 | { 8 | public partial class FinanceAnnuityPaymentFutureValue : Page 9 | { 10 | protected void Page_Load(object sender, EventArgs e) 11 | { 12 | } 13 | 14 | protected void CalculateButton_Click(object sender, EventArgs e) 15 | { 16 | Calculate(); 17 | } 18 | 19 | private void Calculate() 20 | { 21 | decimal futureValue; 22 | 23 | if (!decimal.TryParse(FutureValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out futureValue)) 24 | futureValue = 0; 25 | 26 | decimal rateOfReturn; 27 | 28 | if (!decimal.TryParse(RateOfReturnText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out rateOfReturn)) 29 | rateOfReturn = 0; 30 | 31 | int numberOfPeriods; 32 | 33 | if (!TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out numberOfPeriods)) 34 | numberOfPeriods = 0; 35 | 36 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 37 | 38 | try 39 | { 40 | var result = Mathos.Finance.Finance.AnnuityPaymentFutureValue( 41 | futureValue, 42 | rateOfReturn, 43 | numberOfPeriods, 44 | roundToTwoDecimalPlaces); 45 | 46 | ResultLabel.Text = string.Format( 47 | "Result: {0}", 48 | result.ToString(CultureInfo.CurrentCulture)); 49 | } 50 | catch 51 | { 52 | ErrorLabel.Text = "Error!"; 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceAnnuityPaymentPresentValue.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | using static System.Int32; 5 | 6 | namespace Laboratory.Module.Finance 7 | { 8 | public partial class FinanceAnnuityPaymentPresentValue : Page 9 | { 10 | protected void Page_Load(object sender, EventArgs e) 11 | { 12 | } 13 | 14 | protected void CalculateButton_Click(object sender, EventArgs e) 15 | { 16 | Calculate(); 17 | } 18 | 19 | private void Calculate() 20 | { 21 | decimal futureValue; 22 | 23 | if (!decimal.TryParse(FutureValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out futureValue)) 24 | futureValue = 0; 25 | 26 | decimal rateOfReturn; 27 | 28 | if (!decimal.TryParse(RateOfReturnText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out rateOfReturn)) 29 | rateOfReturn = 0; 30 | 31 | int numberOfPeriods; 32 | 33 | if (!TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out numberOfPeriods)) 34 | numberOfPeriods = 0; 35 | 36 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 37 | 38 | try 39 | { 40 | var result = Mathos.Finance.Finance.AnnuityPaymentPresentValue( 41 | futureValue, 42 | rateOfReturn, 43 | numberOfPeriods, 44 | roundToTwoDecimalPlaces); 45 | 46 | ResultLabel.Text = string.Format( 47 | "Annuity Payment (Present Value): {0}", 48 | result.ToString(CultureInfo.CurrentCulture)); 49 | } 50 | catch 51 | { 52 | ErrorLabel.Text = "Error!"; 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Laboratory/Module/Uncertainty.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Uncertainty.aspx.cs" Inherits="Laboratory.Module.Uncertainty" %> 2 | 3 | 4 | 5 | 6 |
7 | Uncertainty Calculator 8 |
9 | 10 |

11 | This application allows you to work with uncertainty calcuations. Read the tutorial here. 12 |

13 | 14 |

15 | 1. Copy and paste the desired table in the text area below (for example from Microsoft Excel). Do not include the table headings! 16 | 17 |
18 |
19 | 20 | 21 | 22 |
23 |
24 | 25 | 2. Enter the operation you want to perform on the values in the table (for example "x^2"). 26 | 27 |
28 |
29 | 30 | 31 | 32 |
33 |
34 | 35 | 3. When you are ready, press the button! 36 |

37 | 38 |

39 | 41 |
42 |
43 | 44 | 45 |
46 | 47 |

48 | 49 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinancePresentValue.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinancePresentValue.aspx.cs" Inherits="Laboratory.Module.Finance.FinancePresentValue" %> 2 | 3 | 4 | 5 | 6 |
7 | Present Value 8 |
9 | 10 |

11 | This application allows you to calculate the present value of a future amount of money. Read the wiki here. 12 |

13 | 14 | 15 | 16 | 19 | 22 | 23 | 24 | 27 | 30 | 31 | 32 | 35 | 38 | 39 | 40 | 43 | 46 | 47 |
17 | Future value 18 | 20 | 21 |
25 | Rate of return (%) 26 | 28 | 29 |
33 | Number of periods 34 | 36 | 37 |
41 | Round to 2 decimal places 42 | 44 | 45 |
48 | 49 |

50 | 52 |
53 |
54 | 55 | 56 |

57 | 58 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceFutureValue.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceFutureValue.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceFutureValue" %> 2 | 3 | 4 | 5 | 6 |
7 | Future Value 8 |
9 | 10 |

11 | This application allows you to calculate the value of an asset at a specific date. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 |
18 | Present value 19 | 21 | 22 |
26 | Rate of return (%) 27 | 29 | 30 |
34 | Number of periods 35 | 37 | 38 |
42 | Round to 2 decimal places 43 | 45 | 46 |
49 | 50 |

51 | 53 | 54 |
55 |
56 | 57 |

58 | 59 |
-------------------------------------------------------------------------------- /Laboratory/Module/DataAnalysis/PolynomSeq.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module.DataAnalysis { 11 | 12 | 13 | public partial class WebForm1 { 14 | 15 | /// 16 | /// TextBox1 control. 17 | /// 18 | /// 19 | /// Auto-generated field. 20 | /// To modify move field declaration from designer file to code-behind file. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox TextBox1; 23 | 24 | /// 25 | /// Label1 control. 26 | /// 27 | /// 28 | /// Auto-generated field. 29 | /// To modify move field declaration from designer file to code-behind file. 30 | /// 31 | protected global::System.Web.UI.WebControls.Label Label1; 32 | 33 | /// 34 | /// FindNthTerm control. 35 | /// 36 | /// 37 | /// Auto-generated field. 38 | /// To modify move field declaration from designer file to code-behind file. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button FindNthTerm; 41 | 42 | /// 43 | /// Button1 control. 44 | /// 45 | /// 46 | /// Auto-generated field. 47 | /// To modify move field declaration from designer file to code-behind file. 48 | /// 49 | protected global::System.Web.UI.WebControls.Button Button1; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceFutureValueOfAnAnnuity.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Module.Finance 6 | { 7 | public partial class FinanceFutureValueOfAnAnnuity : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void CalculateButton_Click(object sender, EventArgs e) 14 | { 15 | Calculate(); 16 | } 17 | 18 | private void Calculate() 19 | { 20 | decimal periodicPayment; 21 | 22 | if ( 23 | !decimal.TryParse(PeriodicPaymentText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 24 | out periodicPayment)) 25 | periodicPayment = 0; 26 | 27 | decimal ratePerPeriod; 28 | 29 | if ( 30 | !decimal.TryParse(RatePerPeriodText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 31 | out ratePerPeriod)) 32 | ratePerPeriod = 0; 33 | 34 | int numberOfPeriods; 35 | 36 | if ( 37 | !int.TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 38 | out numberOfPeriods)) 39 | numberOfPeriods = 0; 40 | 41 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 42 | 43 | try 44 | { 45 | var result = Mathos.Finance.Finance.FutureValueOfAnnuity( 46 | periodicPayment, 47 | ratePerPeriod, 48 | numberOfPeriods, 49 | roundToTwoDecimalPlaces); 50 | 51 | ResultLabel.Text = string.Format( 52 | "Future Value Of An Annuity: {0}", 53 | result.ToString(CultureInfo.CurrentCulture)); 54 | } 55 | catch 56 | { 57 | ErrorLabel.Text = "Error!"; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinancePresentValueOfAnAnnuity.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Module.Finance 6 | { 7 | public partial class FinancePresentValueOfAnAnnuity : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void CalculateButton_Click(object sender, EventArgs e) 14 | { 15 | Calculate(); 16 | } 17 | 18 | private void Calculate() 19 | { 20 | decimal periodicPayment; 21 | 22 | if ( 23 | !decimal.TryParse(PeriodicPaymentText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 24 | out periodicPayment)) 25 | periodicPayment = 0; 26 | 27 | decimal ratePerPeriod; 28 | 29 | if ( 30 | !decimal.TryParse(RatePerPeriodText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 31 | out ratePerPeriod)) 32 | ratePerPeriod = 0; 33 | 34 | int numberOfPeriods; 35 | 36 | if ( 37 | !int.TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 38 | out numberOfPeriods)) 39 | numberOfPeriods = 0; 40 | 41 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 42 | 43 | try 44 | { 45 | var result = Mathos.Finance.Finance.PresentValueOfAnnuity( 46 | periodicPayment, 47 | ratePerPeriod, 48 | numberOfPeriods, 49 | roundToTwoDecimalPlaces); 50 | 51 | ResultLabel.Text = string.Format( 52 | "Present Value Of An Annuity: {0}", 53 | result.ToString(CultureInfo.CurrentCulture)); 54 | } 55 | catch 56 | { 57 | ErrorLabel.Text = "Error!"; 58 | } 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Laboratory/Module/Triangle.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Triangle.aspx.cs" Inherits="Laboratory.Module.Triangle" %> 2 | 3 | 4 | 5 | 6 |
7 | Triangle Solver 8 |
9 | 10 |

11 | Please provide any information about the triangle: 12 | 500px-Triangle_with_notations_2.svg 15 |

16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 45 | 48 | 49 |
abc
25 | 26 | 28 | 29 | 31 | 32 |
ABC
41 | 43 | 44 | 46 | 47 |
50 | 51 |

52 | 54 |
55 |
56 | 57 |
58 | 59 |

60 | 61 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceFutureValueOfAnAnnuity.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceFutureValueOfAnAnnuity.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceFutureValueOfAnAnnuity" %> 2 | 3 | 4 | 5 | 6 |
7 | Future Value Of An Annuity 8 |
9 | 10 |

11 | This application allows you to calculate the value of a group of payments at a specified date in the future. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 |
18 | Periodic payment 19 | 21 | 22 |
26 | Rate per period (%) 27 | 29 | 30 |
34 | Number of periods 35 | 37 | 38 |
42 | Round to 2 decimal places 43 | 45 | 46 |
49 | 50 |

51 | 53 | 54 |
55 |
56 | 57 |

58 | 59 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinancePresentValueOfAnAnnuity.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinancePresentValueOfAnAnnuity.aspx.cs" Inherits="Laboratory.Module.Finance.FinancePresentValueOfAnAnnuity" %> 2 | 3 | 4 | 5 | 6 |
7 | Present Value Of An Annuity 8 |
9 | 10 |

11 | This application allows you to calculate the current value of a set of cash flows in the future, given a specified rate of return or discount rate. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 |
18 | Periodic payment 19 | 21 | 22 |
26 | Rate per period (%) 27 | 29 | 30 |
34 | Number of periods 35 | 37 | 38 |
42 | Round to 2 decimal places 43 | 45 | 46 |
49 | 50 |

51 | 53 |
54 |
55 | 56 | 57 |

58 |
-------------------------------------------------------------------------------- /Mathos/Geometry/Shapes/Torus.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Geometry.Shapes 4 | { 5 | /// 6 | /// A torus. 7 | /// 8 | public class Torus : IShape3D 9 | { 10 | private double _distance; 11 | private double _tubeRadius; 12 | 13 | /// 14 | /// Default constructor. 15 | /// 16 | public Torus() : this(0, 0) 17 | { 18 | } 19 | 20 | /// 21 | /// Constructor with a and . 22 | /// 23 | /// The distance. 24 | /// The tube radius. 25 | public Torus(double distance, double tubeRadius) 26 | { 27 | _distance = distance < 0 ? 0 : distance; 28 | _tubeRadius = tubeRadius < 0 ? 0 : tubeRadius; 29 | } 30 | 31 | /// 32 | /// Gets or sets the radius of the tube and distance. 33 | /// 34 | public double Distance 35 | { 36 | get { return _distance; } 37 | set { _distance = value < 0 ? 0 : value; } 38 | } 39 | 40 | /// 41 | /// Gets or sets the tube radius. 42 | /// 43 | public double TubeRadius 44 | { 45 | get { return _tubeRadius; } 46 | set { _tubeRadius = value < 0 ? 0 : value; } 47 | } 48 | 49 | /// 50 | /// Gets the area of the circle. 51 | /// 52 | public double SurfaceArea 53 | { 54 | get { return 4* _distance * _tubeRadius * Math.Pow(Math.PI,2); } 55 | } 56 | 57 | /// 58 | /// Gets the circumference of the circle. 59 | /// 60 | public double Volume 61 | { 62 | get { return 2 * _distance * Math.Pow( Math.PI * _tubeRadius ,2); } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceAnnuityPaymentFutureValue.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceAnnuityPaymentFutureValue.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceAnnuityPaymentFutureValue" %> 2 | 3 | 4 | 5 | 6 |
7 | Annuity Payment (Future Value) 8 |
9 | 10 |

11 | This application allows you to calculate the cash flows of an annuity when future value is known. An annuity is denoted as a series of periodic payments. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 |
18 | Future value 19 | 21 | 22 |
26 | Rate of return (%) 27 | 29 | 30 |
34 | Number of periods 35 | 37 | 38 |
42 | Round to 2 decimal places 43 | 45 | 46 |
49 | 50 |

51 | 53 |
54 |
55 | 56 | 57 |

58 | 59 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceAnnuityPaymentPresentValue.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceAnnuityPaymentPresentValue.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceAnnuityPaymentPresentValue" %> 2 | 3 | 4 | 5 | 6 |
7 | Annuity Payment (Present Value) 8 |
9 | 10 |

11 | This application allows you to calculate the periodic payment on an annuity. An annuity is a series of periodic payments that are received at a future date. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 |
18 | Future value 19 | 21 | 22 |
26 | Rate of return (%) 27 | 29 | 30 |
34 | Number of periods 35 | 37 | 38 |
42 | Round to 2 decimal places 43 | 45 | 46 |
49 | 50 |

51 | 53 |
54 |
55 | 56 | 57 |

58 | 59 |
-------------------------------------------------------------------------------- /Mathos/PreCalculus/ArithmeticSequence.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.PreCalculus 2 | { 3 | /// 4 | /// Represents an arithmetic sequence. 5 | /// 6 | public class ArithmeticSequence 7 | { 8 | /// 9 | /// Initializes a sequence with both an initial term and a common difference of 0. 10 | /// 11 | public ArithmeticSequence() : this(0, 0) 12 | { 13 | } 14 | 15 | /// 16 | /// Initializes a sequence with an and a . 17 | /// 18 | /// The initial term. 19 | /// The common difference. 20 | public ArithmeticSequence(double initialTerm, double commonDifference) 21 | { 22 | InitialTerm = initialTerm; 23 | CommonDifference = commonDifference; 24 | } 25 | 26 | /// 27 | /// Gets or sets the initial term. 28 | /// 29 | public double InitialTerm { get; set; } 30 | 31 | /// 32 | /// Gets or sets the common difference. 33 | /// 34 | public double CommonDifference { get; set; } 35 | 36 | /// 37 | /// Gets the -th term in the sequence. 38 | /// 39 | /// The term to get. 40 | /// The -th term in the sequence. 41 | public double NTerm(int n) 42 | { 43 | return InitialTerm + (n - 1) * CommonDifference; 44 | } 45 | 46 | /// 47 | /// Gets the sum of terms. 48 | /// 49 | /// The number of terms. 50 | /// The sum of terms. 51 | public double Sum(int n) 52 | { 53 | var tmpLeft = (double) n/2; 54 | 55 | return tmpLeft * (2 * InitialTerm + (n - 1) * CommonDifference); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceRemainingBalanceOfAnnuity.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Web.UI; 4 | 5 | namespace Laboratory.Module.Finance 6 | { 7 | public partial class FinanceRemainingBalanceOfAnnuity : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void CalculateButton_Click(object sender, EventArgs e) 14 | { 15 | Calculate(); 16 | } 17 | 18 | private void Calculate() 19 | { 20 | decimal originalValue; 21 | 22 | if ( 23 | !decimal.TryParse(OriginalValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 24 | out originalValue)) 25 | originalValue = 0; 26 | 27 | decimal payment; 28 | 29 | if (!decimal.TryParse(PaymentText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out payment)) 30 | payment = 0; 31 | 32 | decimal ratePerPeriod; 33 | 34 | if ( 35 | !decimal.TryParse(RatePerPeriodText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 36 | out ratePerPeriod)) 37 | ratePerPeriod = 0; 38 | 39 | int numberOfPeriods; 40 | 41 | if ( 42 | !int.TryParse(NumberOfPeriodsText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 43 | out numberOfPeriods)) 44 | numberOfPeriods = 0; 45 | 46 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 47 | 48 | try 49 | { 50 | var result = Mathos.Finance.Finance.RemainingBalanceOfAnnuity( 51 | originalValue, 52 | payment, 53 | ratePerPeriod, 54 | numberOfPeriods, 55 | roundToTwoDecimalPlaces); 56 | 57 | ResultLabel.Text = string.Format( 58 | "Remaining balance of annuity: {0}", 59 | result.ToString(CultureInfo.CurrentCulture)); 60 | } 61 | catch 62 | { 63 | ErrorLabel.Text = "Error!"; 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Laboratory/Web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceNetPresentValue.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Web.UI; 5 | 6 | namespace Laboratory.Module.Finance 7 | { 8 | public partial class FinanceNetPresentValue : Page 9 | { 10 | protected void Page_Load(object sender, EventArgs e) 11 | { 12 | } 13 | 14 | protected void CalculateButton_Click(object sender, EventArgs e) 15 | { 16 | Calculate(); 17 | } 18 | 19 | private void Calculate() 20 | { 21 | decimal initialInvestmentValue; 22 | 23 | if ( 24 | !decimal.TryParse(InitialInvestmentValueText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, 25 | out initialInvestmentValue)) 26 | initialInvestmentValue = 0; 27 | 28 | var cashFlow = new List(); 29 | var values = CashFlowValueText.Text.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); 30 | 31 | foreach (var value in values) 32 | { 33 | decimal cashFlowItem; 34 | 35 | if (!decimal.TryParse(value, NumberStyles.Any, CultureInfo.CurrentCulture, out cashFlowItem)) 36 | cashFlowItem = 0; 37 | 38 | cashFlow.Add(cashFlowItem); 39 | } 40 | 41 | decimal rateOfReturn; 42 | 43 | if (!decimal.TryParse(RateOfReturnText.Text, NumberStyles.Any, CultureInfo.CurrentCulture, out rateOfReturn)) 44 | rateOfReturn = 0; 45 | 46 | var roundToTwoDecimalPlaces = RoundCheck.Checked; 47 | 48 | try 49 | { 50 | var result = Mathos.Finance.Finance.NetPresentValue( 51 | initialInvestmentValue, 52 | cashFlow, 53 | rateOfReturn, 54 | roundToTwoDecimalPlaces); 55 | 56 | ResultLabel.Text = string.Format( 57 | "Net Present value: {0}", 58 | result.ToString(CultureInfo.CurrentCulture)); 59 | } 60 | catch 61 | { 62 | ErrorLabel.Text = "Error!"; 63 | } 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceRemainingBalanceOfAnnuity.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceRemainingBalanceOfAnnuity.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceRemainingBalanceOfAnnuity" %> 2 | 3 | 4 | 5 | 6 |
7 | Remaining Balance Of Annuity 8 |
9 | 10 |

11 | This application allows you to calculate the remaining balance at a given time(time n), whether at a future date or at present. 12 | Read the wiki here. 13 |

14 | 15 | 16 | 17 | 20 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | 36 | 39 | 40 | 41 | 44 | 47 | 48 | 49 | 52 | 55 | 56 |
18 | Original value 19 | 21 | 22 |
26 | Payment 27 | 29 | 30 |
34 | Rate per period (%) 35 | 37 | 38 |
42 | Number of periods 43 | 45 | 46 |
50 | Round to 2 decimal places 51 | 53 | 54 |
57 | 58 |

59 | 61 |
62 |
63 | 64 | 65 |

66 | 67 |
-------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceNetPresentValue.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="FinanceNetPresentValue.aspx.cs" Inherits="Laboratory.Module.Finance.FinanceNetPresentValue" %> 2 | 3 | 6 | 7 | 8 | 9 |
10 | Net Present Value 11 |
12 | 13 |

14 | This application allows you to calculate the sum of the present values (PVs) of the individual cash flows of the same entity. 15 | Read the wiki here. 16 |

17 | 18 | 19 | 20 | 23 | 26 | 27 | 28 | 31 | 36 | 37 | 38 | 41 | 44 | 45 | 46 | 49 | 52 | 53 |
21 | Initial invenstment 22 | 24 | 25 |
29 | Cash flow 30 | 32 | 33 |   34 | Insert values separated by space (ex 200 100 300) 35 |
39 | Rate of return (%) 40 | 42 | 43 |
47 | Round to 2 decimal places 48 | 50 | 51 |
54 | 55 |

56 | 58 |
59 |
60 | 61 | 62 |

63 | 64 |
-------------------------------------------------------------------------------- /Mathos/Calculus/Elementary.Complex.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | 4 | namespace Mathos.Calculus 5 | { 6 | // Missing functions in Math class 7 | // functions of real variable 8 | /// 9 | /// 10 | /// 11 | public static partial class Elementary 12 | { 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | public static Complex Coth(Complex z) 19 | { 20 | return Complex.Reciprocal(Complex.Tanh(z)); 21 | } 22 | 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public static Complex Cot(Complex z) 29 | { 30 | return Complex.Reciprocal(Complex.Tan(z)); 31 | } 32 | 33 | /// 34 | /// 35 | /// 36 | /// 37 | /// 38 | public static Complex Log(Complex number) 39 | { 40 | throw new NotImplementedException(); 41 | } 42 | 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | public static Complex Exp(Complex number) 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | 53 | // other functions 54 | 55 | /// 56 | /// 57 | /// 58 | /// 59 | /// 60 | public static double LogOfAbs(Complex number) 61 | { 62 | var y = Math.Abs(number.Imaginary); 63 | var x = Math.Abs(number.Real); 64 | var max = x; 65 | 66 | double u; 67 | 68 | if (x >= y) 69 | u = y/x; 70 | else 71 | { 72 | max = y; 73 | u = x/y; 74 | } 75 | 76 | return Math.Log(max) + 0.5 * LogOfOnePlusX(u * u); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Laboratory/Module/DataAnalysis/LinearRegression.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="LinearRegression.aspx.cs" Inherits="Laboratory.Module.DataAnalysis.LinearRegression" %> 2 | 3 | 4 | 5 | 6 |
Linear Regression 7 |
8 |

9 | This application allows you to find a linear relationship between y values and x values.

10 | 11 |

Enter the x values
12 | Enter the sequence below. Separate each term by a comma. For example, enter 1,2,3,4,5.

13 | 14 | 15 | 16 |

Enter the y values
17 | Enter the sequence below. Separate each term by a comma. For example, enter 1,2,3,4,5.

18 | 19 |
20 | 21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
Linear equation
R value
R squared value
Regression coefficient (β)
Intercept
51 | 52 |
53 | -------------------------------------------------------------------------------- /Laboratory/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 2 | CodeBehind="Default.aspx.cs" Inherits="Laboratory.Default" %> 3 | 4 | 5 | 6 |
7 | Welcome to Mathos Laboratory 8 |
9 | 10 |

11 | At this page you might try out almost all of the great features built into the 12 | Mathos Core library online! 13 |

14 | 15 |

16 | Please navigate to 17 | Modules 18 | , to see the new amazing features. 19 |

20 | 21 |

22 | Mathos is an open source project, which consists of a core library with many 23 | great features to facilitate mathematical calculations. It can be downloaded 24 | here. 25 |

26 | 27 |

28 | Would you like to contribute? Great! Please navigate to our contribution page here! 29 |

30 | 31 | 45 | 46 | 47 |

 

48 |
-------------------------------------------------------------------------------- /Mathos/Arithmetic/PhysicalConstants.cs: -------------------------------------------------------------------------------- 1 | namespace Mathos.Arithmetic 2 | { 3 | /// 4 | /// 5 | /// 6 | public static class PhysicalConstants 7 | { 8 | /// 9 | /// International System of Units 10 | /// 11 | public static class SI 12 | { 13 | /// 14 | /// The speed of light. 15 | /// 299792458 m/s 16 | /// 17 | public const double C = 2.99792458e8; 18 | 19 | /// 20 | /// The Newton constant. 21 | /// 6.67408 * 10^-11 m^3 kg^-1 s^-2 22 | /// 23 | public const double NewtonConstant = 6.67408e-11; 24 | 25 | /// 26 | /// The Planck constant (h). 27 | /// 6.62607004 * 10^-34 m^2 kg/s 28 | /// 29 | public const double PlanckConstant = 6.62607004e-34; 30 | 31 | /// 32 | /// The h-bar. 33 | /// 1.0545718 * 10^-34 m^2 kg/s 34 | /// 35 | public const double PlankConstantBar = 1.0545718e-34; 36 | 37 | /// 38 | /// The acceleration of gravity. 39 | /// 9.80665 m/s^2 40 | /// 41 | public const double GravityAccelartion = 9.80665e0; 42 | 43 | /// 44 | /// The electron volt (eV). 45 | /// 1.602176565(35) * 10^−19 J 46 | /// 47 | public const double ElectronVolt = 1.602176462e-19; 48 | 49 | /// 50 | /// The electron mass. 51 | /// 9.10938356 * 10^-31 kilograms 52 | /// 53 | public const double ElectronMass = 9.10938356e-31; 54 | 55 | /// 56 | /// The Boltzmann constant (kB or k). 57 | /// 1.38064852 * 10^-23 m^2 kg s^-2 K^-1 58 | /// 59 | public const double BoltzmannConstant = 1.38064852e-23; 60 | } 61 | 62 | /// 63 | /// Avogadro's number. 64 | /// 6.02214199 * 10^23 65 | /// 66 | public const double Avogadro = 6.02214199e23; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Laboratory/Module/Converter.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Converter.aspx.cs" Inherits="Laboratory.Module.Converter" %> 2 | 3 | 4 | 5 | 6 |
7 | Converter [under dev] 8 |
9 | 10 |

11 | 14 | Length 15 | Speed 16 | Mass 17 | Area 18 | Volume 19 | Base 20 | Angle 21 | Power 22 | Pressure 23 | Temperature 24 | 25 | 26 | Please provide what you would like to convert (length, speed, mass, area, volume, base, angle, power, pressure, temperature)

27 |
28 | 29 | 31 | Please select a unit 32 | 33 | 34 |
35 |
36 | 38 | Please select a unit 39 | 40 | 41 |
42 |
43 | 44 |

45 | 47 |
48 |
49 | 50 |
51 | 52 |

53 |
54 |
-------------------------------------------------------------------------------- /MathosTest/Finance.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | using Mathos.Finance; 5 | 6 | namespace MathosTest 7 | { 8 | [TestClass] 9 | public class FinanceTest 10 | { 11 | [TestMethod] 12 | public void FutureValue() 13 | { 14 | // $1,000 at 0.5% over 12 periods 15 | var futureValue = Finance.FutureValue(1000M, 0.5M, 12); 16 | 17 | Assert.AreEqual(1061.68M, futureValue); 18 | } 19 | 20 | [TestMethod] 21 | public void PresentValue() 22 | { 23 | // $,1061.68 at 0.5% over 12 periods 24 | var futureValue = Finance.PresentValue(1061.68M, 0.5M, 12); 25 | 26 | Assert.AreEqual(1000, futureValue); 27 | } 28 | 29 | [TestMethod] 30 | public void NetPresentValue() 31 | { 32 | var cashFlow = new List {200000, 300000, 200000}; 33 | var netPresentValue = Finance.NetPresentValue(500000, cashFlow, 10); 34 | 35 | Assert.AreEqual(80015.02M, netPresentValue); 36 | } 37 | 38 | [TestMethod] 39 | public void PresentValueOfAnnuity() 40 | { 41 | var presentValueOfAnnuity = Finance.PresentValueOfAnnuity(200, 1, 12); 42 | 43 | Assert.AreEqual(2251.02M, presentValueOfAnnuity); 44 | } 45 | 46 | [TestMethod] 47 | public void FutureValueOfAnnuity() 48 | { 49 | var futureValueOfAnnuity = Finance.FutureValueOfAnnuity(200, 1, 12); 50 | 51 | Assert.AreEqual(2536.50M, futureValueOfAnnuity); 52 | } 53 | 54 | [TestMethod] 55 | public void AnnuityPaymentPresentValue() 56 | { 57 | var annuityPayment = Finance.AnnuityPaymentPresentValue(1000, 1, 12); 58 | 59 | Assert.AreEqual(88.85M, annuityPayment); 60 | } 61 | 62 | [TestMethod] 63 | public void AnnuityPaymentFutureValue() 64 | { 65 | var annuityPayment = Finance.AnnuityPaymentFutureValue(5000, 3, 5); 66 | 67 | Assert.AreEqual(941.77M, annuityPayment); 68 | } 69 | 70 | [TestMethod] 71 | public void RemainingBalanceOfAnnuity() 72 | { 73 | var remaining = Finance.RemainingBalanceOfAnnuity(5000, 200, 3, 15); 74 | 75 | Assert.AreEqual(4070.05M, remaining); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Interactive Mathematics/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Windows; 4 | 5 | // Управление общими сведениями о сборке осуществляется с помощью 6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения, 7 | // связанные со сборкой. 8 | [assembly: AssemblyTitle("Interactive Mathematics")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Artem Los")] 12 | [assembly: AssemblyProduct("Interactive Mathematics")] 13 | [assembly: AssemblyCopyright("Copyright © 2012-2016 Mathos Project")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми 18 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через 19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа. 20 | [assembly: ComVisible(false)] 21 | 22 | //Чтобы начать построение локализованных приложений, задайте 23 | //CultureYouAreCodingWith в файле .csproj 24 | //внутри . Например, если используется английский США 25 | //в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий 26 | //атрибута NeutralResourceLanguage ниже. Обновите "en-US" в 27 | //строка внизу для обеспечения соответствия настройки UICulture в файле проекта. 28 | 29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 30 | 31 | 32 | [assembly: ThemeInfo( 33 | ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам 34 | //(используется, если ресурс не найден на странице 35 | // или в словарях ресурсов приложения) 36 | ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов 37 | //(используется, если ресурс не найден на странице, 38 | // в приложении или в каких-либо словарях ресурсов для конкретной темы) 39 | )] 40 | 41 | 42 | // Сведения о версии сборки состоят из следующих четырех значений: 43 | // 44 | // Основной номер версии 45 | // Дополнительный номер версии 46 | // Номер построения 47 | // Редакция 48 | // 49 | // Можно задать все значения или принять номер построения и номер редакции по умолчанию, 50 | // используя "*", как показано ниже: 51 | // [assembly: AssemblyVersion("1.0.*")] 52 | [assembly: AssemblyVersion("1.0.0.0")] 53 | [assembly: AssemblyFileVersion("1.0.0.0")] 54 | -------------------------------------------------------------------------------- /Laboratory/Module/Factorial.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module { 11 | 12 | 13 | public partial class Factorial { 14 | 15 | /// 16 | /// Controllo NumberText. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox NumberText; 23 | 24 | /// 25 | /// Controllo CalculateButton. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.Button CalculateButton; 32 | 33 | /// 34 | /// Controllo ErrorLabel. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 41 | 42 | /// 43 | /// Controllo ResultTextbox. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.TextBox ResultTextbox; 50 | 51 | /// 52 | /// Controllo ElapsedTimeLabel. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Label ElapsedTimeLabel; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /MathosTest/SetTest.cs: -------------------------------------------------------------------------------- 1 | using Mathos; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace MathosTest 5 | { 6 | [TestClass] 7 | public class SetTest 8 | { 9 | [TestMethod] 10 | public void AddRemoveElements() 11 | { 12 | var set = new Set(2, 4, 6, 8, 10); 13 | 14 | Assert.AreEqual("{2,4,6,8,10}", set.ToString()); 15 | 16 | set.Add(1, 3, 5, 7, 9); 17 | 18 | Assert.AreEqual("{2,4,6,8,10,1,3,5,7,9}", set.ToString()); 19 | 20 | set.Remove(9); 21 | 22 | Assert.AreEqual("{2,4,6,8,10,1,3,5,7}", set.ToString()); 23 | } 24 | 25 | [TestMethod] 26 | public void AddSets() 27 | { 28 | var a = new Set(1, 2, 3, 4, 5); 29 | var b = new Set(1, 2, 3, 4, 6); 30 | 31 | a.Add(b); 32 | 33 | Assert.AreEqual(new Set(1, 2, 3, 4, 5, 6), a); 34 | } 35 | 36 | [TestMethod] 37 | public void UnionTest() 38 | { 39 | var a = new Set(1, 2, 3); 40 | var b = new Set(2, 3, 4); 41 | 42 | Assert.AreEqual("{1,2,3,4}", a.Union(b).ToString()); 43 | } 44 | 45 | [TestMethod] 46 | public void IntersectionTest() 47 | { 48 | var a = new Set(1, 2, 3); 49 | var b = new Set(2, 3, 4); 50 | 51 | Assert.AreEqual("{2,3}", a.Intersection(b).ToString()); 52 | } 53 | 54 | [TestMethod] 55 | public void DifferenceTest() 56 | { 57 | var a = new Set(1, 2, 3); 58 | var b = new Set(2, 3, 4); 59 | 60 | Assert.AreEqual("{1}", a.Difference(b).ToString()); 61 | Assert.AreEqual("{4}", b.Difference(a).ToString()); 62 | } 63 | 64 | [TestMethod] 65 | public void SymmetricTest() 66 | { 67 | var a = new Set(1, 2, 3); 68 | var b = new Set(3, 4); 69 | 70 | Assert.AreEqual("{1,2,4}", a.Symmetric(b).ToString()); 71 | } 72 | 73 | [TestMethod] 74 | public void SubsetTest() 75 | { 76 | var a = new Set(1, 2, 3); 77 | var b = new Set(1, 2, 3); 78 | var c = new Set(1, 2, 3, 4); 79 | 80 | Assert.IsTrue(a.IsSubset(b)); 81 | Assert.IsTrue(a.IsSubset(c)); 82 | 83 | Assert.IsFalse(a.IsProperSubset(b)); 84 | Assert.IsTrue(a.IsProperSubset(c)); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /ProjectWebsite/Default.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ProjectWebsite.Default" EnableEventValidation="false" %> 2 | 3 | 4 | 5 | 6 | 7 | Mathos Parser 8 | 23 | 32 | 33 | 34 | 35 | 36 |
37 |

38 | Mathos Parser 39 |

40 | 43 | 44 |
45 |
46 |
47 |
48 | 49 |
Copyright © 2012-2013 Artem Los
50 | 51 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /MathosTest/SpecialFunctions/GammaTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Mathos.Arithmetic.Numbers; 5 | using Mathos.SpecialFunctions; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | 8 | namespace MathosTest.Mathos_Main.SpecialFunctions 9 | { 10 | [TestClass] 11 | public class GammaTests 12 | { 13 | const double EPS = 1e-7; 14 | private bool AreApproximatelyEqual(double d1, double d2) 15 | { 16 | return Math.Abs(d1 - d2) < EPS; 17 | } 18 | 19 | private bool IsApproximatelyZero(double d) 20 | { 21 | return Math.Abs(d) < EPS; 22 | } 23 | [TestMethod] 24 | public void Test_Gamma_Of_Valid_Values() 25 | { 26 | Dictionary expected = new Dictionary { 27 | {1,1}, 28 | {Math.PI, 2.288037796}, 29 | {Math.E, 1.567468255}, 30 | {-1.5,2.363271801} 31 | }; 32 | 33 | //foreach (var item in expected) 34 | //{ 35 | // double actual = GammaRelated.Gamma(item.Key); 36 | // Assert.IsTrue(AreApproximatelyEqual(item.Value, actual)); 37 | //} 38 | 39 | Assert.IsTrue( 40 | expected.All(x => 41 | AreApproximatelyEqual(x.Value, GammaRelated.Gamma(x.Key)) 42 | ) 43 | ); 44 | 45 | Assert.IsTrue( 46 | AreApproximatelyEqual( 47 | GammaRelated.Gamma(Math.PI + 1), 48 | Math.PI * GammaRelated.Gamma(Math.PI) 49 | ) 50 | ); 51 | } 52 | [TestMethod] 53 | [ExpectedException(typeof(ArgumentOutOfRangeException))] 54 | public void Test_Invalid_Values() 55 | { 56 | GammaRelated.LogOfFactorial(-1); 57 | } 58 | 59 | [TestMethod] 60 | public void Test_Log_Of_Factorial() 61 | { 62 | Dictionary factorials = new Dictionary(); 63 | for (int i = 0; i < 20; i++) 64 | { 65 | factorials.Add(i, 66 | Get.Factorial(i)); 67 | } 68 | 69 | Assert.IsTrue( 70 | factorials.All(x => 71 | AreApproximatelyEqual( 72 | Math.Log(x.Value), 73 | GammaRelated.LogOfFactorial(x.Key)) 74 | ) 75 | ); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Mathos/PreCalculus/GeometricSequence.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.PreCalculus 4 | { 5 | /// 6 | /// Represents a geometric sequence. 7 | /// 8 | public class GeometricSequence 9 | { 10 | /// 11 | /// Initializes a sequence with both an initial term and a common ratio of 1. 12 | /// 13 | public GeometricSequence() : this(1, 1) 14 | { 15 | } 16 | 17 | /// 18 | /// Initializes a sequence with an and a . 19 | /// 20 | /// The initial term. 21 | /// The common ratio. 22 | public GeometricSequence(double initialTerm, double commonRatio) 23 | { 24 | if ((Math.Abs(initialTerm) > 0) && (Math.Abs(commonRatio) > 0)) 25 | { 26 | InitialTerm = initialTerm; 27 | CommonRatio = commonRatio; 28 | } 29 | else 30 | throw new ArgumentException("The initial term nor common ratio can be 0."); 31 | } 32 | 33 | /// 34 | /// Gets or sets the initial term. 35 | /// 36 | public double InitialTerm { get; set; } 37 | 38 | /// 39 | /// Gets or sets the common ratio. 40 | /// 41 | public double CommonRatio { get; set; } 42 | 43 | /// 44 | /// Gets the -th term in the sequence. 45 | /// 46 | /// The term to get. 47 | /// The -th term in the sequence. 48 | public double NTerm(int n) 49 | { 50 | return InitialTerm * Math.Pow(CommonRatio, n); 51 | } 52 | 53 | /// 54 | /// Gets the sum of terms. 55 | /// 56 | /// The number of terms. 57 | /// The sum of terms. 58 | public double Sum(int n) 59 | { 60 | return InitialTerm * (1 - Math.Pow(CommonRatio, n + 1)) / (1 - CommonRatio); 61 | } 62 | 63 | /// 64 | /// Gets the infinite sum of the sequence. 65 | /// 66 | /// The infinite sum of the sequence. 67 | public double InfiniteSum() 68 | { 69 | if (Math.Abs(CommonRatio) < 1) 70 | return InitialTerm / (1 - CommonRatio); 71 | 72 | throw new ArgumentException("THe common ratio must be between -1 and 1."); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Laboratory/Module/DataAnalysis/PolynomSeq.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Web.UI; 3 | using Mathos.Calculus; 4 | 5 | namespace Laboratory.Module.DataAnalysis 6 | { 7 | public partial class WebForm1 : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void FindNthTerm_Click(object sender, EventArgs e) 14 | { 15 | if (TextBox1.Text != "") 16 | { 17 | var tokens = TextBox1.Text.Split(','); 18 | 19 | double[] seq; 20 | try 21 | { 22 | seq = Array.ConvertAll(tokens, double.Parse); 23 | } 24 | catch 25 | { 26 | Label1.Text = "Could not convert the sequence into an array."; 27 | 28 | return; 29 | } 30 | 31 | int degree; 32 | 33 | if (FiniteCalculus.HasPattern(seq, out degree)) 34 | { 35 | var coeff = FiniteCalculus.GetCoefficientsForNthTerm(seq, degree); 36 | var output = FiniteCalculus.GetExpressionForNthTerm(coeff); 37 | 38 | Label1.Text = output; 39 | } 40 | else 41 | { 42 | Label1.Text = "Not enough terms to spot a pattern or not a polynomial sequence."; 43 | } 44 | } 45 | else 46 | { 47 | Label1.Text = "No sequence was entered."; 48 | } 49 | } 50 | 51 | protected void Button1_Click(object sender, EventArgs e) 52 | { 53 | if (TextBox1.Text != "") 54 | { 55 | var tokens = TextBox1.Text.Split(','); 56 | 57 | double[] seq; 58 | try 59 | { 60 | seq = Array.ConvertAll(tokens, double.Parse); 61 | } 62 | catch 63 | { 64 | Label1.Text = "Could not convert the sequence into an array."; 65 | 66 | return; 67 | } 68 | 69 | int degree; 70 | 71 | if (FiniteCalculus.HasPattern(seq, out degree)) 72 | { 73 | var coeff = FiniteCalculus.GetCoefficientsForNthSum(seq, degree); 74 | var output = FiniteCalculus.GetExpressionForNthSum(coeff); 75 | 76 | Label1.Text = output; 77 | } 78 | else 79 | { 80 | Label1.Text = "Not enough terms to spot a pattern or not a polynomial sequence."; 81 | } 82 | } 83 | else 84 | { 85 | Label1.Text = "No sequence was entered."; 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /Mathos/Geometry/Shapes/Ring.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Geometry.Shapes 4 | { 5 | /// 6 | /// A ring shape. 7 | /// 8 | public class Ring : IShape2D 9 | { 10 | private double _bigRadius; 11 | private double _smallRadius; 12 | 13 | /// 14 | /// Default constructor. 15 | /// 16 | public Ring() : this(0, 0) 17 | { 18 | } 19 | 20 | /// 21 | /// Constructor with and . 22 | /// 23 | /// The big radius. 24 | /// The small radius. 25 | public Ring(double bigRadius, double smallRadius) 26 | { 27 | _bigRadius = bigRadius < 0 ? 0 : bigRadius; 28 | _smallRadius = smallRadius < 0 ? 0 : smallRadius; 29 | } 30 | 31 | /// 32 | /// Gets or sets the big radius. 33 | /// 34 | public double BigRadius 35 | { 36 | get { return _bigRadius; } 37 | set { _bigRadius = value < 0 ? 0 : value; } 38 | } 39 | 40 | /// 41 | /// Gets or sets the small radius. 42 | /// 43 | public double SmallRadius 44 | { 45 | get { return _smallRadius; } 46 | set { _smallRadius = value < 0 ? 0 : value; } 47 | } 48 | 49 | /// 50 | /// Gets or sets the big diameter. 51 | /// 52 | public double BigDiameter 53 | { 54 | get { return _bigRadius * 2; } 55 | set { _bigRadius = value < 0 ? 0 : value / 2; } 56 | } 57 | 58 | /// 59 | /// Gets or sets the small diameter. 60 | /// 61 | public double SmallDiameter 62 | { 63 | get { return _smallRadius * 2; } 64 | set { _smallRadius = value < 0 ? 0 : value / 2; } 65 | } 66 | 67 | /// 68 | /// Gets the area of the ring. 69 | /// 70 | public double Area 71 | { 72 | get { return (_bigRadius * _bigRadius -_smallRadius * _smallRadius ) * Math.PI; } 73 | } 74 | 75 | /// 76 | /// Gets the circumference of the ring. 77 | /// 78 | public double Circumference 79 | { 80 | get { return 2 * Math.PI * (_bigRadius + _smallRadius); } 81 | } 82 | 83 | /// 84 | /// Gets the perimeter of the ring. 85 | /// 86 | public double Perimeter 87 | { 88 | get { return Circumference; } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Mathos/Geometry/Trigonometry.cs: -------------------------------------------------------------------------------- 1 | using Mathos.Geometry.Shapes; 2 | 3 | namespace Mathos.Geometry 4 | { 5 | /// 6 | /// A 7 | /// |\ 8 | /// SideA | \ SideC 9 | /// | \ 10 | /// B----- C 11 | /// SideB 12 | /// 13 | public static class Trigonometry 14 | { 15 | /// 16 | /// Angles of a triangle. 17 | /// 18 | public enum TriangleAngle 19 | { 20 | /// 21 | /// Angle A (Top) 22 | /// 23 | A, 24 | /// 25 | /// Angle C (Corner) 26 | /// 27 | C 28 | } 29 | 30 | /// 31 | /// Calculates the sine of in . 32 | /// 33 | /// The triangle 34 | /// The angle to calculate. 35 | /// The sine of . 36 | public static double Sine(Triangle tri, TriangleAngle angle = TriangleAngle.C) 37 | { 38 | switch (angle) 39 | { 40 | case TriangleAngle.A: 41 | return tri.SideB/tri.SideC; 42 | default: 43 | return tri.AngleA/tri.SideC; 44 | } 45 | } 46 | 47 | /// 48 | /// Calculates the cosine of in . 49 | /// 50 | /// The triangle 51 | /// The angle to calculate. 52 | /// The cosine of . 53 | public static double Cosine(Triangle tri, TriangleAngle angle = TriangleAngle.C) 54 | { 55 | switch (angle) 56 | { 57 | case TriangleAngle.A: 58 | return tri.SideA / tri.SideC; 59 | default: 60 | return tri.AngleB / tri.SideC; 61 | } 62 | } 63 | 64 | /// 65 | /// Calculates the tangent of in . 66 | /// 67 | /// The triangle 68 | /// The angle to calculate. 69 | /// The tangent of . 70 | public static double Tangent(Triangle tri, TriangleAngle angle = TriangleAngle.C) 71 | { 72 | switch (angle) 73 | { 74 | case TriangleAngle.A: 75 | return tri.SideB / tri.SideA; 76 | default: 77 | return tri.AngleA / tri.SideB; 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Laboratory/Account/Login.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 2 | CodeBehind="Login.aspx.cs" Inherits="Laboratory.Account.Login" %> 3 | 4 | 5 | 6 | 7 |

8 | Log In 9 |

10 |

11 | Please enter your username and password. 12 | Register if you don't have an account. 13 |

14 | 15 | 16 | 17 | 18 | 19 | 21 |
22 | 43 |

44 | 45 |

46 |
47 |
48 |
49 |
-------------------------------------------------------------------------------- /Laboratory/Module/NumberChecker.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module { 11 | 12 | 13 | public partial class NumberChecker { 14 | 15 | /// 16 | /// Controllo DropDownList1. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.DropDownList DropDownList1; 23 | 24 | /// 25 | /// Controllo TextBox1. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox TextBox1; 32 | 33 | /// 34 | /// Controllo CalculateButton. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button CalculateButton; 41 | 42 | /// 43 | /// Controllo ErrorLabel. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 50 | 51 | /// 52 | /// Controllo ResultLabel. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Label ResultLabel; 59 | 60 | /// 61 | /// Controllo ElapsedTimeLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ElapsedTimeLabel; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Laboratory/Module/Uncertainty.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module { 11 | 12 | 13 | public partial class Uncertainty { 14 | 15 | /// 16 | /// Controllo tableInput. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.HtmlControls.HtmlTextArea tableInput; 23 | 24 | /// 25 | /// Controllo functionInput. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox functionInput; 32 | 33 | /// 34 | /// Controllo CalculateButton. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.Button CalculateButton; 41 | 42 | /// 43 | /// Controllo ErrorLabel. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 50 | 51 | /// 52 | /// Controllo TableOutput. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.HtmlControls.HtmlTextArea TableOutput; 59 | 60 | /// 61 | /// Controllo ElapsedTimeLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ElapsedTimeLabel; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Laboratory/Module/Uncertainty.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Web.UI; 4 | using Mathos.Arithmetic; 5 | using Mathos.Parser; 6 | using Mathos.Statistics; 7 | 8 | namespace Laboratory.Module 9 | { 10 | public partial class Uncertainty : Page 11 | { 12 | private readonly MathParser _parser = new MathParser(); 13 | 14 | protected void Page_Load(object sender, EventArgs e) 15 | { 16 | _parser.OperatorAction["^"] = Pow; 17 | _parser.LocalVariables.Add("x", 0); 18 | 19 | _parser.LocalFunctions.Add("ln", x => DecimalArithmetic.Ln(x[0], 2000)); 20 | } 21 | 22 | protected void CalculateButton_Click(object sender, EventArgs e) 23 | { 24 | if (functionInput.Text == "") 25 | return; 26 | 27 | try 28 | { 29 | var watch = new Stopwatch(); 30 | watch.Start(); 31 | 32 | TableOutput.InnerText = 33 | UncertainNumber.ConvertArrayToTsvString( 34 | UncertainNumber.AutoFormat(UncertainNumber.CustomFunction(Func, tableInput.InnerText))); 35 | 36 | watch.Stop(); 37 | ElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds); 38 | } 39 | catch 40 | { 41 | TableOutput.InnerText = "Something went wrong. Check so that you've entered the function correctly."; 42 | } 43 | } 44 | 45 | public decimal Func(decimal x) 46 | { 47 | _parser.LocalVariables["x"] = x; 48 | 49 | return _parser.ProgrammaticallyParse(functionInput.Text); 50 | } 51 | 52 | public decimal Pow(decimal x, decimal exp) 53 | { 54 | //double[] fact = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000, 51090942171709440000d, 1124000727777607680000d }; 55 | 56 | // still developing this 57 | if (exp == 0) 58 | return 1; 59 | if (exp == 1) 60 | return x; 61 | if (exp - decimal.Floor(exp) != 0) 62 | { 63 | //for (int i = 0; i < 19; i++) 64 | //{ 65 | // decimal nom = System.Convert.ToDecimal( pow( exp * (decimal)Math.Log((double)x), i)); // (decimal)(Math.Pow((double)exp,i)* Math.Pow( (double)exp * Math.Log(Math.Abs((double)x)),i)); 66 | // val += nom / (decimal)fact[i]; 67 | //} 68 | 69 | return Convert.ToDecimal(Math.Exp((double) exp*Math.Log((double) x))); 70 | } 71 | 72 | decimal val = 1; 73 | 74 | for (var i = 0; i < exp; i++) 75 | val *= x; 76 | 77 | return val; 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Microsoft Reciprocal License (Ms-RL) 2 | 3 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 4 | 5 | 1. Definitions 6 | 7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 8 | 9 | A "contribution" is the original software, or any additions or changes to the software. 10 | 11 | A "contributor" is any person that distributes its contribution under this license. 12 | 13 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 14 | 15 | 2. Grant of Rights 16 | 17 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 18 | 19 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 20 | 21 | 3. Conditions and Limitations 22 | 23 | (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. You may license other files that are entirely your own work and do not contain code from the software under any terms you choose. 24 | 25 | (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 26 | 27 | (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 28 | 29 | (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 30 | 31 | (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 32 | 33 | (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 34 | -------------------------------------------------------------------------------- /Mathos/LICENSE.md: -------------------------------------------------------------------------------- 1 | Microsoft Reciprocal License (Ms-RL) 2 | 3 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 4 | 5 | 1. Definitions 6 | 7 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 8 | 9 | A "contribution" is the original software, or any additions or changes to the software. 10 | 11 | A "contributor" is any person that distributes its contribution under this license. 12 | 13 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 14 | 15 | 2. Grant of Rights 16 | 17 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 18 | 19 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 20 | 21 | 3. Conditions and Limitations 22 | 23 | (A) Reciprocal Grants- For any file you distribute that contains code from the software (in source code or binary format), you must provide recipients the source code to that file along with a copy of this license, which license will govern that file. You may license other files that are entirely your own work and do not contain code from the software under any terms you choose. 24 | 25 | (B) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 26 | 27 | (C) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 28 | 29 | (D) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 30 | 31 | (E) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 32 | 33 | (F) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. -------------------------------------------------------------------------------- /MathosTest/syntaxTest.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | using Mathos.Syntax; 4 | 5 | namespace MathosTest 6 | { 7 | [TestClass] 8 | public class SyntaxTest 9 | { 10 | [TestMethod] 11 | public void IsPositiveTest() 12 | { 13 | const int positive = 25; 14 | const int negative = -36; 15 | 16 | Assert.IsTrue(positive.IsPositive()); 17 | Assert.IsFalse(negative.IsPositive()); 18 | } 19 | 20 | [TestMethod] 21 | public void IsNegativeTest() 22 | { 23 | const int positive = 25; 24 | const int negative = -36; 25 | 26 | Assert.IsFalse(positive.IsNegative()); 27 | Assert.IsTrue(negative.IsNegative()); 28 | } 29 | 30 | [TestMethod] 31 | public void IsDivisibleTest() 32 | { 33 | const int divisible = 26; 34 | const int nondivisible = 37; 35 | 36 | Assert.IsTrue(divisible.IsDivisible(2)); 37 | Assert.IsFalse(nondivisible.IsDivisible(2)); 38 | } 39 | 40 | [TestMethod] 41 | public void IsEvenTest() 42 | { 43 | const int even = 26; 44 | const int odd = 37; 45 | 46 | Assert.IsTrue(even.IsEven()); 47 | Assert.IsFalse(odd.IsEven()); 48 | } 49 | 50 | [TestMethod] 51 | public void IsOddTest() 52 | { 53 | const int even = 26; 54 | const int odd = 37; 55 | 56 | Assert.IsFalse(even.IsOdd()); 57 | Assert.IsTrue(odd.IsOdd()); 58 | } 59 | 60 | [TestMethod] 61 | public void IsPrimeTest() 62 | { 63 | const int prime = 7; 64 | const int composite = 10; 65 | 66 | Assert.IsTrue(prime.IsPrime()); 67 | Assert.IsFalse(composite.IsPrime()); 68 | } 69 | 70 | [TestMethod] 71 | public void IsCoprimeTest() 72 | { 73 | const int test = 14; 74 | 75 | const int coprime = 15; 76 | const int composite = 21; 77 | 78 | Assert.IsTrue(test.IsCoprime(coprime)); 79 | Assert.IsFalse(test.IsCoprime(composite)); 80 | } 81 | 82 | [TestMethod] 83 | public void ToPositiveTest() 84 | { 85 | const int positive = 56; 86 | const int negative = -47; 87 | 88 | Assert.AreEqual(56, positive.ToPositive()); 89 | Assert.AreEqual(47, negative.ToPositive()); 90 | } 91 | 92 | [TestMethod] 93 | public void ToNegativeTest() 94 | { 95 | const int positive = 56; 96 | const int negative = -47; 97 | 98 | Assert.AreEqual(-56, positive.ToNegative()); 99 | Assert.AreEqual(-47, negative.ToNegative()); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Mathos/Statistics/Statistical Distributions/HypergeometricDistribution.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mathos.Statistics.Statistical_Distributions 4 | { 5 | /// 6 | /// 7 | /// 8 | public static class HypergeometricDistribution 9 | { 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | /// 17 | /// 18 | public static decimal ProbabilityMassFunction(long populationSize, long numberOfSuccessStates, long numberOfDraws, long numberOfSuccesses) 19 | { 20 | if (populationSize <= 0 || numberOfSuccessStates < 0 || numberOfDraws <= 0) return 0; 21 | 22 | double mCk = StatisticalProcedures.NumberOfCombinations(numberOfSuccessStates, numberOfSuccesses); 23 | double nmCnk = StatisticalProcedures.NumberOfCombinations(populationSize - numberOfSuccessStates, 24 | numberOfDraws - numberOfSuccesses); 25 | double nCn = StatisticalProcedures.NumberOfCombinations(populationSize, numberOfDraws); 26 | 27 | return (decimal) (mCk*nmCnk/nCn); 28 | } 29 | 30 | /// 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | public static decimal Mean(long populationSize, long numberOfSuccessStates, long numberOfDraws) 38 | { 39 | return (decimal)(numberOfDraws * numberOfSuccessStates) / populationSize; 40 | } 41 | 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | public static decimal Variance(long populationSize, long numberOfSuccessStates, long numberOfDraws) 50 | { 51 | decimal n = numberOfDraws; 52 | decimal m = numberOfSuccessStates; 53 | decimal n2 = populationSize; 54 | 55 | return n * (m / n2) * (n2 - m) * (1 / n2) * (n2 - n) * (1 / (n2 - 1)); 56 | } 57 | 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | /// 64 | /// 65 | public static decimal StandardDeviation(long populationSize, long numberOfSuccessStates, long numberOfDraws) 66 | { 67 | return (decimal)Math.Sqrt((double)Variance(populationSize, numberOfSuccessStates, numberOfDraws)); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Laboratory/Site.Master: -------------------------------------------------------------------------------- 1 | <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Laboratory.SiteMaster" %> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 27 | 28 |
29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 |
Mathos LaboratoryExplore the computational power of Mathos Core Library
37 | <%-- 38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 | 46 |
47 | 48 | 49 | 50 | 51 |
--%> 52 |
53 | 54 | 65 | 66 |
67 | 68 |
69 | 70 | 77 |
78 |
79 | 80 | -------------------------------------------------------------------------------- /Interactive Mathematics/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Этот код создан программным средством. 4 | // Версия среды выполнения: 4.0.30319.269 5 | // 6 | // Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если 7 | // код создан повторно. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Interactive_Mathematics.Properties 12 | { 13 | 14 | 15 | /// 16 | /// Класс ресурсов со строгим типом для поиска локализованных строк и пр. 17 | /// 18 | // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder 19 | // класс с помощью таких средств, как ResGen или Visual Studio. 20 | // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen 21 | // с параметром /str или заново постройте свой VS-проект. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Interactive_Mathematics.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Переопределяет свойство CurrentUICulture текущего потока для всех 56 | /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Mathos/Arithmetic/Numbers/Check.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace Mathos.Arithmetic.Numbers 5 | { 6 | /// 7 | /// Helpful checks for numbers. 8 | /// 9 | public class Check 10 | { 11 | /// 12 | /// Check if is positive. 13 | /// 14 | /// The number to check. 15 | /// True if is positive; false otherwise. 16 | public static bool IsPositive(long num) 17 | { 18 | return num > 0; 19 | } 20 | 21 | /// 22 | /// 23 | /// 24 | /// 25 | /// 26 | public static bool IsNegative(long num) 27 | { 28 | return num < 0; 29 | } 30 | 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | public static bool IsDivisible(long numA, long divisibleBy) 38 | { 39 | return numA % divisibleBy == 0; 40 | } 41 | 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | public static bool IsEven(long num) 48 | { 49 | return (num & 1) == 0; 50 | } 51 | 52 | /// 53 | /// 54 | /// 55 | /// 56 | /// 57 | public static bool IsOdd(long num) 58 | { 59 | if (num < 0) 60 | return num % 2 != 0; 61 | 62 | return (num & 1) == 1; 63 | } 64 | 65 | /// 66 | /// 67 | /// 68 | /// 69 | public static bool IsPrime(long num) 70 | { 71 | if (Get.ListOfCommonPrimeNumbers.Contains((int)num)) // first of all, we check 72 | return true; // if the prime is already 73 | // in the list 74 | 75 | if (num % 2 == 0) //even numbers>2 are not prime (2 is included in the common prime numbers) 76 | return false; 77 | 78 | var sqrtNum = (long)Math.Sqrt(num); // optimizing so that we do not 79 | // need to calculate the sqrt on each iteration 80 | for (long i = 2; i <= sqrtNum; i++) 81 | { 82 | if (num%i == 0) 83 | return false; // not a prime 84 | } 85 | 86 | return true; // a prime 87 | } 88 | 89 | /// 90 | /// 91 | /// 92 | /// 93 | /// 94 | /// 95 | public static bool IsCoprime(long numA, long numB) 96 | { 97 | return Get.Gcd(numA, numB) == 1; 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /MathosTest/SpecialFunctions/ElementaryTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using Mathos.Calculus; 4 | using Mathos.SpecialFunctions; 5 | using Microsoft.VisualStudio.TestTools.UnitTesting; 6 | 7 | namespace MathosTest.Mathos_Main.SpecialFunctions 8 | { 9 | [TestClass] 10 | public class ElementaryTests 11 | { 12 | // Using Asser.AreEqual almost always fails 13 | // Everything here is an approximation 14 | const double EPS = 1e-15; 15 | private bool AreApproximatelyEqual(double d1, double d2) 16 | { 17 | return Math.Abs(d1 - d2) < EPS; 18 | } 19 | 20 | private bool IsApproximatelyZero(double d) 21 | { 22 | return Math.Abs(d) < EPS; 23 | } 24 | 25 | 26 | 27 | private bool AreApproximatelyEqual(Complex complex1, Complex complex2) 28 | { 29 | return AreApproximatelyEqual(complex1.Real, complex2.Real) && 30 | AreApproximatelyEqual(complex1.Imaginary, complex2.Imaginary); 31 | } 32 | 33 | [TestMethod] 34 | public void Test_Cot() 35 | { 36 | Complex r = new Complex(Math.PI / 4, 0); 37 | Complex i = new Complex(0, Math.Log(3)); 38 | Complex c = new Complex(Math.PI / 2, Math.Log(3)); 39 | 40 | Complex cotr = Elementary.Cot(r); 41 | Complex coti = Elementary.Cot(i); 42 | Complex cotc = Elementary.Cot(c); 43 | 44 | 45 | Assert.IsTrue(AreApproximatelyEqual(cotr.Real,1D)); 46 | Assert.IsTrue(IsApproximatelyZero(cotr.Imaginary)); 47 | 48 | Assert.IsTrue(IsApproximatelyZero(coti.Real)); 49 | Assert.IsTrue(AreApproximatelyEqual(coti.Imaginary,-1.25D)); 50 | 51 | Assert.IsTrue(IsApproximatelyZero(cotc.Real)); 52 | Assert.IsTrue(AreApproximatelyEqual(cotc.Imaginary, -0.8D)); 53 | } 54 | 55 | [TestMethod] 56 | public void Test_Coth() 57 | { 58 | Complex r = new Complex(Math.Log(3), 0); 59 | Complex i = new Complex(0, Math.PI/4); 60 | Complex c = new Complex(Math.Log(3), Math.PI / 2); 61 | 62 | Assert.IsTrue(AreApproximatelyEqual(Elementary.Coth(r).Real, 1.25D)); 63 | Assert.IsTrue(IsApproximatelyZero(Elementary.Coth(r).Imaginary)); 64 | 65 | Assert.IsTrue(IsApproximatelyZero(Elementary.Coth(i).Real)); 66 | Assert.IsTrue(AreApproximatelyEqual(Elementary.Coth(i).Imaginary, -1D)); 67 | 68 | Assert.IsTrue(IsApproximatelyZero(Elementary.Coth(c).Imaginary)); 69 | Assert.IsTrue(AreApproximatelyEqual(Elementary.Coth(c).Real, 4D/5D)); 70 | } 71 | [TestMethod] 72 | public void Test_Roots() 73 | { 74 | //Complex[] expected = { Complex.One, Complex.ImaginaryOne, -Complex.One, -Complex.ImaginaryOne }; 75 | 76 | //Complex[] actual = Elementary.Roots(Complex.One, 4); 77 | 78 | //Assert.AreEqual(actual.Length, expected.Length); 79 | 80 | //for (int i = 0; i < expected.Length; i++) 81 | //{ 82 | // Assert.IsTrue(AreApproximatelyEqual(actual[i], expected[i])); 83 | //} 84 | } 85 | 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Mathos/Algebra.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Numerics; 3 | using Mathos.Arithmetic; 4 | 5 | namespace Mathos 6 | { 7 | /// 8 | /// 9 | /// 10 | public static class EquationSolver 11 | { 12 | /// 13 | /// Solves a quadratic equation, Ax^2 + Bx + C, where a != 0 14 | /// 15 | /// The first variable. 16 | /// The second variable. 17 | /// The third variable. 18 | /// 19 | [Obsolete] 20 | public static Complex[] QuadraticEquation(double a, double b, double c) 21 | { 22 | // only real solutions for the moment 23 | var discriminant = Math.Pow(b, 2) - 4 * a * c; 24 | 25 | // x1 results wrong value. 26 | //ComplexNumber x1 = ((ComplexNumber)(-B) + ComplexOperation.Sqrt(discriminant)) / (2 * (ComplexNumber)A); 27 | //ComplexNumber x2 = (-B - ComplexOperation.Sqrt(discriminant)) / (2 * A); 28 | 29 | //return new ComplexNumber[] { x1, x2 }; 30 | //return new Vector((decimal)x1, (decimal)x2); 31 | var q = -(b + Math.Sign(b) * ComplexArithmetic.Sqrt(discriminant)) / 2; 32 | 33 | return new[] { q / a, c / q }; 34 | } 35 | 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | public static Complex[] QuadraticEquationEx(double a, double b, double c) 43 | { 44 | var discriminant = Math.Pow(b, 2) - 4 * a * c; 45 | var q = -(b + Math.Sign(b) * ComplexArithmetic.Sqrt(discriminant)) / 2; 46 | 47 | return new[] { q / a, c / q }; 48 | } 49 | 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// 55 | /// 56 | /// 57 | public static Complex[] QuadraticEquation(Complex a, Complex b, Complex c) 58 | { 59 | var discriminant = b * b - 4 * a * c; 60 | var x1 = (b * -1 + Complex.Sqrt(discriminant)) / (2 * a); 61 | var x2 = (b * -1 - Complex.Sqrt(discriminant)) / (2 * a); 62 | 63 | return new[] { x1, x2 }; 64 | } 65 | 66 | /// 67 | /// Solves a system of two equations, 68 | /// Ax + By = E, 69 | /// Cx + Dy = F 70 | /// 71 | /// A 72 | /// B 73 | /// C 74 | /// D 75 | /// E 76 | /// F 77 | /// 78 | public static Vector SystemOfTwoEquations(double a, double b, double c, double d, double e, double f) 79 | { 80 | // only real numbers for the moment 81 | var x = (e * d - f * b) / (a * d - b * c); 82 | var y = (a * f - e * c) / (a * d - b * c); 83 | 84 | return new Vector(x, y); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceFutureValue.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module.Finance { 11 | 12 | 13 | public partial class FinanceFutureValue { 14 | 15 | /// 16 | /// Controllo PresentValueText. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox PresentValueText; 23 | 24 | /// 25 | /// Controllo RateOfReturnText. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox RateOfReturnText; 32 | 33 | /// 34 | /// Controllo NumberOfPeriodsText. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox NumberOfPeriodsText; 41 | 42 | /// 43 | /// Controllo RoundCheck. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.CheckBox RoundCheck; 50 | 51 | /// 52 | /// Controllo CalculateButton. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Button CalculateButton; 59 | 60 | /// 61 | /// Controllo ErrorLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 68 | 69 | /// 70 | /// Controllo ResultLabel. 71 | /// 72 | /// 73 | /// Campo generato automaticamente. 74 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 75 | /// 76 | protected global::System.Web.UI.WebControls.Label ResultLabel; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinancePresentValue.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module.Finance { 11 | 12 | 13 | public partial class FinancePresentValue { 14 | 15 | /// 16 | /// Controllo FutureValueText. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox FutureValueText; 23 | 24 | /// 25 | /// Controllo RateOfReturnText. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox RateOfReturnText; 32 | 33 | /// 34 | /// Controllo NumberOfPeriodsText. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox NumberOfPeriodsText; 41 | 42 | /// 43 | /// Controllo RoundCheck. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.CheckBox RoundCheck; 50 | 51 | /// 52 | /// Controllo CalculateButton. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Button CalculateButton; 59 | 60 | /// 61 | /// Controllo ErrorLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 68 | 69 | /// 70 | /// Controllo ResultLabel. 71 | /// 72 | /// 73 | /// Campo generato automaticamente. 74 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 75 | /// 76 | protected global::System.Web.UI.WebControls.Label ResultLabel; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /MathosTest/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34011 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MathosTest.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MathosTest.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to 42 2 65 | ///12 2 66 | ///421 2 67 | ///4 2 68 | ///12 2. 69 | /// 70 | internal static string String1 { 71 | get { 72 | return ResourceManager.GetString("String1", resourceCulture); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Laboratory/Module/EquationSolver.aspx.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Web.UI; 4 | using Mathos; 5 | namespace Laboratory.Module 6 | { 7 | public partial class EquationSolver : Page 8 | { 9 | protected void Page_Load(object sender, EventArgs e) 10 | { 11 | } 12 | 13 | protected void SolveSystemOfTwoEquation_Click(object sender, EventArgs e) 14 | { 15 | if (TextBox1.Text == "") 16 | TextBox1.Text = "0"; 17 | if (TextBox2.Text == "") 18 | TextBox2.Text = "0"; 19 | if (TextBox3.Text == "") 20 | TextBox3.Text = "0"; 21 | if (TextBox4.Text == "") 22 | TextBox4.Text = "0"; 23 | if (TextBox5.Text == "") 24 | TextBox5.Text = "0"; 25 | if (TextBox6.Text == "") 26 | TextBox6.Text = "0"; 27 | 28 | try 29 | { 30 | var watch = new Stopwatch(); 31 | watch.Start(); 32 | 33 | Vector result = Mathos.EquationSolver.SystemOfTwoEquations(Convert.ToDouble(TextBox1.Text), 34 | Convert.ToDouble(TextBox2.Text), 35 | Convert.ToDouble(TextBox4.Text), 36 | Convert.ToDouble(TextBox5.Text), 37 | Convert.ToDouble(TextBox3.Text), 38 | Convert.ToDouble(TextBox6.Text)); 39 | 40 | watch.Stop(); 41 | EquationElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", watch.Elapsed.TotalMilliseconds); 42 | 43 | EquationResultLabel.Text = string.Format( 44 | "Result: x = {0}; y = {1}", 45 | result[0], 46 | result[1]); 47 | } 48 | catch 49 | { 50 | EquationErrorLabel.Text = "Error!"; 51 | } 52 | } 53 | 54 | protected void SolveQuadraticEquation_Click(object sender, EventArgs e) 55 | { 56 | if (TextBox7.Text.Trim() == "" || TextBox7.Text.Trim() == "0") 57 | { 58 | QuadraticEquationErrorLabel.Text = "A cannot be 0!"; 59 | return; 60 | } 61 | if (TextBox8.Text == "") 62 | TextBox8.Text = "0"; 63 | if (TextBox9.Text == "") 64 | TextBox9.Text = "0"; 65 | 66 | try 67 | { 68 | var watch = new Stopwatch(); 69 | watch.Start(); 70 | 71 | var result = Mathos.EquationSolver.QuadraticEquation(Convert.ToDouble(TextBox7.Text), 72 | Convert.ToDouble(TextBox8.Text), 73 | Convert.ToDouble(TextBox9.Text)); 74 | 75 | watch.Stop(); 76 | QuadraticEquationElapsedTimeLabel.Text = string.Format("Elapsed time: {0} ms", 77 | watch.Elapsed.TotalMilliseconds); 78 | 79 | QuadraticEquationResultLabel.Text = string.Format( 80 | "Result: x2 = {0}; x2 = {1}", 81 | result[0].Real, 82 | result[1].Imaginary); 83 | } 84 | catch 85 | { 86 | QuadraticEquationErrorLabel.Text = "Error!"; 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceNetPresentValue.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module.Finance { 11 | 12 | 13 | public partial class FinanceNetPresentValue { 14 | 15 | /// 16 | /// Controllo InitialInvestmentValueText. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox InitialInvestmentValueText; 23 | 24 | /// 25 | /// Controllo CashFlowValueText. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox CashFlowValueText; 32 | 33 | /// 34 | /// Controllo RateOfReturnText. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox RateOfReturnText; 41 | 42 | /// 43 | /// Controllo RoundCheck. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.CheckBox RoundCheck; 50 | 51 | /// 52 | /// Controllo CalculateButton. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Button CalculateButton; 59 | 60 | /// 61 | /// Controllo ErrorLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 68 | 69 | /// 70 | /// Controllo ResultLabel. 71 | /// 72 | /// 73 | /// Campo generato automaticamente. 74 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 75 | /// 76 | protected global::System.Web.UI.WebControls.Label ResultLabel; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Laboratory/Module/Finance/FinanceAnnuityPaymentFutureValue.aspx.designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Codice generato da uno strumento. 4 | // 5 | // Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se 6 | // il codice viene rigenerato. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | namespace Laboratory.Module.Finance { 11 | 12 | 13 | public partial class FinanceAnnuityPaymentFutureValue { 14 | 15 | /// 16 | /// Controllo FutureValueText. 17 | /// 18 | /// 19 | /// Campo generato automaticamente. 20 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 21 | /// 22 | protected global::System.Web.UI.WebControls.TextBox FutureValueText; 23 | 24 | /// 25 | /// Controllo RateOfReturnText. 26 | /// 27 | /// 28 | /// Campo generato automaticamente. 29 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 30 | /// 31 | protected global::System.Web.UI.WebControls.TextBox RateOfReturnText; 32 | 33 | /// 34 | /// Controllo NumberOfPeriodsText. 35 | /// 36 | /// 37 | /// Campo generato automaticamente. 38 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 39 | /// 40 | protected global::System.Web.UI.WebControls.TextBox NumberOfPeriodsText; 41 | 42 | /// 43 | /// Controllo RoundCheck. 44 | /// 45 | /// 46 | /// Campo generato automaticamente. 47 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 48 | /// 49 | protected global::System.Web.UI.WebControls.CheckBox RoundCheck; 50 | 51 | /// 52 | /// Controllo CalculateButton. 53 | /// 54 | /// 55 | /// Campo generato automaticamente. 56 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 57 | /// 58 | protected global::System.Web.UI.WebControls.Button CalculateButton; 59 | 60 | /// 61 | /// Controllo ErrorLabel. 62 | /// 63 | /// 64 | /// Campo generato automaticamente. 65 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 66 | /// 67 | protected global::System.Web.UI.WebControls.Label ErrorLabel; 68 | 69 | /// 70 | /// Controllo ResultLabel. 71 | /// 72 | /// 73 | /// Campo generato automaticamente. 74 | /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. 75 | /// 76 | protected global::System.Web.UI.WebControls.Label ResultLabel; 77 | } 78 | } 79 | --------------------------------------------------------------------------------