I am developing a toy application to teach me how to generate a more complex CDF app. The current toy app is taking integral.
Manipulate[
DynamicModule[{f = Sin[x], xR = 1, xL = 0, Res = 0.4596976941},
Column[{
InputField[Dynamic[xL], Number],
InputField[Dynamic[xR], Number],
InputField[Dynamic[f]],
Button["Calculate",
Dynamic[Res =
NumberForm[NIntegrate[f, {x, xL, xR}, WorkingPrecision -> nw], np];]],
InputField[Dynamic[Res]],
Dynamic[If[fp == True, Plot[f, {x, xL, xR}]]]}]],
{{np, 10, "NumberFormat"}, 10, 30, 1},
{{nw, 16, "WorkingPrecision"}, 10, 30, 1},
{{fp, True, "Plot the function"}, {False, True}, Checkbox}]
But there are some of the problems that I am trying to solve.
I would like to have name tags on the left or top of each of the input fields.
FieldHint
does not work.Manipulate[ DynamicModule[{f, xR, xL, Res}, Column[{ InputField[Dynamic[xL], Number, FieldHint -> "Lower Limit"], InputField[Dynamic[xR], Number, FieldHint -> "Upper Limit"], InputField[Dynamic[f], FieldHint -> "Function"], InputField[Dynamic[Res], FieldHint -> "Result"], Button["Calculate", Dynamic[Res = NumberForm[NIntegrate[f, {x, xL, xR}, WorkingPrecision -> nw], np];]], Dynamic[If[fp == True, Plot[f, {x, xL, xR}]]]}]], {{np, 10, "NumberFormat"}, 10, 30, 1}, {{nw, 16, "WorkingPrecision"}, 10, 30, 1}, {{fp, False, "Plot the function"}, {False, True}, Checkbox}]
And I think having name tags would look much better even if the FieldHint approach were made to work.
I tried to make the plotting also part of the button, but it is not working (I simply moved the
]
at the end of theButton
expression to the end of the plotting). Also, when I don't have the plot, I get aNull
, which I don't like. Is there a way of getting rid off that? And how can I make the size of the plot bigger?The last thing I could not figure it out is to limit
xL
andxR
inputs to a number. I specified in the input field that the input is number but when I enter something not a number, I get an error. I expected it simply not to update (according to help documentation, "The input field will not be updated if the input is not of the specified type")
FieldHint
looks like a bug: evenInputField["", Expression, FieldHint -> "Hint"]
does not work. Have you reported it? $\endgroup$