Announcement

Collapse
No announcement yet.

Script to replace "a^b" in an expression with "pow(a,b)"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Because I'm lazy, I hate programming, and it's not quite trivial given that "a" can be tan(b), parenthetical expressions, etc.

    WTF is that thing anyway?


    Shining light down on a plasma, and seeing where the ray intersects its surface. I can't solve it analytically since the plasma's surface has a funky transcendental shape, so I'm using Newton's method to find the solutions. For my initial guesses I quadratically expanded around a certain parameter of the plasma (something that I had absolutely no right to assume as being << 1), to get a cubic equation in the sine of the parametric variable for the plasma's surface. And that expression above is one of the solutions to that equation.

    Thanks Mercator.
    "Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
    -Bokonon

    Comment


    • #17
      I applied for a job in Austin...
      Monkey!!!

      Comment


      • #18
        Where at?
        "Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
        -Bokonon

        Comment


        • #19
          Originally posted by Ramo
          Because I'm lazy, I hate programming, and it's not quite trivial given that "a" can be tan(b), parenthetical expressions, etc.

          WTF is that thing anyway?


          Shining light down on a plasma, and seeing where the ray intersects its surface. I can't solve it analytically since the plasma's surface has a funky transcendental shape, so I'm using Newton's method to find the solutions. For my initial guesses I quadratically expanded around a certain parameter of the plasma (something that I had absolutely no right to assume as being << 1), to get a cubic equation in the sine of the parametric variable for the plasma's surface. And that expression above is one of the solutions to that equation.

          Thanks Mercator.
          ...

          couldn't you just check random values until it fit? That'd be simpler...

          Comment


          • #20
            Where at?
            Abbott Labs
            Monkey!!!

            Comment


            • #21
              Originally posted by Ramo
              Shining light down on a plasma, and seeing where the ray intersects its surface. (...)


              Thanks Mercator.
              No problem
              Civilization II: maps, guides, links, scenarios, patches and utilities (+ Civ2Tech and CivEngineer)

              Comment


              • #22
                Shining light down on a plasma, and seeing where the ray intersects its surface. I can't solve it analytically since the plasma's surface has a funky transcendental shape, so I'm using Newton's method to find the solutions. For my initial guesses I quadratically expanded around a certain parameter of the plasma (something that I had absolutely no right to assume as being << 1), to get a cubic equation in the sine of the parametric variable for the plasma's surface. And that expression above is one of the solutions to that equation.
                That's the nerdiest thing I have heard... since the OP
                Monkey!!!

                Comment


                • #23

                  Hopefully I'll finish this soon so I can get well drunk and stoned and forget that I wasted a week on this.


                  couldn't you just check random values until it fit? That'd be simpler...


                  Yeah, but it'd take forever to compute.
                  "Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
                  -Bokonon

                  Comment


                  • #24
                    Originally posted by Kuciwalker


                    ...

                    couldn't you just check random values until it fit? That'd be simpler...
                    That's essentially what Newton's method is.
                    “It is no use trying to 'see through' first principles. If you see through everything, then everything is transparent. But a wholly transparent world is an invisible world. To 'see through' all things is the same as not to see.”

                    ― C.S. Lewis, The Abolition of Man

                    Comment


                    • #25
                      Forget about doing that automaticlly - it's a waste of time. Also drop using MS tools - they sucks - use vi (no, this is not std MS bashing - I work on both unix and MS platforms, and vi is the winner).

                      Repeat search for ^ and make global subsititute for what you find one by one. It may sound tedious, but is much more effective than trying to figure out a way to solve it in one step. It isn't as bad as it may sound - there are of repeated statements that will be fixed by one statement.
                      With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                      Steven Weinberg

                      Comment


                      • #26
                        Watch Numb3rs tonight, I hear they go over this!
                        Monkey!!!

                        Comment


                        • #27
                          If you have multiple files, then try using cscope to make changes in those files involved. It's quite effective - I once turned a pascal program into c with this tool.
                          With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                          Steven Weinberg

                          Comment


                          • #28
                            I don't know BC, Mercator's solution seems pretty good. Like I said, I tried finding and replacing, and screwed up somehow.

                            Mercator, I just installed Active Perl. Now, how would I run your script?
                            "Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
                            -Bokonon

                            Comment


                            • #29
                              That is insane...
                              Speaking of Erith:

                              "It's not twinned with anywhere, but it does have a suicide pact with Dagenham" - Linda Smith

                              Comment


                              • #30
                                Problem is that you easily spend much more time trying to invent the smart solution than just do the boring stuff.

                                If it is something that you expect to do a lot in the future, then I'm in for the smart thing - otherwise it's my experience it's just a waste of time (admitted, it can be fun to make such a regexp )
                                With or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.

                                Steven Weinberg

                                Comment

                                Working...
                                X