# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Solve a system of trigonometric or hyperbolic equations

Contributed by:
Daniel Lichtblau

ResourceFunction["TrigNSolve"][ numerically solves the trigonometric system |

ResourceFunction["TrigNSolve"] also handles hyperbolic functions in the input.

Input can be in the form of trigonometric or hyperbolic polynomials or equations.

ResourceFunction["TrigNSolve"] creates regular polyomials from its input, using a new set of internal variables. It uses NSolve to obtain intermediate solutions in these variables. It then post-processes using arc trigs and arc hyperbolics to solve for the original variables.

ResourceFunction["TrigNSolve"] takes Method and WorkingPrecision options, which it passes to NSolve.

Examples are taken from the Mathematica.StackExchange forum.

Because ResourceFunction["TrigNSolve"] ultimately creates polynomials, it cannot handle mixed variables that appear both in polynomial and in trig form (e.g. *x*^2+Cos[*x*]).

Find real solutions for a system of five equations:

In[1]:= |

Out[3]= |

Check that residuals are small:

In[4]:= |

Out[4]= |

A system can have variables appearing in trigs or as ordinary variables and can also have radical expressions:

In[5]:= |

Out[6]= |

Solve a mixed trig-hyperbolic system:

In[7]:= |

Out[8]= |

Solve a system in trigs and ordinary variables:

In[9]:= |

Out[10]= |

Numerically solve a difficult trigonometric system and extract real-valued solutions:

In[11]:= |

Out[12]= |

Use the "Endomorphism" method from NSolve on a large trigonometric system:

In[13]:= |

Out[14]= |

Extract real-valued solutions:

In[15]:= |

Out[15]= |

Compare to the default Method→Automatic timing:

In[16]:= |

Out[16]= |

And to the "Monodromy" method:

In[17]:= |

Out[17]= |

Timing results strongly suggest that "Homotopy" was used as the Automatic default for this example:

In[18]:= |

Out[18]= |

TrigNSolve requires that variables appearing in trig functions not also appear as polynomial variables:

In[19]:= |

Out[19]= |

- Mathematica StackExchange Example 1
- Mathematica StackExchange Example 2
- Mathematica StackExchange Example 3
- Mathematica StackExchange Example 4
- Mathematica StackExchange Example 5
- Mathematica StackExchange Example 6

Wolfram Language 13.0 (December 2021) or above

- 1.0.1 – 20 June 2024
- 1.0.0 – 17 June 2024

This work is licensed under a Creative Commons Attribution 4.0 International License