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

Mathematica: Function output to array

  1. Jun 15, 2010 #1
    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;

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


    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!
  2. jcsd
  3. Jun 15, 2010 #2
    F1Pair := Function[{x, m, b}, {x, m*x + b}];
    Map[F1Pair[#, 2, 1] &, Range[0, 10]]
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Mathematica Function output Date
Mathematica Cannot do the integral of the Hyper-geometric function? Mar 11, 2018
Mathematica Cannot Plot This Function in Mathematica Feb 26, 2018
Mathematica How to append functions to a list of functions? Oct 8, 2017
Is the integral for current correct? Jul 7, 2017
Mathematica which function would average an output Mar 3, 2005