Message Boards Message Boards

1
|
5503 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How do I hold arguments for simplification

Posted 9 years ago

Hi,

I am trying to create a simple "Manipulate" that takes in 2 fractions and then adds them. When I input the fractions I don't want them to simplify until they are added together. In other words, I just want the answer in simplified form. But the moment I input them and press enter... the fractions themselves reduce to simplified form. Is there a way to stop this from happening?

Manipulate[Row[{a, "+", b, "=", Simplify[a + b]}],
 Row[{Control[{{a, 1/2, ""}}], Control[{{b, 1/2, ""}}]}]]
POSTED BY: Michael McCain
2 Replies

Thank you Kuba! This makes sense.

I noticed that if I used "/" instead of "Control+/" it works but does not convert to traditional form in either the input or output. Is there a way to fix this so it converts? The code below coverts to traditional form... but does not use boxes. Is there a way to convert with boxes?

Manipulate[Row[{a, "+", b, "=", Simplify[a + b]}], 
 Row[{Control[{{a, 1/2, ""}}], Control[{{b, 1/2, ""}}]}]]
POSTED BY: Michael McCain

You can prevent this by working with boxes for example:

DynamicModule[{a = 1, b = 2},
 Column[{
   Dynamic @ DisplayForm @  RowBox[{a, "+", b, "=",  Plus @@ (ToExpression /@ {a, b}) // Simplify}],

   Row[{
     InputField[Dynamic[a], Boxes],
     InputField[Dynamic[b], Boxes]}]

   }]
 ]

enter image description here

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract