# Finding constants using fsolve

Problem: find $k$ and $c$ given

$\begin{align}
  1 + \sinh^{-1}1 &= k \sinh^{-1}(1/k) + c \;,  \\
  1 + \sinh^{-1}5 &= k \sinh^{-1}(5/k) + c \;.  
\end{align}$

Plan: use `fsolve` from `scipy.optimize`.


```python
import numpy as np
from scipy.optimize import fsolve
```


```python
def func(x):
    """Function of x = (k, c) defined so that when each component is zero we 
        have our solution.  
       No extra arguments need to be passed, so func is simple."""
    k, c = x
    return (
            1. + np.arcsinh(1.) - (k * np.arcsinh(1./k) + c),
            1. + np.arcsinh(5.) - (k * np.arcsinh(5./k) + c)
           )
```


```python
x0 = (0.1, 0.1)   # guesses for k and c
k, c = fsolve(func, x0)
print(f'k = {k:0.2f}, c = {c:0.2f}')
```

    k = 1.00, c = 1.00



```python

```

9ae8ac8716d033339cb51b71645156a8aedc9f6a
ipynb
Jupyter Notebook
2020_week_6/problem_6.12_constants.ipynb
CLima86/Physics_5300_CDL
d9e8ee0861d408a85b4be3adfc97e98afb4a1149
MIT
2020_week_6/problem_6.12_constants.ipynb
CLima86/Physics_5300_CDL
d9e8ee0861d408a85b4be3adfc97e98afb4a1149
MIT
2020_week_6/problem_6.12_constants.ipynb
CLima86/Physics_5300_CDL
d9e8ee0861d408a85b4be3adfc97e98afb4a1149
MIT
Qwen/Qwen-72B
1. YES
2. YES