Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica - get value of function at certain x

Tags:
  1. Aug 5, 2014 #1
    Hi,

    I am not really sure this is the right topic to post my question in, but it is homework so...

    To my data in txt file I fitted a function ##f(x)## where ##x\in [0,100]##. In the original file I had only 100 points, but now that I have a nice polynomial fit, I can get infinite number of points (on that function).

    And that is exactly what I want to do. For example:

    Code (Text):

    f[0.5]
     
    returns me coordinates. (The argument in the code is parametrization of the fitted function from 0 to 1)

    Now my question is:

    From 100 original points, I need 800. And I have those 800 parameter values exactly defined in another txt file, lets call it values.txt. So the question is: How do I tell Mathematica to evaluate the fitted function at all the parametrization values in values.txt file? :/

    Hopefully you understand what I need. I know it is simple, but I can't find it anywhere.
     
    Last edited by a moderator: Aug 5, 2014
  2. jcsd
  3. Aug 6, 2014 #2
    First - I believe this belongs in one of the homework threads - and someone should move it.

    I don't have Mathematica handy, but once you read the 800 values into an array, I believe you can just f[data_array] and it will generate an array of 800 values, each of which is f applied to an element in data_array.
    Try it out, I can't.
     
  4. Aug 7, 2014 #3
    This topic can be REmoved, not only moved. I found a solution on Mathematica community.

    Thanks anyway!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook