Find the tangent of any polynomial function at x

Problem:

I’m looking for a catch-all function that I can use to calculate the tangent of any polynomial function at x. I’m indifferent to the language used although JavaScript or Python would be prefered! I should be able to pass in any x value and an array of coefficients in the format, a + bx + cx^2 + dx^3 … and so on.

Example function format:

function findTangent(x, coefficients) {

  // Do differential calculus here.

  return [tangentIntercept, tangentSlope]

}

Example function test:

Say I have the function, y = 2 + 7x + 5x^2 + x^3 and I want to to find the tangent at, x = -2. I could call this function like so, findTangent(-2, [2, 7, 5, 1]) and get a return value like this, [-2, -1] representing the tangent, y = -2 – x.

Notes:

I have looked for an answer on the Math Stackexchange and Google search but all the results are in a mathematical syntax and not code. I want a programmatic solution, I am far more comfortable with loops and if statements than funny symbols and math jargon!

46 thoughts on “Find the tangent of any polynomial function at x”

  1. 649797 107113thank you dearly author , I discovered oneself this internet web site quite valuable and its full of exceptional healthy selective info ! , I as properly thank you for the fantastic food strategy post. 106418

    Reply
  2. 522709 966607I feel other website proprietors need to take this internet site as an model, very clean and wonderful user friendly style and style, as effectively as the content. Youre an expert in this topic! 437121

    Reply
  3. 605673 455056Spot on with this write-up, I actually suppose this internet internet site needs rather much more consideration. most likely be once a lot more to learn a lot more, thanks for that info. 928870

    Reply
  4. 654464 799468The next time I learn a weblog, I hope that it doesnt disappoint me as a lot as this one. I mean, I do know it was my choice to read, nonetheless I in fact thought youd have something attention-grabbing to say. All I hear can be a bunch of whining about something that you could fix for people who werent too busy in search of attention. 918889

    Reply

Leave a Comment