How to write a function in mathematica

Introduction Ordinary differential equations are at the heart of our perception of the physical universe. For this reason numerical methods for their solutions is one of the oldest and most successful areas of numerical computations. It would be very nice if discrete models provide calculated solutions to differential ordinary and partial equations exactly, but of course they do not. In fact in general they could not, even in principle, since the solution depends on an infinite amount of initial data.

How to write a function in mathematica

The Jacobi elliptic functions sn and cn are analogous to the trigonometric functions sine and cosine. They come up in applications such as nonlinear oscillations and conformal mapping.

Unfortunately, there are multiple conventions for defining these functions. The purpose of this post is to clear up the confusion around these different conventions. The image above is a plot of the function sn [1]. Modulus, Parameter, and Modular Angle Jacobi functions take two inputs.

We typically think of a Jacobi function as being a function of its first input, the second input being fixed. This second input is a "dial" you can turn that changes their behavior.

There are several ways to specify this dial. I started with the word "dial" rather than "parameter" because in this context parameter takes on a technical meaning, one way of describing the dial.

In addition to the "parameter," you could describe a Jacobi function in terms of its modulus or modular angle. This post will be a Rosetta stone of sorts, showing how each of these ways of describing a Jacobi elliptic function are related.

Abramowitz and Stegunfor example, write the Jacobi functions sn and cn as sn u m and cn u m. It would be easier to remember if m stood for modulus, but that's not conventional. Instead, m is for parameter and k is for modulus. As any one of these three goes to zero, the Jacobi functions sn and cn converge to their counterparts sine and cosine.

So whether your dial is the parameter, modulus, or modular angle, sn converges to sine and cn converges to cosine as you turn the dial toward zero. So if your dial is the parameter or the modulus, it goes to 1. In either case, as you turn the dial to the right as far as it will go, sn converges to hyperbolic secant, and cn converges to the constant function 1.

Quarter Periods In addition to parameter, modulus, and modular angle, you'll also see Jacobi function described in terms of K and K'.

These are called the quarter periods for good reason. The functions sn and cn have period 4 K as you move along the real axis, or move horizontally anywhere in the complex plane. They also have period 4 iK'. That is, the functions repeat when you move a distance 4 K ' vertically [2]. The quarter periods are a function of the modulus.

The quarter period K along the real axis is The function K m is known as "the complete elliptic integral of the first kind. Yes, it's an angle, but it's called an amplitude.

When we said above that the Jacobi functions had period 4 K, this was in terms of the variable u. Jacobi Elliptic Functions in Mathematica Mathematica uses the u convention for the first argument and the parameter convention for the second argument.

The Mathematica function JacobiSN[u, m] computes the function sn with argument u and parameter m. Similarly, JacobiCN[u, m] computes the function cn with argument u and parameter m. We haven't talked about the Jacobi function dn up to this point, but it is implemented in Mathematica as JacobiDN[u, m].

The function that computes the quarter period K from the parameter m is EllipticK[m]. The function K m is implemented in Python as scipy. Related posts [1] The plot was made using JacobiSN[0. It's the smallest vertical period for cn, but 2 iK ' is the smallest vertical period for sn.

Read More From DZone.This note describes making a simple package in Mathematica. An example package that contains one function is made showing how to save it and load it into Mathematica and to update it again by adding a second function to it. Writing a Mathematica command The input line above is an example of writing the definition of y as a cubic polynomial in x.

how to write a function in mathematica

There are two items you should notice in the above command that are peculiar to the Mathematica program. The Wolfram Language has a very general notion of functions, as rules for arbitrary transformations. Values for variables are also assigned in this manner.

When you set a value for a variable, the variable becomes a symbol for that value. The Mathematica function JacobiSN[u, m] computes the function sn with argument u and parameter m. In the notation of A&S, sn(u | m).

Similarly, JacobiCN[u, m] computes the function cn with. May 28,  · To find the range of a function in math, first write down whatever formula you’re working with. Then, if you’re working with a parabola or any equation where the x-coordinate is squared or raised to an even power, use the formula -b divided by 2a to get the x- and then rutadeltambor.com: K.

Mathematica functionality: the built-in function N[expression,nd] returns (more precisely, attempts to return) the numerical value of an arbitrary suitable Mathematica expression with nd - digit precision.

Function—Wolfram Language Documentation