[Date Index]
[Thread Index]
[Author Index]
Re: Using manipulate with user entered variables and functions
*To*: undisclosed-recipients:;
*Subject*: [mg131336] Re: Using manipulate with user entered variables and functions
*From*: Bob Hanlon <hanlonr357 at gmail.com>
*Date*: Sat, 29 Jun 2013 04:56:31 -0400 (EDT)
*Approved*: Steven M. Christensen <steve@smc.vnet.net>, Moderator
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-outx@smc.vnet.net
*Delivered-to*: mathgroup-newsendx@smc.vnet.net
*Newsgroups*: comp.soft-sys.math.mathematica
*References*: <20130523080537.2A5356A0D@smc.vnet.net>
Manipulate[
Module[
{var = Union[Cases[f,
_Symbol?(! NumericQ[#] &), Infinity]]},
Grid[
{HoldForm[D[Style["f", Italic], #] //
TraditionalForm] & /@ var,
(D[f, #] // Simplify //
TraditionalForm) & /@ var},
BaseStyle ->
{FontFamily -> "Times", Large},
Background -> Yellow, Frame -> All,
FrameStyle -> {Blue, Thickness[2]}]],
{{f, 4 x y^3 + x y,
Style["f", Italic, FontFamily -> "Times", Medium]},
(# -> Style[TraditionalForm[#], Large,
FontFamily -> "Times"]) & /@
{4 x y^3 + x y, -3 x + x^2 - 6},
ControlType -> PopupMenu}]
Bob Hanlon
On Fri, Jun 28, 2013 at 8:21 AM, sigismond kmiecik <
sigismond.kmiecik at wanadoo.fr> wrote:
> Bob,
>
> I tried to modify the answer you gave in order to have all the expressions
> displayed in traditional form (in the popup menu and the evaluated output)
> without success apart for the symbol for differentiation.
>
> My updated notebook:
>
>
> Manipulate[
> Module[{var = Union[Cases[f, _Symbol?(! NumericQ[#] &), Infinity]]},
> Grid[{HoldForm[D["f", #] // TraditionalForm] & /@ var,
> Simplify[Map [D[f, #] &, var]]},
> BaseStyle -> {Bold, FontFamily -> "Times", Large},
> Background -> Yellow, Frame -> All,
> FrameStyle -> {Blue, Thickness[4]}]], {f, {4 x y^3 + x y,
> TraditionalForm[-3 x + x^2 - 6]} , ControlType -> PopupMenu,
> Background -> LightRed }]
>
> The second expression of "f" is displayed as I want in the popup menu but
> it generates an odd output.
> What is wrong and how can I apply to the popup menu the Basestyle option
> I added to the Grid definition?
>
> Thanks
>
> Sigismond Kmiecik
>
>
> Le 12/06/2013 11:27, Bob Hanlon a =E9crit :
>
>> 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 at 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
>>>
>>>
>>>
>
> --
> Sigismond Kmiecik
>
>
Prev by Date:
**Create Modelica Models within Mathematica**
Next by Date:
**Fraction Spacing**
Previous by thread:
**Re: Using manipulate with user entered variables and functions**
Next by thread:
**problem with ndsolve using interpolated functions**
| |