sine Wiki & Documentation Rss Feedhttp://www.codeplex.com/sine/Wiki/View.aspx?title=Homesine Wiki Rss DescriptionUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=13<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true rational number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release), it is more accurately described as a floating-point class.<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraic symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">public</span> <span style="color:Blue;">class</span> ExpressionSample {
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion defined</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
BigNum x = 100;
BigNum xPow100 = x.Pow( 100 );
Console.WriteLine(<span style="color:#A31515;">"100^100 == "</span> + xPow100.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 02 Oct 2009 20:33:02 GMTUpdated Wiki: Home 20091002083302PUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=12<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true rational number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release), it is more accurately described as a floating-point class.<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraic symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">public</span> <span style="color:Blue;">class</span><span style="color:MediumTurquoise;"> ExpressionSample </span>{
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion operator is defined, so this 100 literal will be converted into a BigNumDec equal to 100</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
BigNum x = 100;
BigNum xPow100 = x.Pow( 100 );
Console.WriteLine(<span style="color:#A31515;">"100^100 == "</span> + xPow100.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 18 Sep 2009 21:36:25 GMTUpdated Wiki: Home 20090918093625PUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=11<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true real-number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release).<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraic symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">public</span> <span style="color:Blue;">class</span><span style="color:MediumTurquoise;"> ExpressionSample </span>{
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion operator is defined, so this 100 literal will be converted into a BigNumDec equal to 100</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
BigNum x = 100;
BigNum xPow100 = x.Pow( 100 );
Console.WriteLine(<span style="color:#A31515;">"100^100 == "</span> + xPow100.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 04 Sep 2009 14:27:56 GMTUpdated Wiki: Home 20090904022756PUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=10<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true real-number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release).<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraic symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">public</span> <span style="color:Blue;">class</span><span style="color:MediumTurquoise;"> ExpressionSample </span>{
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion operator is defined, so this 100 literal will be converted into a BigNumDec equal to 100</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 04 Sep 2009 01:33:19 GMTUpdated Wiki: Home 20090904013319AUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=9<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true real-number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release).<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraric symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">public</span> <span style="color:Blue;">class</span><span style="color:MediumTurquoise;"> ExpressionSample </span>{
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion operator is defined, so this 100 literal will be converted into a BigNumDec equal to 100</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 04 Sep 2009 00:51:33 GMTUpdated Wiki: Home 20090904125133AUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=8<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision decimal number library developed in C#.<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like to include arbitrary-precision arithmetic in their applications.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true real-number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release).<br /><br />The library also includes an Expression class which can parse and evaluate expressions with support for algebraric symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is small but untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under 24/7 active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.<br />
<h2>Features</h2>
<ul><li>Arbitrary-precision decimal arithmetic</li>
<li>Expression evaluator class</li>
<li>Relatively easy to use</li></ul>
<h2>Sample</h2>
<div style="color:Black;background-color:White;"><pre>
<span style="color:Blue;">using</span> W3b.Sine;
<span style="color:Blue;">class</span><span style="color:MediumTurquoise;"> ExpressionSample </span>{
<span style="color:Blue;">public</span> <span style="color:Blue;">static</span> <span style="color:Blue;">void</span> Main(String[] args) {
Dictionary<String,BigNum> symbols = <span style="color:Blue;">new</span> Dictionary<String,BigNum>() {
{<span style="color:#A31515;">"x"</span>, 100} <span style="color:Green;">// the implicit conversion operator is defined, so this 100 literal will be converted into a BigNumDec equal to 100</span>
};
Expression expression = <span style="color:Blue;">new</span> Expression(<span style="color:#A31515;">"1 + 2 / 3 * x"</span>);
BigNum result = expression.Evaluate( symbols );
Console.WriteLine( expression.ExpressionString + <span style="color:#A31515;">" == "</span> + result.ToString() );
}
}
</pre></div></div><div class="ClearBoth"></div>W3bboFri, 04 Sep 2009 00:50:48 GMTUpdated Wiki: Home 20090904125048AUpdated Wiki: Homehttp://sine.codeplex.com/Wiki/View.aspx?title=Home&version=7<div class="wikidoc"><b>Project Description</b><br />An arbitrary-precision real number library developed in C#.<br /><br />The elementary operations are implemented using "schoolbook" algorithms, more advanced functions are implemented with Taylor/Maclaurin series.<br /><br />The project also includes a rudimentary expression evaluator (implemented as a simple stack, not RPN style, however; more like those 1-line calculators you can buy for £5 at WHSmith)<br /><br />The library still has an extensive list of work that needs doing to it before it can become really useful, like a function to calculate Pi (right now it uses a hardcoded literal generated by Mathematica (my CAS of choice), limited to 40 decimal places). There are also a few bugs relating to the .ToString() function, but the core of the class is solid.<br /><br />Many, many, many thanks go to Chris (LongNightMoon from Channel9) in assisting with development, especially with the division operation.<br /><br />I haven't performed any complexity analysis of the functions, since it wasn't covered under the original spec (and my CS knowledge isn't great enough at this point to know how to either).<br /><br />This is a BSD licensed library for use by CLR/DLR languages (like VB.NET, C#, and F#) when developers would like arbitrary-precision arithmetic.<br /><br />The library contains an abstract BigNum class (representing a generic immutable unbound number instance) and a concrete implementation (BigNumDec: an implementation using an internal base 10 representation and schoolbook algorithms). The BigNumDec implementation does not provide true real-number support as it does not internally represent numbers as a numerator/denominator pair (this is planned for a future release).<br /><br />The library also includes an Expression class which can parse and evaluate expressions (like (5<u>3)/2</u>10 with support for algebraric symbols (defined in a Dictionary<String,BigNum> instance). There exists no support for functions in expressions (this is also coming in a future release). <br /><br />The library is very untidy and could do with a good clean-up. I question my original design descision to have a base abstract class and to implement additional operations in the BigNum classes rather than in a dedicated "BigMath" static class.<br /><br />You are encouraged to submit patches and improvements. This project is not under active development.<br /><br />The name "Sine" is taken from a university problem I wrote this library to solve in early 2008: to find the sine of 10^40 radians.</div><div class="ClearBoth"></div>W3bboFri, 04 Sep 2009 00:41:06 GMTUpdated Wiki: Home 20090904124106AUpdated Wiki: Homehttp://www.codeplex.com/sine/Wiki/View.aspx?title=Home&version=6<div class="wikidoc">
<b>Project Description</b><br />An arbitrary-precision real number library developed in C#.<br /><br />The elementary operations are implemented using "schoolbook" algorithms, more advanced functions are implemented with Taylor/Maclaurin series.<br /><br />The project also includes a rudimentary expression evaluator (implemented as a simple stack, not RPN style, however; more like those 1-line calculators you can buy for £5 at WHSmith)<br /><br />The library still has an extensive list of work that needs doing to it before it can become really useful, like a function to calculate Pi (right now it uses a hardcoded literal generated by Mathematica (my CAS of choice), limited to 40 decimal places). There are also a few bugs relating to the .ToString() function, but the core of the class is solid.<br /><br />Many, many, many thanks go to Chris (LongNightMoon from Channel9) in assisting with development, especially with the division operation.<br /><br />I haven't performed any complexity analysis of the functions, since it wasn't covered under the original spec (and my CS knowledge isn't great enough at this point to know how to either).
<br /> <br /><h1>
A Brief History
</h1> <br />Sometime in February 2008, Professor Achim Jung at the University of Birmingham posed a challenge to potential undergraduates: "Write a program which computes the Sine of an angle 10^40 radians, if you pull it off you get an unconditional(1) offer to study Computer Science". This was during a little talk given to everyone about the limitations of the intrinsic number types in most programming languages. "Score!", I thought, as I took up the challenge that day.<br /> <br />It took me a few weeks to come to a final solution. I realised I'd need to first develop an arbitrary-precision real library (IntX is only for Integers, which is a bummer in this case), and then re-implement my own trigonometric functions. Implementing the trig functions was trivial and done in a matter of minutes when using Taylor series approximations, the real problem was creating a number format.<br /> <br />At Prof. Jung's recommendation, I read through Knuth's The Art of Computer Programming, Volume 2; but whilst I followed most of it fine I didn't really find it much of a help. Realising there might be many ways to solve the problem I created an abstract BigNum class so I could experiment and started work on my first attempt: a subclass of BigNum named BigNumBin which worked using an internal resizable BitArray and Two's Complement for sign. To say the least, it didn't go very well and I was thinking of giving up, until Chris (LongNightMoon from MSDN's Channel9) gave me renewed hope with a more conventional ByteArray and Binary Coded Decimal concept. Whilst it wasn't the "pure" solution I was after, it was a pragmatic solution and I churned out the completed class a few days later, emailed it off to Professor Jung, and scored an unconditional.<br /> <br />....and that's why the project is called "Sine".<br /> <br />Oh, and the answer is -0.56963340095363632731<br /> <br />([1) The UK universities admission process is different to the United States' (and others). Since every (except 1) HE institute (i.e. University) in the UK is a public institute at least partially funded by the government all admissions are done through UCAS (the Universities and Colleges Admissions Service), there is no other way (not even any "backdoors") into a university except through UCAS. UCAS works by you submitting your details, a personal statement about how great you are, the subjects you're currently studying or previously attained, and the grades you hope to achieve in them). For subjects like A-Levels, you take the final exams in May/June, but you don't get the results back until August, long after you finished High School/6th Form so universities give you "conditional offers", which basically mean that *if* you attain certain grades in August then you've got a place. If you get an unconditional offer it means you're pretty much guaranteed a place at the university regardless of what you get in August, which takes a lot of pressure off during the May/June exams. Often universities award unconditionals if you already meet the criteria (for instance, having a gap year after attaining the grades), it is rare for them to offer unconditionals to students who don't already meet the criteria (but they often do offer reduced criteria based on how well you impress them during your application interview). So I guess I just got lucky. So here's a note to anyone thinking of studying CS at Birmingham: ask for Prof. Achim Jung and the details of whatever challenge he is posing for your year of admission. Feel free to send me a PM/email via Codeplex if you need help with solving it :)<br />
</div>W3bboThu, 10 Jul 2008 23:52:28 GMTUpdated Wiki: Home 20080710115228PUpdated Wiki: Homehttp://www.codeplex.com/sine/Wiki/View.aspx?title=Home&version=5<div class="wikidoc">
<b>Project Description</b><br />An arbitrary-precision real number library developed in C#.<br /><br />The elementary operations are implemented using "schoolbook" algorithms, more advanced functions are implemented with Taylor/Maclaurin series.<br /><br />The project also includes a rudimentary expression evaluator (implemented as a simple stack, not RPN style, however; more like those 1-line calculators you can buy for £5 at WHSmith)<br /><br />The library still has an extensive list of work that needs doing to it before it can become really useful, like a function to calculate Pi (right now it uses a hardcoded literal generated by Mathematica (my CAS of choice), limited to 40 decimal places). There are also a few bugs relating to the .ToString() function, but the core of the class is solid.<br /><br />Many, many, many thanks go to Chris (LongNightMoon from Channel9) in assisting with development, especially with the division operation.<br /><br />I haven't performed any complexity analysis of the functions, since it wasn't covered under the original spec (and my CS knowledge isn't great enough at this point to know how to either).
<br /> <br /><h1>
A Brief History
</h1> <br />Sometime in February 2008, Professor Achim Jung at the University of Birmingham posed a challenge to potential undergraduates: "Write a program which computes the Sine of an angle 10^40 radians, if you pull it off you get an unconditional<a href="http://www.codeplex.com/sine/Wiki/View.aspx?title=1&referringTitle=Home">1</a> offer to study Computer Science". This was during a little talk given to everyone about the limitations of the intrinsic number types in most programming languages. "Score!", I thought, as I took up the challenge that day.<br /> <br />It took me a few weeks to come to a final solution. I realised I'd need to first develop an arbitrary-precision real library (IntX is only for Integers, which is a bummer in this case), and then re-implement my own trigonometric functions. Implementing the trig functions was trivial and done in a matter of minutes when using Taylor series approximations, the real problem was creating a number format.<br /> <br />At Prof. Jung's recommendation, I read through Knuth's The Art of Computer Programming, Volume 2; but whilst I followed most of it fine I didn't really find it much of a help. Realising there might be many ways to solve the problem I created an abstract BigNum class so I could experiment and started work on my first attempt: a subclass of BigNum named BigNumBin which worked using an internal resizable BitArray and Two's Complement for sign. To say the least, it didn't go very well and I was thinking of giving up, until Chris (LongNightMoon from MSDN's Channel9) gave me renewed hope with a more conventional ByteArray and Binary Coded Decimal concept. Whilst it wasn't the "pure" solution I was after, it was a pragmatic solution and I churned out the completed class a few days later, emailed it off to Professor Jung, and scored an unconditional.<br /> <br />....and that's why the project is called "Sine".<br /> <br />Oh, and the answer is -0.56963340095363632731<br /> <br /><a href="http://www.codeplex.com/sine/Wiki/View.aspx?title=1&referringTitle=Home">1</a> The UK universities admission process is different to the United States' (and others). Since every (except 1) HE institute (i.e. University) in the UK is a public institute at least partially funded by the government all admissions are done through UCAS (the Universities and Colleges Admissions Service), there is no other way (not even any "backdoors") into a university except through UCAS. UCAS works by you submitting your details, a personal statement about how great you are, the subjects you're currently studying or previously attained, and the grades you hope to achieve in them). For subjects like A-Levels, you take the final exams in May/June, but you don't get the results back until August, long after you finished High School/6th Form so universities give you "conditional offers", which basically mean that <b>if</b> you attain certain grades in August then you've got a place. If you get an unconditional offer it means you're pretty much guaranteed a place at the university regardless of what you get in August, which takes a lot of pressure off during the May/June exams. Often universities award unconditionals if you already meet the criteria (for instance, having a gap year after attaining the grades), it is rare for them to offer unconditionals to students who don't already meet the criteria (but they often do offer reduced criteria based on how well you impress them during your application interview). So I guess I just got lucky. So here's a note to anyone thinking of studying CS at Birmingham: ask for Prof. Achim Jung and the details of whatever challenge he is posing for your year of admission. Feel free to send me a PM/email via Codeplex if you need help with solving it :)<br />
</div>W3bboThu, 10 Jul 2008 23:51:29 GMTUpdated Wiki: Home 20080710115129PUpdated Wiki: Homehttp://www.codeplex.com/sine/Wiki/View.aspx?title=Home&version=4<div class="wikidoc">
<b>Project Description</b><br />An arbitrary-precision real number library developed in C#.<br /><br />The elementary operations are implemented using "schoolbook" algorithms, more advanced functions are implemented with Taylor/Maclaurin series.<br /><br />The project also includes a rudimentary expression evaluator (implemented as a simple stack, not RPN style, however; more like those 1-line calculators you can buy for £5 at WHSmith)<br /><br />The library still has an extensive list of work that needs doing to it before it can become really useful, like a function to calculate Pi (right now it uses a hardcoded literal generated by Mathematica (my CAS of choice), limited to 40 decimal places). There are also a few bugs relating to the .ToString() function, but the core of the class is solid.<br /><br />Many, many, many thanks go to Chris (LongNightMoon from Channel9) in assisting with development, especially with the division operation.<br /><br />I haven't performed any complexity analysis of the functions, since it wasn't covered under the original spec (and my CS knowledge isn't great enough at this point to know how to either).
<br /> <br /><h1>
A Brief History
</h1> <br />Sometime in February 2008, Professor Achim Jung at the University of Birmingham posed a challenge to potential undergraduates: "Write a program which computes the Sine of an angle 10^40 radians, if you pull it off you get an unconditional offer to study Computer Science". This was during a little talk given to everyone about the limitations of the intrinsic number types in most programming languages. "Score!", I thought, as I took up the challenge that day.<br /> <br />It took me a few weeks to come to a final solution. I realised I'd need to first develop an arbitrary-precision real library (IntX is only for Integers, which is a bummer in this case), and then re-implement my own trigonometric functions. Implementing the trig functions was trivial and done in a matter of minutes when using Taylor series approximations, the real problem was creating a number format.<br /> <br />At Prof. Jung's recommendation, I read through Knuth's The Art of Computer Programming, Volume 2; but whilst I followed most of it fine I didn't really find it much of a help. Realising there might be many ways to solve the problem I created an abstract BigNum class so I could experiment and started work on my first attempt: a subclass of BigNum named BigNumBin which worked using an internal resizable BitArray and Two's Complement for sign. To say the least, it didn't go very well and I was thinking of giving up, until Chris (LongNightMoon from MSDN's Channel9) gave me renewed hope with a more conventional ByteArray and Binary Coded Decimal concept. Whilst it wasn't the "pure" solution I was after, it was a pragmatic solution and I churned out the completed class a few days later, emailed it off to Professor Jung, and scored an unconditional.<br /> <br />....and that's why the project is called "Sine".<br /> <br />Oh, and the answer is -0.56963340095363632731<br />
</div>W3bboThu, 26 Jun 2008 19:51:21 GMTUpdated Wiki: Home 20080626075121PUpdated Wiki: Homehttp://www.codeplex.com/sine/Wiki/View.aspx?title=Home&version=3<div class="wikidoc">
<b>Project Description</b><br />An arbitrary-precision real number library developed in C#.<br /><br />The elementary operations are implemented using "schoolbook" algorithms, more advanced functions are implemented with Taylor/Maclaurin series.<br /><br />The project also includes a rudimentary expression evaluator (implemented as a simple stack, not RPN style, however; more like those 1-line calculators you can buy for £5 at WHSmith)<br /><br />The library still has an extensive list of work that needs doing to it before it can become really useful, like a function to calculate Pi (right now it uses a hardcoded literal generated by Mathematica (my CAS of choice), limited to 40 decimal places). There are also a few bugs relating to the .ToString() function, but the core of the class is solid.<br /><br />Many, many, many thanks go to Chris (LongNightMoon from Channel9) in assisting with development, especially with the division operation.<br /><br />I haven't performed any complexity analysis of the functions, since it wasn't covered under the original spec (and my CS knowledge isn't great enough at this point to know how to either).
<br /> <br /><h1>
A Brief History
</h1> <br />Sometime in February 2008, Professor Achim Jung at the University of Birmingham posed a challenge to potential undergraduates: "Write a program which computes the Sine of an angle 10^40 radians, if you pull it off you get an unconditional offer to study Computer Science". This was during a little talk given to everyone about the limitations of the intrinsic number types in most programming languages. "Score!", I thought, as I took up the challenge that day.<br /> <br />It took me a few weeks to come to a final solution. I realised I'd need to first develop an arbitrary-precision real library (IntX is only for Integers, which is a bummer in this case), and then re-implement my own trigonometric functions. Implementing the trig functions was trivial and done in a matter of minutes when using Taylor series approximations, the real problem was creating a number format.<br /> <br />At Prof. Jung's recommendation, I read through Knuth's The Art of Computer Programming, Volume 2; but whilst I followed most of it fine I didn't really find it much of a help. Realising there might be many ways to solve the problem I created an abstract BigNum class so I could experiment and started work on my first attempt: a subclass of BigNum named BigNumBin which worked using an internal resizable BitArray and Two's Complement for sign. To say the least, it didn't go very well and I was thinking of giving up, until Chris (LongNightMoon from MSDN's Channel9) gave me renewed hope with a more conventional ByteArray and Binary Coded Decimal concept. Whilst it wasn't the "pure" solution I was after, it was a pragmatic solution and I churned out the completed class a few days later, emailed it off to Professor Jung, and scored an unconditional.<br /> <br />....and that's why the project is called "Sine".<br />
</div>W3bboThu, 26 Jun 2008 19:50:15 GMTUpdated Wiki: Home 20080626075015P