Loading web-font TeX/Math/Italic

Monday, 22 March 2021

Publishing .NETCore Application and running on Linux

Over the last year or so I've been writing a simple tool in .NET Core to compare two CSV files. It can be found in on GitHub here. I won't go into details about the tool in this post but being a .NET Core application I've been able to develop it on Windows and also deploy and run on Linux. This post describes how I published and deployed.

I've been using Visual Studio. When I want to create a new deployment I right-click on the Project and select Publish...

I have setup a profile, called "FolderProfile" (Very imaginative!)

  • TargetLocation : Folder name
  • Configuration : Release | Any CPU (from my solution)
  • Deployment mode : Framework-dependent
  • TargetFramework : netcoreapp3.0
  • TargetRuntime : Portable

(I used Framework-dependent deployment for cross-platform binaries. This creates a dll which can be run with dotnet <filename.dll> on any platform. Of course this requires the .NET runtime to be installed on the Linux machine.)
 
Then click on Publish.
 
This created a folder under Release/netcoreapp3.0/publish
 
I copied these files onto my Linux machine. Here are the important ones:
total 68
drwxr-xr-x  2 jonathan jonathan  4096 Mar 12 19:27 .
drwxr-xr-x 64 jonathan jonathan  4096 Mar 12 19:35 ..
-rwx------  1 jonathan jonathan   431 Jul  2  2020 CSVComparison.deps.json
-rwx------  1 jonathan jonathan 14336 Jul  2  2020 CSVComparison.dll
-rwx------  1 jonathan jonathan  4860 Jul  2  2020 CSVComparison.pdb
-rwx------  1 jonathan jonathan   154 Jul  2  2020 CSVComparison.runtimeconfig.json 
 

I've previously installed the .NET Core runtime on Ubuntu. As of the time of writing the installed version (dotnet --version) is 3.1.404.

The IMDB/movie_data.csv file is a 50000 row CSV I generated from the IMDB movie dataset. I had originally set this up for a machine learning exercise but it is also a good sized dataset to checkout the tool. I made two copies and edited one of the comments on the candidate file. Then, to run the CSV Comparison, I navigated to the folder containing the binaries and ran with this command-line:

dotnet ./CSVComparison.dll ../IMDB/movie_data2.csv ../IMDB/movie_data2.csv ../IMDB/movie_config.xml ./output

The output:

Reference: ./movie_data.csv
Candidate: ./movie_data2.csv
Saving results to output/ComparisonResults.csv
Finished. Comparison took 10517ms

And the result:

?xml version="1.0" encoding="utf-8"?>
<ComparisonDefinition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/20
01/XMLSchema">
  <Delimiter>,</Delimiter>
  <KeyColumns>
    <Column>row</Column>
  </KeyColumns>
  <HeaderRowIndex>0</HeaderRowIndex>
  <ToleranceValue>0.1</ToleranceValue>
  <IgnoreInvalidRows>false</IgnoreInvalidRows>
  <ToleranceType>Relative</ToleranceType>
  <ExcludedColumns />
</ComparisonDefinition>

Date run: 22/03/2021 18:40:12
Reference: ./movie_data.csv
Candidate: ./movie_data2.csv
Number of Reference rows: 50001
Number of Candidate rows: 50001
Comparison took 10517ms
Number of breaks 1

Break Type,Key,Column Name,Reference Row, Reference Value, Candidate Row, Candidate Value
ValueMismatch,7230,review,96,"Exceptional movie that handles a theme of

Tuesday, 2 March 2021

Time for some Maths

While tidying up my old University Maths notes the other day I came across this problem. (I didn't get it right first time round!)

It's quite interesting and I thought I'd also use the opportunity to setup nice looking maths on the blog. So, the question:

Find the first two terms of the series for tanx in powers of x.

Now, 

tanx=\frac{sinx}{cosx}


and the power series expansions of sinx and cosx begin as:

sinx=x-\frac{x^3}{3!}+\frac{x^5}{5!}+...

cosx=1-\frac{x^2}{2!}+\frac{x^4}{4!}+...


Put this together:

tanx=\frac{x-\frac{x^3}{6}+...}{1-\frac{x^2}{2}+...}


Multiply by \frac{1+\frac{x^2}{2}}{1+\frac{x^2}{2}} (This is just multiplying by 1 and chosen so we can deal with the x^2 term in the denominator), so:

tanx=\frac{(1+\frac{x^2}{2})(x-\frac{x^3}{6}+...)}{(1+\frac{x^2}{2})(1-\frac{x^2}{2}+...)}

If we now just multiply out the first term we get

tanx=\frac{x+\frac{x^3}{2}-\frac{x^3}{6}+...}{1+\frac{x^2}{2}-\frac{x^2}{2}+...}

tanx=\frac{x+\frac{x^3}{3}+...}{1+...}

The other terms in x^4 and x^5 can be ignored, giving:

tanx=x+\frac{x^3}{3}+...


To display the formulae I've added MathJax to the blog. 

Go to Theme then from the Customise dropdown select Edit HTML. Add the following just below the <head> element:


<script src='http://cdn.mathjax.org/mathjax/latest/MathJax.js' type='text/javascript'>
MathJax.Hub.Config({
extensions: [&quot;tex2jax.js&quot;,&quot;TeX/AMSmath.js&quot;,&quot;TeX/AMSsymbols.js&quot;],
jax: [&quot;input/TeX&quot;, &quot;output/HTML-CSS&quot;],
tex2jax: {
inlineMath: [ [&#39;&#39;,&#39;&#39;], [&quot;\\(&quot;,&quot;\\)&quot;] ],
displayMath: [ [&#39;&#39;,&#39;
&#39;], [&quot;\\[&quot;,&quot;\\]&quot;] ],
},
&quot;HTML-CSS&quot;: { availableFonts: [&quot;TeX&quot;] }
});
</script>
view raw MathJax.js hosted with ❤ by GitHub


Finally, here's a useful link: MathJax basic tutorial and quick reference - Mathematics Meta Stack Exchange