Message Boards Message Boards

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

What is the code for Y=yb1+yb2 in Mathematica

Posted 9 years ago

Hello all, My name is Parisa. I am a Ph.D. student at Carleton University in Canada. I am pretty new in this community. I was wondering if you could help me to find a solution for my question. I tried to insert an input as: Y:=yb1+yb2 in the notebook, but it does not give me any out put. I also tried different ways such as: Y:=y[b1]+y[b2] Y:=y[b][1]+y[b][2] still there is no output!!! I was wondering if you could help.

2 Replies

In an expression such as

 Y:=yb1+yb2

the ":=" is shorthand for "SetDelayed"; typing that and pressing Shift&Enter does not give any output. To see the value assigned, type

 Y

and press Shift&Enter.

As was already pointed out, it's a bad idea to use any names of your own that are, or begin with, an upper-case letter — so as to avoid clashes with built-in names, all of which do begin with an upper-case letter (or, for certain special names, with the symbol $).

But is your intention that yb1 and yb2, and hence Y, are constants, or are they functions of some underlying variable such as t?

If the former then, as pointed out, it's more appropriate to use

 Y = yb1 + yb2

where "=" is shorthand for Set.

If the latter, then define the function Y of t in terms of the functions yb1 and yb2 of t by:

 Y[t_] := yb1[t] + yb2[t]

Note the pattern expression "t_" on the left-hand side.

It seems it would be well worth your time to explore some of the documentation, and view a couple of the "starting out" videos on the Wolfram web site. The time you spend with that will more than make up for the time you waste floundering around without knowing the very basics of the language.

Added in edit:

It occurs to me that you might have intended something entirely different, namely, to type an equation asking whether (the value of) Y is equal to the same of (the values of) yb1 and yb2. If that was your intention, then you need to use a double equal-sign to form the equation:

 Y == yb1 + yb2

And then you would expect a result of True or False (assuming you had assigned values to Y, yb1, and yb2); you might need to use Simplify or other simplification functions to help Mathematica to decide whether the two sides of the equation are actually true. But — if you had not already assigned values to Y, yb1, and yb2, the output from the equation would just be the equation itself: Mathematica cannot do anything with it.

POSTED BY: Murray Eisenberg

did you hit the ENTER key or the RETURN key? In Mathematica, it is the ENTER key (the one next to the numeric keypad). You can also hit SHIFT-RETURN

For assignment, use = not :=. Also spaces are important. yb1 is not the same as y b1

I suspect you meant to write

 Y = y b1 + y b2

I would suggest to avoid using first letter which is UpperCase. This applies for not only variable names but also for function names. Always use lowerCaseFirstLetter. If you must use UpperCase, then add a 0, as in A0 or D0, but not never a single UpperCase. Else can conflict with Mathematica own symbols among other issues.

POSTED BY: Nasser M. Abbasi
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