Function Repository Resource:

FullSimplifyFunction

Source Notebook

Convert a pure function into a simpler form

Contributed by: E. Chan-López, Carlos Francisco Arias Méndez & Ulrich Neumann

ResourceFunction["FullSimplifyFunction"][expr]

applies a full simplification to all Function expressions within expr.

Details and Options

ResourceFunction["FullSimplifyFunction"] threads over lists.
ResourceFunction["FullSimplifyFunction"] operates on subexpressions with head Function, accepting either a single symbol or a list of parameters.
ResourceFunction["FullSimplifyFunction"] takes the same options as FullSimplify.

Examples

Basic Examples (4) 

Use FullSimplifyFunction to simplify a simple Function:

In[1]:=
ResourceFunction["FullSimplifyFunction"][Function[# + #]]
Out[1]=

Use FullSimplifyFunction to simplify a simple function given as a rule:

In[2]:=
ResourceFunction["FullSimplifyFunction"][
 y -> Function[Cosh[#] - Sinh[#]]]
Out[2]=

Use FullSimplifyFunction to simplify a more complicated function:

In[3]:=
ResourceFunction["FullSimplifyFunction"][
 f -> Function[{\[Theta], \[CurlyPhi]}, a*Cos[\[CurlyPhi]] Sin[\[Theta]] - a*Cos[\[Theta]] Sin[\[CurlyPhi]]]]
Out[3]=

Use FullSimplifyFunction to simplify multiple function rules:

In[4]:=
ResourceFunction[
 "FullSimplifyFunction"][{y -> Function[x, 1/2 (E^-x + E^x)], y -> Function[x, (E^x - E^-x)/(E^x + E^-x)]}]
Out[4]=

Scope (2) 

Use FullSimplifyFunction to simplify expressions involving special functions:

In[5]:=
ResourceFunction["FullSimplifyFunction"][
 Function[z, Csc[3 Pi/2] (BesselI[-1/2, z] - BesselK[1/2, z])/2]]
Out[5]=

Use FullSimplifyFunction with more complicated function rules:

In[6]:=
ResourceFunction["FullSimplifyFunction"][
 x -> Function[t, 1/6 E^(-Sqrt[3] t) (3 - 2 Sqrt[3] + 3 E^(2 Sqrt[3] t) + 2 Sqrt[3] E^(2 Sqrt[3] t)) C[1] - (
    E^(-Sqrt[3] t) (-1 + E^(2 Sqrt[3] t)) C[2])/(2 Sqrt[3])]]
Out[6]=

Options (2) 

Use FullSimplifyFunction with Assumptions:

In[7]:=
ResourceFunction["FullSimplifyFunction"][
 a -> Function[
   x, -Log[(1 - E^(x k[1] + (k[1] (2 I \[Pi] C[1]))/k[1]))/k[1]]], Assumptions -> C[1] \[Element] Integers]
Out[7]=

Use FullSimplifyFunction to simplify a function involving an EllipticF using assumptions:

In[8]:=
ResourceFunction["FullSimplifyFunction"][
 Function[x, E^(EllipticF[x, 1])], Assumptions -> -Pi/2 < x < Pi/2]
Out[8]=

Applications (3) 

Use FullSimplifyFunction with the results of DSolve:

In[9]:=
eqns = {Derivative[1][y][x] == y[x] - a z[x], Derivative[1][z][x] == y[x] - z[x], y[0] == 1, z[0] == 4};
DSolve[eqns, {y, z}, x]
Out[10]=

Use FullSimplifyFunction on the solutions:

In[11]:=
s = ResourceFunction["FullSimplifyFunction"][%]
Out[11]=

Verify the solutions:

In[12]:=
AllTrue @@ Flatten[Simplify[ReplaceAll[s][eqns[[1 ;; -3]]]]]
Out[12]=

Solve an initial value problem for an inhomogeneous linear hyperbolic system with constant coefficients:

In[13]:=
pdes = {D[u[x, t], t] == D[v[x, t], x] + 1, D[v[x, t], t] == -D[u[x, t], x] - 1};
ic = {u[x, 0] == Cos[x]^2, v[x, 0] == Sin[x]};
sol = DSolve[{pdes, ic}, {u, v}, {x, t}]
Out[15]=

Use FullSimplifyFunction on the solutions:

In[16]:=
ResourceFunction["FullSimplifyFunction"][sol]
Out[16]=

Verify the solutions:

In[17]:=
AllTrue @@ Flatten[Simplify[ReplaceAll[%][pdes]]]
Out[17]=

Use FullSimplifyFunction in the solutions of the Euler-Lagrange equations governing the motion of a rolling wheel on an inclined plane. In this particular problem, the translational coordinate y and the rotational coordinate θ are treated as independent variables. Define the equation of motion for the translational coordinate and its initial conditions:

In[18]:=
eqny = {2/3 m g Sin[\[Alpha]] - m y''[t] == 0};
In[19]:=
icvy = {y[0] == y0, y'[0] == v0};

The solution for equation of motion using DSolve:

In[20]:=
First@DSolve[Join[eqny, icvy], y, t]
Out[20]=

Apply FullSimplifyFunction:

In[21]:=
ResourceFunction["FullSimplifyFunction"][%]
Out[21]=

Verify the solution:

In[22]:=
Part[ReplaceAll[%][eqny], 1]
Out[22]=

Use the resource function SymbolToSubscript to format some parts of the solution as subscripts:

In[23]:=
ResourceFunction["SymbolToSubscript"][
 ResourceFunction["FullSimplifyFunction"][
  First@DSolve[Join[eqny, icvy], y, t]]]
Out[23]=

The equation of motion for the rotational coordinate and its initial conditions:

In[24]:=
eqn\[Theta] = {1/3 m R g Sin[\[Alpha]] - 1/2 m R^2 \[Theta]''[t] == 0};
In[25]:=
icv\[Theta] = {\[Theta][0] == \[Theta]0, \[Theta]'[0] == \[Omega]0};

The solution for this equation of motion using DSolve:

In[26]:=
First@DSolve[Join[eqn\[Theta], icv\[Theta]], \[Theta], t]
Out[26]=
In[27]:=
ResourceFunction["FullSimplifyFunction"][%]
Out[27]=

Verify the solution:

In[28]:=
Part[ReplaceAll[%][eqn\[Theta]], 1]
Out[28]=

Use SymbolToSubscript to format some parts of the solution as subscripts:

In[29]:=
ResourceFunction["SymbolToSubscript"][
 ResourceFunction["FullSimplifyFunction"][
  First@DSolve[Join[eqn\[Theta], icv\[Theta]], \[Theta], t]]]
Out[29]=

Properties and Relations (2) 

Use FullSimplifyFunction with the resource function SolutionRulesToFunctions:

In[30]:=
First@DSolve[
  Join[{1/3 g m R Sin[\[Alpha]] - 1/2 m R^2 (\[Theta]^\[Prime]\[Prime])[t] == 0}, {\[Theta][0] == \[Theta]0, Derivative[1][\[Theta]][0] == \[Omega]0}], \[Theta][t], t]
Out[30]=
In[31]:=
ResourceFunction["SolutionRulesToFunctions"][%]
Out[31]=

Apply FullSimplifyFunction on the solution:

In[32]:=
ResourceFunction["FullSimplifyFunction"][%]
Out[32]=

Publisher

Ramón Eduardo Chan López

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 02 August 2023

Source Metadata

Related Resources

Author Notes

This function is a generalization of the responses found in a post (titled “Simplifying the exponential expression within the Function”) on the Mathematica StackExchange platform. It incorporates ideas from that discussion and was developed in response to the author's query.

A relevant reference on handling variable scoping using Block can be found in the Stack Overflow Community post, “How to Block Symbols without evaluating them?”, with a significant contribution from Leonid Shifrin.

License Information