Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Solve a system of trigonometric or hyperbolic equations
ResourceFunction["TrigNSolve"][eqns,vars] numerically solves the trigonometric system eqns in vars. |
ResourceFunction["TrigNSolve"] uses a hybrid symbolic-numeric methodology that, among other things, may use symbolic functions such as Together as well as numeric ones such as N. These have a way of occasionally interfering with one another. Thus there may be systems that require approximate input, or systems that cannot be solved at the default setting of WorkingPrecision. See Possible Issues for an example. It is not known whether there are systems that require exact input in order to get numeric solutions.
A simple trigonometric system of equations:
In[1]:= | ![]() |
Solve it:
In[2]:= | ![]() |
Out[2]= | ![]() |
Check the solutions:
In[3]:= | ![]() |
Out[3]= | ![]() |
Find real solutions for a system of five equations:
In[4]:= | ![]() |
Out[6]= | ![]() |
Check that residuals are small:
In[7]:= | ![]() |
Out[7]= | ![]() |
A system can have variables appearing in trigs or as ordinary variables and can also have radical expressions:
In[8]:= | ![]() |
Out[9]= | ![]() |
Solve a mixed trig-hyperbolic system:
In[10]:= | ![]() |
Out[11]= | ![]() |
Solve a system in trigs and ordinary variables:
In[12]:= | ![]() |
Out[13]= | ![]() |
Numerically solve a difficult trigonometric system and extract real-valued solutions:
In[14]:= | ![]() |
Out[15]= | ![]() |
A nontrivial mixed system:
In[16]:= | ![]() |
Solve it:
In[17]:= | ![]() |
Out[17]= | ![]() |
Use the "Endomorphism" method from NSolve on a large trigonometric system:
In[18]:= | ![]() |
Out[19]= | ![]() |
Extract real-valued solutions:
In[20]:= | ![]() |
Out[20]= | ![]() |
Compare to the default Method→Automatic timing:
In[21]:= | ![]() |
Out[21]= | ![]() |
And to the "Monodromy" method:
In[22]:= | ![]() |
Out[22]= | ![]() |
Timing results strongly suggest that "Homotopy" was used as the Automatic default for this example:
In[23]:= | ![]() |
Out[23]= | ![]() |
TrigNSolve requires that variables appearing in trig functions not also appear as polynomial variables:
In[24]:= | ![]() |
Out[24]= | ![]() |
Some systems cannot be solved in exact form and require numericization in advance:
A nontrivial mixed system:
In[25]:= | ![]() |
Using N we solve it readily:
In[26]:= | ![]() |
Out[26]= | ![]() |
We cannot solve the exact form:
In[27]:= | ![]() |
Out[27]= | ![]() |
Alternatively the exact input can be handled but only at nontrivial WorkingPrecision:
In[28]:= | ![]() |
Out[28]= | ![]() |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License