Tranformations on Functions

Arithmetic, Decimals and Fractions, Prealgebra, Algebra I, Algebra II, Geometry, Trigonometry, Precalculus, Calculus, Discrete Math, Probability and Statistics, etc.
Forum Rules
By using the Wolfram Faculty Program Forum, you agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, or sexually oriented material. Wolfram Faculty Program Forum administrators have the right to remove, edit, move or close any topic at any time should we see fit.

Personal Information: Posts in this forum may be viewed by non-members; however, the forum prohibits non-members from viewing your profile. Although your email address is hidden from both non-members and members, your account is initially configured to allow members to contact you via email through the forum. If you wish to hide your profile, or prohibit others from contacting you directly, you may change these settings by updating your profile through the User Control Panel.

Attachments: Attachments are not currently enabled on this forum. To share a file with others on this site, simply upload your file to the online storage service of your choice and include a link to the file within your post. If your school does not offer an online file storage and sharing service, the following sites provide free basic online file storage and sharing: Mozy, FilesAnywhere, Adrive, and KeepandShare.

Tranformations on Functions

Postby Andrew_Bayliss » Fri Dec 10, 2010 2:17 pm

I was wondering if anyone could check my code for the following demonstration on transforming functions.

Code: Select all
q[x_]=(x-1)^2-1/;x>=0;Manipulate[Grid[{{TraditionalForm[A func[B x+W]+G]},{Plot[A*func[B*x+W]+G,{x,-6,6},PlotRange->{-6,6},PlotStyle->Thick,ImageSize->550]}},Alignment->Center,Spacings->{4,3}],{{func,n,"Function"},{
n->"f(x) = x",f->"f(x) = x^2", g->"f(x) = x^3", h->"f(x) = Sqrt[x]",k->"f(x) = |x|",j->"f(x) = sin(x)",
s->"f(x) = [x]",t->"f(x) = ln(x)",m->"f(x) = sgn (x)",r->"f(x) = 1/x",q->"f(x) = special"},PopupMenu},{{A,1},-3,3,1/4},{{B,1},-3,3,1/4},{{W,0,"C"},-5,5,.5},{{G,0,"D"},-5,5,.5}]

The problem is that if I take the labels in the PopupMenu (ex "f(x) = x^2"), and I format it within the quotation marks to how I want it to appear in the demonstration with the superscript, using a particular font, font face, and size). When I reopen the file containing the demonstration, the code is all messed up and won't evaluate. I get the following code.

Code: Select all
"f(x) =\!\(\*
StyleBox[SuperscriptBox["x", "2"],
FontFamily->"Times New Roman",

Where the f(x) retains its formatting, but then I get the " \!\(\*..." and it won't evaluate correctly, unless I go back and change everything back. I really like the demonstration, and I have used it a few times in class. However like the previous topic I have no idea why formatting is so hard. If you have any suggestions for improving the code, please let me know.

Andrew Bayliss
User avatar
Posts: 7
Joined: Mon Oct 11, 2010 10:36 pm
Organization: Sparta High School
Department: Mathematics

Re: Tranformations on Functions

Postby telefunkenvf14 » Fri Jul 29, 2011 8:23 pm

Better late than never...

I'm not exactly certain of what all you want formatted in Times, Italic, and 16pt, but using DisplayForm may help. Wrap the (slightly edited) contents of the error message you were receiving in DisplayForm and you get some pretty-printing output in the front end:

Code: Select all
DisplayForm[StyleBox["f(x) = " SuperscriptBox["x","2"],FontFamily->"Times New Roman",FontSize->16,FontSlant->"Italic"]]

Here is a stripped-down version of the code you gave:

Code: Select all
f[x_] = x^2;
     StyleBox[A func[B x + W] + G, FontFamily -> "Times New Roman",
      FontSize -> 16, FontSlant -> "Italic"]]}, {Plot[
     A*func[B*x + W] + G, {x, -6, 6}, PlotRange -> {-6, 6},
     PlotStyle -> Thick, ImageSize -> 550]}}, Alignment -> Center,
  Spacings -> {4, 3}], {{func, f,
   "Function"}, {f ->
     StyleBox["f(x) = " SuperscriptBox["x", "2"],
      FontFamily -> "Times New Roman", FontSize -> 16,
      FontSlant -> "Italic"]]}}, {{A, 1}, -3, 3, 1/4}, {{B, 1}, -3, 3,
   1/4}, {{W, 0, "C"}, -5, 5, .5}, {{G, 0, "D"}, -5, 5, .5}]


User avatar
Posts: 46
Joined: Tue Apr 27, 2010 7:40 pm
Location: Lincoln, NE
Organization: University of Nebraska-Lincoln
Department: Economics

Return to Mathematics and Statistics (Primary/Secondary)

Who is online

Users browsing this forum: No registered users and 1 guest