Pythagorean theorem in equations

Discussion in 'SolidWorks' started by Seth Renigar, Mar 29, 2007.

  1. Seth Renigar

    Seth Renigar Guest

    I am trying to calculate the Pythagorean theorem in an equation. But,
    I have never used the exponential function, and am having problems
    getting it to work.

    Basically, I am just unsure of the correct syntax for the exponential
    function. I think once I figure that out, I can get it to work,
    maybe.

    The equation (in layman's terms) that I need to use is: X=sqr(A^2 +
    B^2) where A & B are the known values. But, when using the
    exponential function, I don't know where or how to tell it to raise to
    the 2nd power, in the syntax. The help doesn't help any either.

    What I have currently is "D1@Sketch1" = sqr(exp("D2@Sketch1") +
    exp("D3@Sketch1")). What is the correct syntax to tell it that the
    exponential is the power of 2? Or am I just completely off-base to
    begin with????

    Thanks,
    Seth
     
    Seth Renigar, Mar 29, 2007
    #1
  2. Seth Renigar

    Jean Marc Guest

    Not really the answer, but from my old days in Fortran, I would simply write
    "D2@Sketch1"*"D2@Sketch1" for "D2@Sketch1"^2

    HIH
    JM
     
    Jean Marc, Mar 29, 2007
    #2
  3. Seth Renigar

    Dale Dunn Guest

    Seth,

    exp("D3@Sketch1") is e^"D3@Sketch1"

    You need something like hyp=sqr("D3@Sketch1"^2+"D3@Sketch2"^2)

    SW Equations use VBA functions, operators and syntax, so you can look up
    more in the macro editor's help.
     
    Dale Dunn, Mar 29, 2007
    #3
  4. Seth Renigar

    Seth Renigar Guest

    Dale,

    OK, that works. Thank you.

    Basically, this is not using the built in SW exponential function
    syntax. It is using a more conventional syntax. This does make it
    much more simple. But, just out of curiousity, what would the correct
    syntax be if you really wanted to use the built in SW exponential
    function? I know nothing about VBA...

    Seth
     
    Seth Renigar, Mar 29, 2007
    #4
  5. Seth Renigar

    Dale Dunn Guest

    I'm not sure what you mean by "built in exponential function". Syntax in
    the dimension modify box? Anyhow, for equations VBA *is* the built-in
    function, with all the same limitations and capabilities: one-line IF
    functions, random number functions (fun!), and some trig functions missing
    (use trig identities to get cotangent, etc.)

    Way back in 2000 (I think), they was a bug where you could see the
    mechanism for this under certain circumstances. Basically, the SW equations
    seemed to be translated into VBA statements for evaluation.
     
    Dale Dunn, Mar 29, 2007
    #5
  6. Seth Renigar

    Seth Renigar Guest

    What I mean by the built in function is:

    When you use the Add Equation dialog box and click the exponential
    button, SW puts in " exp( ) " and then needs more information. It
    needs the dimension you want to raise, and the power you want to raise
    that dimension to. My question is what would the syntax be to enter
    this missing information, using this "built-in" button?

    Maybe its just me thats not understanding something correctly... I'm
    not dumb by no means. But, I am not a math wiz either.....

    Seth
     
    Seth Renigar, Mar 29, 2007
    #6
  7. Seth Renigar

    Dale Dunn Guest

    I see. The problem isn't density, maybe tunnel vision. I know both very
    well. The equation editor has both the exponential funtion (e^x) and
    exponentiation (x^y). The "^" is down in the RH corner. You want to use an
    exponent (2) to square a quantity. "Exponential function" is the inverse of
    the natural log, which you don't want.
     
    Dale Dunn, Mar 29, 2007
    #7
  8. Seth Renigar

    That70sTick Guest

    The "exp()" function is simply the WRONG function to use. "exp(n)"
    raises "e" to the "n" power (e=2.7818281828...).

    The caret "^" is used to raise to a power. Since you are only
    squaring, you can also simply multiply the number by itself.

    There is a square root function, "sqr()". You can also get square
    root by raising to power of 0.5 (i.e. "n ^ 0.5")
     
    That70sTick, Mar 29, 2007
    #8
  9. Seth Renigar

    Seth Renigar Guest

    Whowa.... Yep, I was way off base with this one...
    Never noticed the "^" in the RH corner....

    Thanks for all your help, and tolerating my stupidity... : )

    Seth
     
    Seth Renigar, Mar 29, 2007
    #9
  10. Seth Renigar

    Cliff Guest

    In layman's terms you could just do A*A + B*B I suppose ....
    You don't really want base e functions or natural logarithms,
    do you?
     
    Cliff, Mar 29, 2007
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.