Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

illegal context - can't figure out my error

Status
Not open for further replies.

mwalz

Materials
May 5, 2005
5
Hi all,

I'm a new Mathcad user and am encountering an illegal context error. I can't figure out the cause of the error. Lambda is a range variable that is defined.

illegal_context.jpg


I did a simple program, reducing this equation down to
b = 1
c = 1
g(x) = 1+x

f(x) = asin[g(x) * sin[b - asin[(1/g(x)) * sin(c)]]]
and it worked fine. So the issue is obviously in my messy equation above, but I am still not seeing it. Any ideas?

Thanks!
Martha
 
Replies continue below

Recommended for you

You are missing a square bracket. How did you do that?



Cheers

Greg Locock

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Is [Ψ]fs created with [Ψ].fs or [Ψ][fs? If the latter, then it cannot be a function name.
 
How did you define [λ]? Did you use i or another counting variable? If so, you should include it in your other equations (see your Help screen above).

If [λ] is a range variable, then why do you want type in its value each time to evaluate [ψ]fs?

Regards,

Cory

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
IRstuff, I will look at that other forum. Thanks!

Greg, I fixed the missing square bracket, still get the same result. Don't know how I managed to define the function with the missing bracket!

jghrist, ?fs was created with ?.fs so no problem there.

Cory, ? is defined as ?:=.700, .. .900 . I need to evaluate ?fs at one particular ? as well as at all values of ? for use in an equation later in the program. I am evaluating ?fs at 1 in the above example for debugging purposes.

Thanks all!

Martha
 
Martha,

Are you sure you defined [λ]:.700, .. .900? MathCad requires a number immediately after the comma or the range will be undefined. If you typed [λ]:.700 .. .900, then MathCad assumes the step is equal to 1 and only defines [λ]= 0.700 since 1.700 is beyond your upper limit.

Regards,

Cory

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips Fora.
 
If you defined lambda as a range, then you might get an illegal context message per the help window you posted. You need to either vectorize the function using <CRTL>+- or explicitly reference the indexed variable with L[i construct

TTFN
 
Oops! I defined lambda as follows: lambda:= .700,.701,.. .900 . (I had previously defined it as 700, .. 900 and the step was 1.)

As for vectorizing the function...since lambda is a range variable, wouldn't that also mean that I would have to vectorize the function nfs(lambda)? That function evaluates just fine and does not give an error.

 
It's a pretty simple change, so I'd try it, just to see what happens.

TTFN
 
a> Would make it a lot cleaner if you used units, e.g., angles with degrees. One of Mathcad's main strengths is its ability to incorporate and process units in numerical calculations. The conversions from degrees to radians simply clutter up the equations.

b> You must have a typo somewhere. I copied your sheet (would have been really easier if you had posted it) and don't seem to get your error. Results were:
0.9729
0.9729
0.9728
0.9728
0.9727
0.9727
0.9727
0.9726
0.9726
0.9725
0.9725
0.9724
0.9724
0.9723
0.9723
0.9723
0.9722
0.9722
0.9721
0.9721
0.9720
0.9720
0.9720
0.9719
0.9719
0.9718
0.9718
0.9717
0.9717
0.9717
0.9716
0.9716
0.9715
0.9715
0.9715
0.9714
0.9714
0.9713
0.9713
0.9712
0.9712
0.9712
0.9711
0.9711
0.9710
0.9710
0.9710
0.9709
0.9709
0.9708
0.9708
0.9708
0.9707
0.9707
0.9707
0.9706
0.9706
0.9705
0.9705
0.9705
0.9704
0.9704
0.9703
0.9703
0.9703
0.9702
0.9702
0.9702
0.9701
0.9701
0.9700
0.9700
0.9700
0.9699
0.9699
0.9699
0.9698
0.9698
0.9697
0.9697
0.9697
0.9696
0.9696
0.9696
0.9695
0.9695
0.9695
0.9694
0.9694
0.9693
0.9693
0.9693
0.9692
0.9692
0.9692
0.9691
0.9691
0.9691
0.9690
0.9690
0.9690
0.9689
0.9689
0.9689
0.9688
0.9688
0.9688
0.9687
0.9687
0.9687
0.9686
0.9686
0.9686
0.9685
0.9685
0.9685
0.9684
0.9684
0.9684
0.9683
0.9683
0.9683
0.9682
0.9682
0.9682
0.9681
0.9681
0.9681
0.9680
0.9680
0.9680
0.9679
0.9679
0.9679
0.9678
0.9678
0.9678
0.9677
0.9677
0.9677
0.9676
0.9676
0.9676
0.9675
0.9675
0.9675
0.9674
0.9674
0.9674
0.9674
0.9673
0.9673
0.9673
0.9672
0.9672
0.9672
0.9671
0.9671
0.9671
0.9670
0.9670
0.9670
0.9670
0.9669
0.9669
0.9669
0.9668
0.9668
0.9668
0.9667
0.9667
0.9667
0.9667
0.9666
0.9666
0.9666
0.9665
0.9665
0.9665
0.9664
0.9664
0.9664
0.9664
0.9663
0.9663
0.9663
0.9662
0.9662
0.9662
0.9662
0.9661
0.9661
0.9661
0.9660
0.9660
0.9660
0.9660
0.9659
0.9659
0.9659
0.9658

TTFN
 
Since nfs(lambda) works, the typo is in your final equation. Near as I can tell, the only non-obvious error would be an implicit multiplication against nfs, e.g., nfs*(lambda) multiplication instead of a function call nfs(lambda).

TTFN
 
IRstuff,

Thanks for all of your help! I never got around to posting my program last week, so thank you for taking the time out to reproduce the whole thing. I will try to figure out where the typo is in my last equation. Thanks again!

Martha
 
I found the error. The argument for the second asin call was being multiplied instead of being taken as the argument. I never would have caught that before.

Thanks again!

Martha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor