Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'build up a calculation program with variables' topicStudent Support Forum > General > Archives > "build up a calculation program with variables"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
07/25/12 5:40pm

Your word document looks fairly straight forward to translate into Mathematica. Here is a start:

Avc:= Ac-2*bc*tfc+(twc+2*rc)*tfc;
k1:= 0.38*Avc/(beta*z);
beffc:= tfb+2*Sqrt[2]*ap+sp+5*(tfc+s);
dc:= hc-2*(tfc+2*rc);
k2:= 0.7*beffc*twc/dc;
Sini:= e*z^2/(1/k1+1/k2+1/k3+1/k4+1/k5+1/k10);

Each variable:=expression tells Mathematica that when you later use that variable Mathematica is to look up the values of all the variables on the right of the := and calculate the result and then use that as the value of your variable.

Notice I ordered those so that variables follow definitions of other variables which they depend on. With := that is not absolutely necessary, but for a beginner I think that can help you organize your work.

Each expression ends in a semicolon telling Mathematica that it is complete.

You must be cautious when using upper case characters to begin names because Mathematica has many symbols already defined that begin with upper case characters. As long as there is no conflict you are usually free to use any names you like.

It is possible, and many people find they cannot resist doing so, to use super and subscripts in variable names. It is possible to make this work, but often this results in errors that a new user cannot understand. I strongly recommend against using super and subscripts unless you want to figure out what is wrong and fix that yourself.

It is possible to use Greek characters from the palette and those do not usually cause problems. But some symbols on the palette are not Greek letters and using those in variable names will cause you great grief.

Mathematica will usually understand that x y and x*y both mean multiply x and y and that xy is a completely different variable with a two letter name. I suggest using * to indicate multiplication to begin with.

It is possible to use "two dimensional" format to enter fractions and powers and radicals, etc. Feel free to do that if you must. Or use () and the usual characters to indicate division, power, etc.

Mathematica treats numbers without a decimal point completely differently from numbers with a decimal point. I think you will tend to have fewer problems if you use numbers without decimal points for values that you know the answer exactly. But this is a large and complicated area of Mathematica to understand.

Mathematica uses E and not e for Euler's constant, I and not i for Sqrt[-1].

Mathematica is FANATIC about precisely correct capitalization and use of () versus {} versus [] and = versus := versus == versus even === and those are all different. Make any tiny error in any one of those and you will likely get error messages you may not understand or simply get nothing at all.

I would suggest trying to translate your work into Mathematica using the example above. At the top of the notebook I suggest assign constants to all the variables that are known. When you think you have part of the work done you can evaluate the notebook with <shift><enter> and then inspect the value of individual variables by entering them separately not followed by a semicolon and then followed by <shift><enter> Verify that the value is correct. Beginning gradually and checking each step to discover flaws as early as possible can be very helpful.

When you have made some progress you can attach a notebook to your next post. If you are stuck somewhere then describe what problem you are having. Hopefully that will enable someone to show you how to take the next step. If you have more questions then just ask.

URL: ,

Subject (listing for 'build up a calculation program with variables')
Author Date Posted
build up a calculation program with variables zouaher 07/22/12 05:48am
Re: build up a calculation program with variables Bill Simpson 07/24/12 00:43am
Re: build up a calculation program with variables zouaher 07/25/12 10:16am
Re: build up a calculation program with variables Bill Simpson 07/25/12 5:40pm
Re: build up a calculation program with variables zouaher 07/26/12 07:12am
Re: build up a calculation program with variables zouaher 07/26/12 07:56am
Re: Re: build up a calculation program with var... Bill Simpson 07/26/12 6:49pm
Re: build up a calculation program with variables zouaher 07/28/12 10:41am
Re: Re: build up a calculation program with var... Bill Simpson 07/28/12 3:08pm
Re: build up a calculation program with variables zouaher 07/31/12 05:16am
Re: Re: build up a calculation program with var... Bill Simpson 07/31/12 12:29pm
Re: build up a calculation program with variables zouaher 08/01/12 11:15am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic