Mathematica: Function output to array

Click For Summary
SUMMARY

The discussion focuses on generating an array of ordered pairs from a defined function in Mathematica. The user defines a function, F1, to calculate y values based on the linear equation y = mx + b. To create a list of ordered pairs for graphing, the user utilizes a second function, F1Pair, and applies the Map function to iterate over a range of x values. The final output is a list of pairs suitable for plotting, specifically using the syntax Map[F1Pair[#, 2, 1] &, Range[0, 10]].

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of linear equations in the form y = mx + b
  • Knowledge of the Map function in Mathematica
  • Basic graphing concepts and techniques
NEXT STEPS
  • Explore advanced function definitions in Mathematica
  • Learn about plotting functions and data in Mathematica
  • Investigate the use of Table function for generating data sets
  • Study the application of ListPlot for visualizing ordered pairs
USEFUL FOR

Mathematica users, data analysts, and educators looking to visualize linear functions and generate data sets for graphing purposes.

noon0788
Messages
21
Reaction score
0
Hello everybody! I've got a Mathematica problem that I've been working on for a while but can't seem to solve. My code is pretty involved, so I'll simplify the dilemma for you.

F1 := Function[{x,m,b},
y = m*x+b;
Print[y]
]

I have a function called F1. If I call it like so...

F1[2,2,1]

I get an output of 5. What I'd like to do, is graph this function. I know how to graph y=mx+b, but I want to graph a bunch of ordered pairs generated by this function. I want to put in x values, get out y values, and plot them. I was trying to use an array to do this, but it hasn't been cooperating with me. How do I use this function, F1, to get something like this -> {{0,1},{1,3},{2,5},{3,7},{4,9},{5,11},{6,13},{7,15},{8,17},{9,19},{10,21}}? Thanks for your help!
 
Physics news on Phys.org
F1Pair := Function[{x, m, b}, {x, m*x + b}];
Map[F1Pair[#, 2, 1] &, Range[0, 10]]
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 2 ·
Replies
2
Views
2K