Joachim
  • Joachim
I have no idea how to start coding the following program in python 3: Write a program to draw a text-based graph of a mathematical function f(x). I don't expect an answer, just general guidelines as to what i need to do...
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
Joachim
  • Joachim
more detailed question: Write a program to draw a text-based graph of a mathematical function f(x). Use axis limits of -10 to 10, with only discrete points plotted. Use nested loops to scan through the entire area of the graph and wherever the (rounded) value of f(x) is equal to the y, output "o" (small letter Oh). Otherwise, output either the appropriate axis character or a space. Remember to import math to use some mathematical functions. To support entering of arbitrary functions, the user must enter a string at first. The Python eval function must then be invoked each time to compute the function value for different values of x.
Joachim
  • Joachim
1 Attachment
anonymous
  • anonymous
ascii graphs; wow :-D turning the command line into a graphing calculator You can probably represent the entire graph as a big long string containing only the axes (made up of '|', '+', and '-' characters), spaces, and newline characters. Once you get a valid function of x from stdin, you can loop over x values from -10 to 10 (with a step of one), plotting circles. for x in xrange(-10, 11) : plot(x, f(x), 'o')

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
http://ideone.com/ezTVc This is how I approached the problem, but my solution has 3 problems: 1. Apart from constant inputs like `3`, the graphs are inverted. 2. Passing things like tan or 1/x yields ZeroDivisonError 3. It's in Python 2 :-D sorry about that. I hope it can guide you to your own working solution :-D
anonymous
  • anonymous
Alright, I've fixed the inverted problem: http://ideone.com/fW4Zc tan(x) and 1/x are still problematic though :(
Joachim
  • Joachim
I have actually managed to figure it out on my one... thanks for your help anyway :D

Looking for something else?

Not the answer you are looking for? Search for more explanations.