Mathematica Mathematica: Function output to array

Click For Summary
The discussion centers on a Mathematica problem involving the creation of a function, F1, which calculates the output of a linear equation y = mx + b. The user successfully calls this function with specific parameters, yielding an output of 5 for the input values 2, 2, and 1. The main goal is to generate and graph a series of ordered pairs from this function, specifically for x values ranging from 0 to 10. The user seeks assistance in utilizing the function to produce a list of ordered pairs in the format {{x, y}}. A proposed solution involves defining a new function, F1Pair, which pairs x values with their corresponding y values calculated from the linear equation. The user suggests using the Map function to apply F1Pair across a range of x values, which effectively generates the desired output of ordered pairs for graphing.
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 0 ·
Replies
0
Views
602
  • · 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
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K