Message Boards Message Boards

0
|
5557 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

beginner's struggle with programming

Posted 10 years ago

Hi,

I am trying to teach my self programming with mathematica and this is one of my first attempts. I am trying to solve x1, x2, x3, x4 and x5 for different values of S, x, y, and ?, given by the following equations:

 x1 = 2*S+x*y/?
 x2 = S+?/x*y
 x3 = 2*?+x*y/S
 x4= x*x3 + y*x1 + ?*x2
 x5= x1/x2

I tried to do it by using Manipulate i.e.

Manipulate[
  N[x1 = 2*S+x*y/?, {S, 150, 1000, 
   50}, {x, 1, 10, 1}, {y, 1, 10, 1}, {?, 2, 4, 1}];
Manipulate[
  N[ x2 = S+?/x*y, {S, 150, 1000, 
   50}, {x, 1, 10, 1}, {y, 1, 10, 1}, {?, 2, 4, 1}];
Manipulate[
  N[x3 = 2*?+x*y/S, {S 150, 1000, 
   50}, {x, 1, 10, 1}, {y, 1, 10, 1}, {?, 2, 4, 1}];
Manipulate[
  N[x4 = x*x2*x3 + y*x1*x3 + ?* x1*x2], {x, 1, 10, 1}, {y, 1, 10, 
   1}, {?, 2, 4, 1}];
Manipulate[
 N[x5= x1/x2], {S, 150, 1000,50}, {x, 1, 10, 1}, {y, 1, 10, 
  1}, {?, 2, 4, 1}]

However, this is not a very efficient way. Any suggestions?

In addition I would like to plot in 2D S vs. x1, x2, and x3 (x-axis S and y- axis x1, x2, and x3). S is in kg and x1, x2, x3 is in meters.

thank you in advance for your help.

POSTED BY: Loft B
2 Replies

Make sure you know the difference between a definition := , an assignment = , a rule -> , and mathematical equal == like

equation1 = x1==2*S;

or define a function

x1[s_, a_] := 5 s + a^2;

Manipulate[x1[s, a], {s, 0, 1.}, {a, -1, 1}]

Plot[x1[s, 3], {s, 0, 1.}]

There are nice tutorials on the Wolfram website.

POSTED BY: Kay Herbert
Posted 10 years ago

Hi Kay,

thank you very much for your advice. However, my problem is more on how to be able to, let's say, visualize the results rather than solving.

I have managed to solve them, but I would like to make a programm where every time i update the input variables (S, x, y, and ?) the ouput is also updated creating a 2D plot.

I hope you understand what I mean.

POSTED BY: Loft B
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