Consider a function plot like this:
###########
#################
####################
#######################
###########################
#############################
################################
###################################
#####################################
########################################
--------------------------------------------------------------------------------
#####################################
###################################
#################################
#############################
###########################
#######################
#####################
#################
###########
This function plot has been created with the J code below, which is not a solution to this challenge.
([: |: ([: |."1 [: #&'#'"0 [: >. [: - (* 0&>)) ,. '-' ,. [: #&'#'"0 [: <. (* 0&<)) 10 * sin 12.7 %~ i. 80
Your task is to write a function or program that takes as input from an implementation defined source that is not the source code of your entry:
- Two positive integers
- w, the width of the plot
- h, the height of the plot
- Two real numbers
- b, the beginning of the region to plot
- e, the end of the region to plot
- A function f mapping real numbers to real numbers. You may assume that this function does not crash, throw an exception, return a NaN or ±∞ for arguments in the range b to e inclusive. The way in which this function is described is implementation defined, but it should be possible to use any combination of the following:
- floating point constants except NaN and ±∞
- addition
- subtraction
- multiplication
- division
- the ex function
- natural logarithm
- sine and cosine
Your function or program shall return or print out an ASCII art plot with dimensions w × h that looks like plot above and plots f in the range b to e inclusive. The plot shall be scaled so that both the topmost and bottommost line contain a #
sign or a -
. Your output format may diverge from the output format shown above in a meaningful way if that doesn't simplify your solution. In particular, you may exchange #
and -
for other characters that give the impression of black space and horizontal line.
The score of your submission is the number of tokens your program source consists of. String literals count as the length of the string they describe but at least as one point, numeric literals count as ⌈log256(|n|)⌉ where n is the number described by the numeric literal.
An identifier which is either predefined by the language or a library your submission uses or whose name can be exchanged with any other unused name counts as one character. All other identifiers count as their length in characters.
If the programming language your submission is written does not have the concept of a token, it's score is the total number of characters that can't be removed from the source without changing the meaning of the program.
The scoring rules ensure that you can indent your code and use descriptive names for your variables, etc. and lowers the edge of domain-specific languages for golfing.
The winner is the submission with the least score.
sin(x)sin(1000x)
and the line does actually pass through all of those shaded pixels. \$\endgroup\$