Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: solve cubic equations

by no_slogan (Deacon)
on May 05, 2017 at 20:56 UTC ( #1189615=note: print w/replies, xml ) Need Help??

in reply to Re: solve cubic equations
in thread solve cubic equations

my \C = ( ( Δ1 + sqrt( Δ1 - 4 Δ0 + 0i) ) / 2 ).roots(3)[0];

Mathematically, your code is equivalent. (The arctan and cos are hidden inside roots.) Numerically, yours is potentially unstable. The first + in the line above might lose accuracy due to subtracting nearly-equal numbers. See Numerical Recipes, chapter 5.6. Unfortunately, sometimes we have to choose between code that looks nice and code that works.

The trouble with Perl 6 is that it's full of people who think it's a good idea to have a class called "Cool" which contains a hodgepodge of numerical and string-manipulation methods.

Replies are listed 'Best First'.
Re^3: solve cubic equations
by bduggan (Pilgrim) on May 11, 2017 at 00:08 UTC
    1. Yes, it's totally possible to optimize for accuracy, and yes, some situations call for that.
    2. Allomorphic typing is cool.
      1. Lots of things are cool, but you can't name them all "Cool" in your language.
      2. This post is the 9th hit on google for the phrase "allomorphic typing." Of the ones above it, 7 are about linguistics, and the other one says that term was briefly in use in computer science 26 years ago. You don't frighten me with your silly language behavior.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1189615]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2023-06-05 09:06 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (24 votes). Check out past polls.