I hope this title isn't misleading, but I am creating 2 programs that ask a user a series of questions in regards to derivatives and plots and I will explain as thorough as possible. I don't have a simple example to demonstrate this so here is what I am creating and where I'm stuck:
1st program: This program asks a user to enter a variable of choice, such as x, y or z (whatever single variable you will want to derive). The next question will ask the user to enter some function, and from the function given, a plot will be created of the original function along with both derivatives.
Clear[var, expr, derivatives, blah, color];
var = Input["Type a variable, such as x, in this window."];
expr = Input["Type an expression to be differentiated in the variable you just typed in the last window."];
g[blah_] = expr /. {var -> blah};
derivatives := {g[var], g'[var], g''[var]}
Plot[{Evaluate@derivatives}, {x, -5, 5}, PlotLegends -> "Expressions"]
Unfortunately I don't know how to include an image of what the plot looks like, but basically it shows the graph of the original function and 2 derivatives, each labeled by a certain color and there is an included legend that corresponds each function to that color.
Now, for my second program I want to ask a user which color corresponds to which function in the plot that is generated. This program should check whether the user's answer is correct and respond accordingly, such as "Nice job" or "Try again", and asks the question again if the user is wrong. I have been given hints to use the command SameQ
but I'm mainly confused about the "color" aspect of this task. The following code I supply below is completely wrong, but I am just trying things. For example:
blue = Input["What is the color of the original function?"];
If[derivatives[[1]] === blue, Print["Great Job"],
While[derivatives[[1]] != blue, blue = Input["Try again; what is the color of the original function?"]]]
I have absolutely no idea how set a color equal to something. Is it even possible?
Any help or tips is much appreciated. If you need clarification I will try my best to do so.