About 100,000 results
Open links in new tab
  1. How do I fit a sine curve to my data with pylab and numpy?

    More userfriendly to us is the function curvefit. Here an example: import numpy as np from scipy.optimize import curve_fit import pylab as plt N = 1000 # number of data points t = np.linspace(0, 4*np.pi, N) data = 3.0*np.sin(t+0.001) + 0.5 + np.random.randn(N) # create artificial data with noise guess_freq = 1 guess_amplitude = 3*np.std(data)/(2**0.5) guess_phase = 0 guess_offset = np.mean ...

  2. Python: Decimals with trigonometric functions - Stack Overflow

    Jun 1, 2012 · Long Answer - Python decimal.Decimal supports exp() function that takes only a real number argument (unlike exp() in R language) and computes the infinite series only up to the number of terms based on configured precision (decimal.Decimal.getcontext().prec). Currently the even terms compute cosh() and the odd terms compute sinh().

  3. python - Trigonometric Interpolation using the Discrete Fourier ...

    If you want to create a continuous function as a summation of shifted sine functions, follow the equation for the Fourier series, with A_n and Φ_n given by the amplitude and phase of the elements of the DFT.

  4. python - Calculating inverse trigonometric functions with formulas ...

    May 31, 2017 · Unfortunately i could not find any sources that would help me interpret inverse trigonometric function formulas for Python. I have also tried putting sin(x) to the power of -1 (sin(x) ** -1) which didn't work as expected. What could be the best solution to do this in Python (In the best, I mean simplest with similar accuracy as Taylor series)?

  5. How can I convert radians to degrees with Python?

    Mar 26, 2012 · @lucase.62, Mark is correct. The cos function operates on an angle as the input, 1 in your example. On your calculator, this angle is in degress, in Python, this angle must be given in radians. The return value, x in your example, is a dimensionless number. On your calculator you have calculated the cos of 1 degree.

  6. math - Inverse Cosine in Python - Stack Overflow

    Aug 4, 2020 · Above, I asked python to fetch me the cosine of a 5 radian angle, and it gave me .28~ Great, below I'll ask python to give me the radian which has a .28~ cosine. Should be 5, right? It literally just told me it was. >>> math.acos(0.28366218546322625) 1.2831853071795865 Wrong! Python returns 1.28~ radians.

  7. Trigonometric Function Graphing with python turtle.

    Feb 19, 2017 · I'm trying to graph trigonometric functions using python turtle, but it doesn't allow me to multiply a float with any built-in function (sine, cosine, tangent,.etc). I want to do A math.sin((b x)-c)+d for the basic graphing formula.

  8. Python: Derivative of trig functions - Stack Overflow

    Nov 27, 2018 · I am trying to identify what the problem with the differentiation of trig functions in Python. I use scipy.misc.derivative. Correct case: def f(x): return math.sin(x) y=derivative(f,5.0,dx=1e-9) print(y) This will give a math.cos(5) right? My problem is here. Since python accepts radians, we need to correct what is inside the sin function.

  9. how to solve trigonometric equations on python - Stack Overflow

    Aug 9, 2018 · Sympy - got two solutions from trigonometric equation, I was expecting only one 1 How to solve non-linear system of trigonometric equations in Python (which MATLAB can solve easily)

  10. trigonometry - Python: Calculate sine/cosine with a precision of up …

    Jul 18, 2017 · Question is pretty self-explanatory. I've seen a couple of examples for pi but not for trigo functions. Maybe one could use a Taylor series as done here but I'm not entirely sure how to implement that in python. Especially how to store so many digits. I should mention: this ideally would run on vanilla python i.e. no numpy etc. Thanks!

Refresh