Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

trigonometric functions give an uncaught user exception

by neophyte (Curate)
on May 30, 2001 at 14:39 UTC ( #84213=perlquestion: print w/ replies, xml ) Need Help??
neophyte has asked for the wisdom of the Perl Monks concerning the following question:

Amazed looking at her code and the error, neophyte ventures to ask:
The following code is part of a program that will be used to find given building stuff (big tubes, in this case) according to input sizes.
I'm using a given formula to calculate b for a given tube with the input of a.
use Math::Trig; use diagnostics; my $a = 3; # user input my $r1 = 3.05; # radius 1 of elliptical tube my $r2 = 3.95; # radius 2 of elliptical tube my $w2 = 82.6; # angle 2 my $w_beta1 = asin($a / (2 * $r1)); my $b = $r1 * ( cos($w_beta1) - (cos($w2 / 2) ) + $r2 * cos($w2 / 2); print $b;

When I execute this code I get a syntax error in the line where $b is defined. No more information, so when I execute this with use diagnostics I get Uncaught exception from user code: syntax error at noname.pl line 8, near ");"
which really doesn't help me. I already looked for missing punctuation and unpaired brackets, but I cannot find anything.
Please tell me what's wrong with that piece of code.

neophyte Niederrhein.pm

Comment on trigonometric functions give an uncaught user exception
Select or Download Code
Re: trigonometric functions give an uncaught user exception
by ChOas (Curate) on May 30, 2001 at 14:46 UTC
    Hi! ;)

    my $b = $r1 * ( cos($w_beta1) - (cos($w2 / 2) ) + $r2 * cos($w2 / 2);

    You got 5 ('s ,and 4 )'s ....

    It`s up to you where you want the last ) ;)

    Hope this helps...

    GreetZ!,
      ChOas

    When in doubt, parenthesize.
    At the very least it will let some poor schmuck bounce on the % key in vi.
                      (L. Wall)
    print "profeth still\n" if /bird|devil/;
      ouch
      thanks a ton, ChOas
      this just shows how blind I can get at times

      neophyte Niederrhein.pm - gotta code quickly, my brain's degenerating

Re: trigonometric functions give an uncaught user exception
by gollem (Acolyte) on May 30, 2001 at 14:50 UTC
    You're missing a ) at the end of that line
Re: trigonometric functions give an uncaught user exception
by DrSax (Sexton) on May 30, 2001 at 16:42 UTC
    The problem is that you need an additional parens on line 8. my $b = $r1 * ( cos($w_beta1) - (cos($w2 / 2) ) + $r2 * cos($w2 / 2));
    Could happen to anyone... DrSax

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://84213]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-12-25 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (161 votes), past polls