Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Monday, April 14, 2014

Online LaTeX Equation Editor - create, integrate and download

Online LaTeX Equation Editor - create, integrate and download:



This is a pretty neat little app.  If you don't have MathType and or don't want to use equation editor for Microsoft products (or similar), such as PowerPoint, then this is a nice way to display equations through an image.

Monday, January 28, 2013

LaTeX Tips: Displayed Math - adding sections, subsections, etc. to equation numbers

LaTeX Tips: Displayed Math

How to number equations. By default, LaTeX will number equations consecutively, as (1), (2), etc., assuming you use the automatic equation numbering mechanism. If the paper is very short, or if there are only a few numbered equations, this is fine, but once the numbers get into the twenties and higher, a scheme that numbers equations by section, as in (1.1), (1.2), ..., (2.1), etc., is preferable. In fact, for the vast majority of journal articles, the latter is probably the best numbering scheme. To get equations numbered by section, just put the following into the preamble: " \numberwithin{equation}{section} ". For books, theses, or very long papers, an equation numbering scheme that is three levels deep (with numbers like (4.1.1), etc.) may be appropriate. To get this, just replace "section" above by "subsection", or the corresponding innermost level. The same mechanism works for other counters, e.g., theorem counters, instead of "equation".

If you have a thesis or some other class/document type it may be different.  In my case (UTK thesis/diss class) it automatically numbered 3.1 for chapters.  So for "3.1.1" it was "section," and "3.1.1.1" I used "subsection."

Thursday, July 19, 2012

Some common functions in Maxima - trig, logarithms, the exponential, and square root

http://maxima.sourceforge.net/docs/manual/en/maxima_10.html#SEC47

exp(x)
log(x)
sqrt(x)
acos(x)
acosh(x)
acot(x)
acoth(x)
asin(x)
asinh(x)
asec(x)
asech(x)
acsc(x)
acsch(x)
atan(x)
atanh(x)
cos(x)
cosh(x)
cot(x)
coth(x)
sin(x)
sinh(x)
sec(x)
sech(x)
csc(x)
csch(x)
tan(x)
tanh(x)
Maxima does not have a built-in function for the base 10 logarithm or other bases. log10(x) := log(x) / log(10) is a useful definition.

Saturday, July 14, 2012

Maxima/wxMaxima - solving for the roots of a transcendental equation

Ok, so something is wrong with my Python.  I think Spyder is giving me some fits in Ubunt for somereason.  Anyways, luckily I have Maxima and Sage to fall back on.  In order to solve for the roots of a transcendental equation, I provide a following example.

The equation I want to solve is:

\[ \tan \left( \tfrac{1}{2} C d^2 \right) - \tan \left( \tfrac{1}{2} C a^2 \right) = 0 \]

where \( \deta \) is given.  I first plotted it to make sure it did in fact show trends of a root or roots for \( \delta = 0.5\).

delta:0.5;
eqn(x):= tan(0.5*x*(delta^2)) - tan(0.5*x);
plot2d(eqn, [x, 0, 20],[y, -1, 1]);

So, yup, it definitely has roots.  The first root is actually at zero, but this is trivial in my case.  So I am interesting in the second root.  It seems to be around 8.  I choose the interval for the root finder to look on as 7.8 to 8.5.

find_root(tan(0.5*x*(delta^2)) - tan(0.5*x), x, 7.8, 8.5);
8.377580409572781

So the root found is the bold number above!

Friday, February 3, 2012

Natural log and trig relation: -ln(tan(phi/2)) = ln(csc(phi) + cot(phi)) and the integrals of csc^3(phi) and csc(phi)

\[

- \ln \left( \tan \dfrac{\phi}{2} \right) = - \ln \left( \dfrac{\sin \phi}{1 + \cos \phi} \right) = \ln \left( \dfrac{1 + \cos \phi}{\sin \phi} \right) = \ln \left( \dfrac{1}{\sin \phi} + \dfrac{\cos \phi}{\sin \phi} \right)

\]
\[

= \ln \left( \csc \phi + \cot \phi \right)

\]

However, I recently was using this in an analysis, was checking some work, and noticed that:


\[

\ln \left( \tan \dfrac{\phi}{2} \right) = \ln \left( \dfrac{1 - \cos \phi}{\sin \phi} \right) =  \ln \left( \csc \phi - \cot \phi \right)

\]

I looked up the formulas again and became quite confused.


The tangent half angle relations are:

\[ \tan \dfrac{\phi}{2} = \dfrac{1 - \cos \phi}{\sin \phi}\]

and

\[ \tan \dfrac{\phi}{2} = \dfrac{\sin \phi}{1 + \cos \phi}\]

So, I guess the relation is:

\[ \ln \left( \csc \phi - \cot \phi \right) = -\ln \left( \csc \phi + \cot \phi \right) \]

Yup, it is confirmed:



Links to the tangent half angle:

http://en.wikipedia.org/wiki/Tangent_half-angle_formula

http://planetmath.org/encyclopedia/DerivationOfHalfAngleFormulaeForTangent.html


However, my problem originates to the integral of \( \csc^3 \phi \).  This integral can be solved by (at least how I did it)

\[ \int \csc^3 \phi \mathrm{d} \phi \]

First, utilize integration by parts

\[ \mathrm{d}v = \csc^2 \phi \mathrm{d} \phi \]

\[ u = \csc \phi \]

\[ v = -\cot \phi \]

\[ \mathrm{d}u = - \csc \phi \cot \phi \mathrm{d} \phi \]

The formula for integration by parts is

\[ uv - \int v \mathrm{d}u \]

Substituting in the correct values gives

\[ -\csc \phi \cot \phi - \int \csc \phi \cot^2 \phi \mathrm{d} \phi \]

Using the trigonometric identity \( \cot^2 \phi = \csc^2 \phi - 1 \) transforms the relation to

\[ -\csc \phi \cot \phi - \int \csc \phi \left( \csc^2 \phi - 1 \right) \mathrm{d} \phi \]

Multiplying through we obtain

\[ -\csc \phi \cot \phi - \int \csc^3 \phi - \csc \phi \mathrm{d} \phi \]

Separating the RHS integrals produces

\[ -\csc \phi \cot \phi - \int \csc^3 \phi \mathrm{d} \phi +  \int \csc \phi \mathrm{d} \phi \]

Recall that this whole relation is equal to \(  \int \csc^3 \phi \mathrm{d} \phi \) which yields

\[  \int \csc^3 \phi \mathrm{d} \phi = -\csc \phi \cot \phi - \int \csc^3 \phi \mathrm{d} \phi +  \int \csc \phi \mathrm{d} \phi \]

At first this seems counter-intuitive and does not seem to help.  However, if you collect the integrals of \( \csc^3 \phi \) the equation becomes clearer as where to go next.  So collecting the \( \csc^3 \phi \) integrals to the LHS, we obtain

\[  2 \int \csc^3 \phi \mathrm{d} \phi = -\csc \phi \cot \phi +  \int \csc \phi \mathrm{d} \phi \]

Then we can divide by two and evaluate the left hand side which gives us

\[  \int \csc^3 \phi \mathrm{d} \phi = \dfrac{1}{2} \left[ -\csc \phi \cot \phi +  \int \csc \phi \mathrm{d} \phi \right] \]

Okay, so this is where my problem began.  I've found two answers for this integral of \( \csc \phi \).  The first is the same as the one I got by evaluating the integral of \( \csc \phi \)

\[  \int \csc^3 \phi \mathrm{d} \phi = \dfrac{1}{2} \left[ -\csc \phi \cot \phi - \ln | \csc \phi - \cot \phi | \right] \]

where

\[ \int \csc \phi \mathrm{d} \phi = - \ln | \csc \phi - \cot \phi | \]

according to: http://www.math.com/tables/integrals/more/csc.htm

However, here: http://answers.yahoo.com/question/index?qid=20080225213623AAUQMz6, the answer is

\[ \int \csc \phi \mathrm{d} \phi = - \ln | \csc \phi + \cot \phi | \]

?? (I'll have to check these to make sure there isn't a mistake.

To make matters worse here: http://answers.yahoo.com/question/index?qid=20080623173220AAyRTys we get an answer for \( \int \csc^3 \phi \mathrm{d} \phi \) equal to

\[  \dfrac{1}{2} \left[ -\csc \phi \cot \phi + \ln | \csc \phi - \cot \phi | \right] \]

??? What the heck is going on?! (Again, when I get the time I will check these answers since the formulation is given.  However, this does give the final answer I am looking for which is

\[  \dfrac{1}{2} \left \lbrace -\csc \phi \cot \phi + \ln \left[ \tan \left( \dfrac{\phi}{2} \right) \right] \right \rbrace \]

However again, the relation I first displayed above shows that

\[  \dfrac{1}{2} \left[ -\csc \phi \cot \phi - \ln | \csc \phi + \cot \phi | \right] \]

\[ = -\dfrac{1}{2} \left[ \csc \phi \cot \phi + \ln | \csc \phi + \cot \phi | \right] \]


\[ = -\dfrac{1}{2} \left[ \csc \phi \cot \phi - \ln | \csc \phi - \cot \phi | \right] \]



\[ = \dfrac{1}{2} \left[ -\csc \phi \cot \phi + \ln | \csc \phi - \cot \phi | \right] \]

So this tells me that the second link should be correct!  The reason for this post originates to me trying to change the angle \( \phi \) from spherical polar coordinates to cylindrical polar coordinates \( \left( r, z \right) \) through the relation \( \phi = \tan \left( r/z \right) \)and \( R^2 = r^2 + z^2 \).  Thus, I am posting this to keep myself from become confused!

Thursday, February 2, 2012

mlab — matplotlib.mlab

mlab — Matplotlib v1.1.0 documentation
Numerical python functions written for compatability with MATLAB commands with the same names.

Tuesday, January 31, 2012

SymPy - Python library for symbolic mathematics

http://sympy.org/en/index.html

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.


Sage - 2D plot - simple plot, more than one function on the same plot, axes limits, change color of function in graph

There are many options when plotting in Sage.  Here is a simple example.

alpha = 30*pi/180
show(alpha)
show(float(alpha))
f = (arcsin(alpha))^2 + log(tan(alpha/2)) - arcsin(alpha)*arctan(alpha)
show(f)
show(float(f))
g = (1/(0.7*sin(x)))*sqrt(1 + ((pi)^(-2))*((0.7*sin(x))^2)*(f - csc(x)*tan(x/2) - log(tan(x/2))))
p = plot(g, (0, alpha))
show(p, ymin = 0, ymax = 20)

In Sage, the variable x is automatically known/defined.  I then create a simple function similar to how I created alpha and f.  I next equal p to the plot since I wanted to change the y axis range manually which you can do through the show command (or this can also be done in the plot command as well).



Here is another example of a 2D plot.  This one shows how to plot a couple of functions.

alpha = 30*pi/180
show(alpha)
show(float(alpha))
z = 0.5
r_max = z*tan(alpha)
show(r_max)
show(float(r_max))
lamb_da = (csc(alpha))^2 - (cot(alpha))*(csc(alpha)) + log(tan(alpha/2))
show(float(lamb_da))
cig_ma_c = 1
r = var('r')

psee = (1/2*pi)*(cig_ma_c)*(r^2)*(lamb_da + (z/r)*sqrt(1 + (z/r)^2) - log(sqrt(1 + (z/r)^2) - z/r) - 1 - (z/r)^2)

lamb_da_bi = (csc(alpha))^2 - (cot(alpha))*(csc(alpha)) + log(tan(alpha)/2)

show(float(lamb_da_bi))

psee_bi = (1/2*pi)*(cig_ma_c)*(r^2)*(lamb_da_bi + (z/r)*sqrt(1 + (z/r)^2) - log(r/(2*z)) - 1 - (z/r)^2)

p1 = plot(psee, (r, 0, r_max))

p2 = plot(psee_bi, (r, 0, r_max), color ='green')

show(p1 + p2)



Sage - displaying a float decimal point

In Sage, like many other mathematics software, uses either a float command or you can simply put a "." in your value to display decimals.

f = (arcsin(alpha))^2 + log(tan(alpha/2)) - arcsin(alpha)*arctan(alpha)
show(f)
show(float(f))

Screenshot:


Monday, January 30, 2012

Sage - Declaring a value

So first things first.  I simply want to declare a value for something.  In this case I want alpha to equal some number.

alpha = 30*pi/180

show(alpha)

Hit evaluate and it gives: (1/6)*pi It works!


Sunday, January 29, 2012

Maxima and wxMaxima in Windows 7

I am forced to use Windows every now and then, but I have recently found out that some of my favorite software works for Windows and is relatively easy to install.  Maxima is very easy, as you just download and run the Windows installer from here:  http://www.windows7download.com/win7-maxima/kqcjkmcz.html

Installing Maxima for Windows also installs wxMaxima (and Xmaxima if wanted) and gnuplot.  Here is a screenshot.


Friday, January 27, 2012

Please Make A Note: LaTeX: Vertical Spacing in Multiline Equations

Please Make A Note: LaTeX: Vertical Spacing in Multiline Equations: "\setlength{\jot}{12pt}"

Haha, I was searching if \vspace*{} worked or not in the align environment and stumbled across my friend's blog post. This works! However, for local entries I had to put yNot's suggestion from the comments where after the line breaks you put [12 pt], for example.

\begin{align}\setlength{\jot}{12pt}
\psi_{yyyy} = \alpha &R \left[ \psi_{yyt} + \left( y + \psi_y \right) \psi_{xyy} - \psi_{yyy} \psi_x \right] - 2 \alpha^2 \psi_{xxyy} \nonumber \\[12 pt] &+ \alpha^3 R \left[ \psi_{xxt} + \left( y + \psi_y \right) \psi_{xxx} - \psi_x \psi_{xxy} \right] - \alpha^4 \psi_{xxxx}
\end{align}

before:

after:

Monday, January 23, 2012

LaTeX - Math - nth power root

In order to write an nth power root the command is:

\sqrt[n]{k}

\[\sqrt[3]{x}\]

where n is the power of the root and k is the expression within the root symbol.

Found this and also other LaTeX help here: http://web.mit.edu/rsi/www/2003/help/faq/latex/#faq9

Monday, December 26, 2011

Differentiation in Maxima

Mathematica is a great piece of software.  You can do many things with it mathematically.  However, it is not free and not always available.  I am trying to find some replacements that are free, cross-platform, readily available, relatively easy to use.

I have been trying at Maxima using the wxMaxima interface and have been quite pleased with it.  So far I have been able to graph functions related to my research.  However, Mathematica is pretty powerful as you can do differentiation, integration, etc. with ease.  Just recently, I tried the differentiation ability of Maxima.  It is possible to do differentiation in Maxima.  So far I have only tried a simple polynomial.  The command for differentiation is:

diff(expr, x)

Here is a screen shot of some examples I did.


Now if I could figure out if and how to simplify the last expression.  If Maxima can do that, then it is a very viable option to Mathematica for several things.

I found this differentiation command at http://mathandmultimedia.com/tag/maxima-tutorial/

Update:  So as you might have noticed I got a great tip in the comments on how to simplify this fraction.  The tip comes from Mike Croucher who has a great, insightful blog http://www.walkingrandomly.com/ which I must admit I don't read often enough due to time but check it out anyways.  It is well established and post similar topics yet more advanced and involved examples.


Friday, December 23, 2011

Legendre polynomials of the first kind, plots of degrees n = 0, 1, 2, 3, 4, 5

\( P_0 \left( x \right) = 1 \)


\( P_1 \left( x \right) = x \)


\( P_2 \left( x \right) = \dfrac{1}{2} \left( 3 x^2 - 1 \right) \)


\( P_3 \left( x \right) = \dfrac{1}{2} x \left( 5 x^2 - 3 \right) \)


\( P_4 \left( x \right) = \dfrac{1}{8} \left( 35 x^4 - 30 x^2 + 3 \right) \)


\( P_5 \left( x \right) = \dfrac{1}{8} x \left( 63 x^4 - 70 x^2 + 15 \right) \)





\( P_0 \left( x \right), P_1 \left( x \right), P_2 \left( x \right), P_3 \left( x \right), P_4 \left( x \right), P_5 \left( x \right) \)





Code for last graph in wxMaxima:

plot2d([legendre_p(0, x), legendre_p(1, x), legendre_p(2, x),legendre_p(3, x), 
legendre_p(4, x), legendre_p(5, x)], [x, -2, 2], [y, -2, 2], 
[legend,"P_0 (x) = 1","P_1 (x) = x","P_2 (x) = (1/2)*(3*x^2 - 1)",
"P_3 (x) = (1/2)*x*(5*x^2 - 3)","P_4 (x) = (1/8)*(35*x^4 - 30*x^2 + 3)",
"P_5 (x) = (1/8)*x*(63*x^4 - 70*x^2 + 15)" ], [ylabel,"P_n (x)"], [gnuplot_preamble,"set key bottom"]);

Legendre - DE, functions and polynomials of the first and second kind, associated Legendre functions

Legendre equation, function, and polynomial links (also contains properties and more).

http://mathworld.wolfram.com/LegendrePolynomial.html

http://mathworld.wolfram.com/LegendreDifferentialEquation.html

http://mathworld.wolfram.com/LegendreFunctionoftheFirstKind.html

http://mathworld.wolfram.com/LegendreFunctionoftheSecondKind.html

http://reference.wolfram.com/mathematica/tutorial/OrthogonalPolynomials.html

http://en.wikipedia.org/wiki/Legendre_polynomials

http://en.wikipedia.org/wiki/Legendre_function

The Legendre differential equation is of the form:

\[ \dfrac{\mathrm{d}}{\mathrm{d}x} \left[ \left( 1 - x^2 \right) \dfrac{\mathrm{d} F}{\mathrm{d}x} \right] + n \left( n + 1 \right) F \]

or

\[ \left( 1 - x^2 \right) F'' - 2 x F' + n \left( n + 1 \right) F = 0  \]

which has the general solution of

\[ C_1 P_n \left( x \right) + C_2 Q_n \left( x \right) \]

where \( P_n \left( x \right) \) is the Legendre function of the first kind, \( Q_n \left( x \right) \), and \( n \) is a non-negative integer which is also the degree of the Legendre polynomial.

A more general equation is the associated Legendre differential equation in the form of:

\[ \left( 1 - x^2 \right) F'' - 2 x F' + \left[ n \left( n + 1 \right) - \dfrac{m^2}{1 - x^2} \right] F = 0 \]

which has the general solution of

\[ C_1 P_n^m \left( x \right) + C_2 Q_n^m \left( x \right) \]

where \( P_n \left( x \right) \) is the associated Legendre function of the first kind, \( Q_n \left( x \right) \) is the associated Legendre function of the second kind, \( n \) is a non-negative integer, the degree of the Legendre polynomial, and \( m \) is also a non-negative integer which determines the degree of the Legendre functions/polynomials.

When the degree is zero, \( m = 0 \), the associated Legendre functions,  \( P_n^0 \left( x \right) \) and \( Q_n^0 \left( x \right) \), return the regular Legendre functions, \( P_n \left( x \right) \) and \( Q_n \left( x \right) \)

The Legendre DE can be solved by a power series expansion method also called the Frobenius method.

The difference between Legendre polynomials and functions is that when the \( n \)th-degree is an integer the Legendre function converges to a polynomial on the interval \( -1 \le x \le 1 \).

For associated Legendre functions of odd integers where \( m \le n \), the function contains \( \sqrt{1 - x^2} \) which demotes the function from a polynomial.

The Legendre equation usually arises in physics problems when the separation of variables method is applied the PDE Laplace's equation in spherical polar coordinates.

\[ \dfrac{1}{\sin \phi} \dfrac{\mathrm{d}}{\mathrm{d}\phi} \left( \sin \phi \dfrac{\mathrm{d} F}{\mathrm{d}\phi} \right) +  \left[ n \left( n + 1 \right) - \dfrac{m^2}{\sin^2 \phi} \right] F = 0 \]

Where \( \phi \) is the colatitudinal angle and the substitution \( x = \cos \phi \) recovers the previous Legendre equation version.


Derivative Tables and Properties - links

Here are some useful links when you need that derivative you always forget.

http://www.math.com/tables/derivatives/tableof.htm

http://calculus.info/tables/derivative/derivative.html

http://en.wikibooks.org/wiki/Calculus/Tables_of_Derivatives

http://www.math.com/tables/derivatives/identities.htm

Wednesday, November 30, 2011

Bessel function and equation properties (links)

Some useful links on Bessel functions, the equation, and their properties.  Later on down the road, I will try to post the properties and discuss the Bessel equation and the Bessel functions for archiving purposes.

For now, here are the links:

http://en.wikipedia.org/wiki/Bessel_function

http://www.efunda.com/math/bessel/bessel.cfm

http://mathworld.wolfram.com/BesselFunction.html

http://mathworld.wolfram.com/BesselDifferentialEquation.html