Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Using manipulate with user entered variables and functions
Replies: 2   Last Post: Jun 29, 2013 4:49 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 906
Registered: 10/29/11
Re: Using manipulate with user entered variables and functions
Posted: Jun 12, 2013 5:27 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Manipulate[
Module[{
var = Union[
Cases[f, _Symbol?(! NumericQ[#] &),
Infinity]]},
Grid[{HoldForm[D["f", #]] & /@ var,
Simplify[D[f, #] & /@ var]},
Frame -> All,
FrameStyle -> {LightGray, Thin}]],
{f, {
x (x^2 + y^3),
x*Sqrt[x^2 + y^2 + z^2],
Sin[(x^2 - t)]/(x (y^2 + z^2))},
ControlType -> PopupMenu}]



Bob Hanlon




On Thu, May 23, 2013 at 4:05 AM, <nmueggen@gmail.com> wrote:

> I am trying to create a program through which a user can enter a number of
> variable names and a function of those variables. The program then
> performs calculations based on derivatives of the function with respect to
> the entered variables. Eventually this will become a tool for error
> propagation in an undergraduate physics lab.
>
> The following simple program allows a user to enter two variables and a
> function of those variables. It then calculates the partial derivatives of
> the function with respect to each of the variables.
>
> Manipulate[{D[f, var[1]], D[f, var[2]]}, {var[1], x}, {var[2], y}, {f,
> x^2 + y^3}]
>
>
> I would like to extend this program to allow for an adjustable number of
> variables. I'm imagining using nested manipulate commands to allow the
> number of variables to be user controlled. To do this I also need the
> program to be able to adjust how many derivatives are being calculated. I
> tried to
> replace the list of derivative commands with a table:
>
> Manipulate[
> Table[D[f, var[i]], {i, 1, 2}], {var[1], x}, {var[2], y}, {f,
> x^2 + y^3}]
>
> This does not work. I suspect that the Table command somehow causes it to
> calculate the derivatives before the function and/or variables are defined
> based on the manipulate controls. How do I control this order of
> evaluation?
>
> Thank you,
>
> Nathan
>
>




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.