Author Topic: Coding comparison using the Po-Shen Loh's new quadratic formula  (Read 1027 times)

Biterider

  • Member
  • *****
  • Posts: 1081
  • ObjAsm Developer
    • ObjAsm
Coding comparison using the Po-Shen Loh's new quadratic formula
« on: September 03, 2022, 03:55:57 PM »
Hi
Here is a video by a well-known author in the asm community.
He makes a very interesting comparison, especially after minute 15:25 when he makes the asm comparison.  :biggrin:

Check it out https://www.youtube.com/watch?v=eZ5U0f14LaY

Biterider

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #1 on: September 03, 2022, 04:57:49 PM »
I watched the video, much depended on how the C compiler handled numbers. The ASM code was faster as expected but the author said it was not highly optimised. Interesting enough but I don't know what you use it for.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 2467
  • AMD 7-32 / i3 10-64
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #2 on: September 04, 2022, 03:25:48 AM »
Interesting enough but I don't know what you use it for.

Quadratic formula is reverse equation of polynomic of grade 2.


     Y = a + b*X + c*X^2

     Y = polynomic (a,b,c,X)  ;  X is known and Y is unknown

     X = quadratic (a,b,c,Y)  ;  X is unknown and Y is known


     If i know steers body weight in kg is related to age in days by:

           BW = -50.4 + 1.22*age - 0.000472*age^2

     What age could have a steer that weighs 450 kg?
 
           age = quadratic(-50.4, 1.22, - 0.000472, 450.0)
     



   
Equations in Assembly: SmplMath

FORTRANS

  • Member
  • *****
  • Posts: 1230
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #3 on: September 05, 2022, 02:16:23 AM »
Hi,

   It was entertaining in an overdone sort of way.  So
thanks for posting.  Useful?  Maybe as an introduction
to algorithm testing I suppose.

Cheers,

Steve N.

Biterider

  • Member
  • *****
  • Posts: 1081
  • ObjAsm Developer
    • ObjAsm
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #4 on: September 05, 2022, 04:46:19 AM »
Hello Steve
You are absolutely right.
You don't always have to agree on the content, but one or the other pearl can almost always be found.

Biterider

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #5 on: September 05, 2022, 05:29:49 AM »
Hector,

There is a notation that I don't understand.

"Y = a + b*X + c*X^2" What is the "^" operator doing ?

It is a quirk leftover from when I went to primary school (early 1950s) where my arithmetic notation was different to what is being used today.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

zedd151

  • Member
  • *****
  • Posts: 1937
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #6 on: September 05, 2022, 05:34:47 AM »
c*X ^ 2
To the power of 2
More simple squared.

E=mc^2 is equal to E=mc2   
Used when you can't write superscript
Regards, zedd.
:tongue:

NoCforMe

  • Member
  • *****
  • Posts: 1106
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #7 on: September 05, 2022, 05:37:54 AM »
I'm surprised Steve didn't get that; I've always seen ^ used for exponentiation. Is there a Euro symbol for this that's different?

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #8 on: September 05, 2022, 05:47:41 AM »
Thanks Z, a "power of ...." makes sense. Its an era thing, having learnt arithmetic in the early 1950s, much modern notation does not fit where what I learnt long ago translates to assembler notation logic far easier. When I did logic at uni, I picked up the discipline of fully bracketing formula and stacked order of precedence does not fit that discipline.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 2467
  • AMD 7-32 / i3 10-64
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #9 on: September 05, 2022, 06:06:19 AM »
Hi Hutch!

"Y = a + b*X + c*X^2" What is the "^" operator doing ?

It's more usual notation for power. If I remember well is used in BASIC from the begining. At least GW-Basic used this notation.

Some old language use "**" for power. Both are programming notations.

In school, or writing, everybody use a superscript:  Y = a + b*X + c*X2

stacked order of precedence does not fit that discipline.

 :biggrin: No shunting-yard
Equations in Assembly: SmplMath

daydreamer

  • Member
  • *****
  • Posts: 2368
  • my kind of REAL10 Blonde
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #10 on: September 05, 2022, 06:23:58 AM »
Please avoid write and compile expression x^2 in C because "^" is used for xor, if you want x*x
my none asm creations
http://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10573
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Coding comparison using the Po-Shen Loh's new quadratic formula
« Reply #11 on: September 05, 2022, 08:40:31 AM »
Hi hector,

This is how my 1950s arithmetic sees the formula.

    original => Y = a + b*X + c*X2

    my brain => Y = a + (b*X) + (c * (X * X))

Thanks for the explanation.  :thumbsup:
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy: