1
$\begingroup$

I want to solve one easy equation with two parameters which changes. I tried to use Manipulate for see the solution "in real time" after each changing one or two of two parameters. But i have next message in result window "Null". So my code is below:

Options[Simple] = {
Сut1 -> 0,
Сut2 -> 0
};
Simple[
OptionsPattern[]
] := Module[
{
kit1 = OptionValue[Сut1],
kit2 = OptionValue[Сut2]
},
solution = N[-Cos[kit1]^2 + 4 Cos[kit1]^2*Sin[kit1]^2*Cos[kit2]^2 - 1.5 
Sin[kit2]^8*(0.3 + Sin[kit1]^2*Cos[kit2]^2) - 0.5*Sin[kit2]*Sin[kit1]];
]

solution1 = Manipulate[Module[{rmt1 = Simple[Сut1 -> kyts1, Сut2 -> kyts2]}, 
rmt1], "Select Options:",
"Value of θ0 angle:", {{kyts1, 90.0, "Degree"}, 0.0, 270.0},
"Value of ϕ0 angle:", {{kyts2, 45.0, "Degree"}, 0.0, 270.0},
"Result is:"];
$\endgroup$
0

1 Answer 1

2
$\begingroup$

The last ; before the closing bracket for the Module in your definition of Simple is effectively suppressing your output. For the same reason, you should NOT have a ; after the closing bracket of the Manipulate expression. If you remove those, values will be displayed.

As a side note, your user-selected degree values are currently interpreted as radians; you may want to modify your call to Simple within the Manipulate to Simple[Cut1 -> kyts1 Degree, Cut2 -> kyts2 Degree].

In addition to those changes, a few other things struck me as odd in your code, so I propose the following refactoring:

ClearAll[Simple]

Options[Simple] = {Сut1 -> 0, Сut2 -> 0};

Simple[OptionsPattern[]] := Module[
  {kit1 = OptionValue[Сut1], kit2 = OptionValue[Сut2]},
  N[-Cos[kit1]^2 + 4 Cos[kit1]^2*Sin[kit1]^2*Cos[kit2]^2 - 
    1.5 Sin[kit2]^8*(0.3 + Sin[kit1]^2*Cos[kit2]^2) - 0.5*Sin[kit2]*Sin[kit1]]
  ]

Manipulate[
  Simple[Сut1 -> kyts1 Degree, Сut2 -> kyts2 Degree],
  "Select Options:",
  "Value of θ0 angle:", {{kyts1, 90.0, "Degree"}, 0.0, 270.0, Appearance -> "Labeled"},
  "Value of ϕ0 angle:", {{kyts2, 45.0, "Degree"}, 0.0, 270.0, Appearance -> "Labeled"},
  "Result is:"
]

Mathematica graphics

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.