Mathematica - get value of function at certain x

Click For Summary
SUMMARY

The discussion focuses on evaluating a fitted polynomial function in Mathematica at multiple parameter values stored in a text file. The user has a function f(x) and needs to compute its values at 800 specific points defined in a separate file named values.txt. The solution involves reading the values into an array and applying the function directly using f[data_array], which will yield an array of results corresponding to each parameter value.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of polynomial fitting techniques
  • Ability to read data from text files in Mathematica
  • Knowledge of array operations in Mathematica
NEXT STEPS
  • Learn how to perform polynomial fitting in Mathematica
  • Research how to read data from text files in Mathematica
  • Explore array manipulation techniques in Mathematica
  • Study the use of function evaluation on arrays in Mathematica
USEFUL FOR

Students, data analysts, and researchers who are using Mathematica for data analysis and need to evaluate functions at multiple points efficiently.

skrat
Messages
740
Reaction score
8
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:
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, let's 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:
Physics news on Phys.org
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.
 
This topic can be REmoved, not only moved. I found a solution on Mathematica community.

Thanks anyway!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 0 ·
Replies
0
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K