The MASM Forum

General => The Laboratory => Topic started by: Biterider on September 03, 2022, 03:55:57 PM

Title: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: Biterider 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 (https://www.youtube.com/watch?v=eZ5U0f14LaY)

Biterider
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: hutch-- 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.
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: HSE on September 04, 2022, 03:25:48 AM
Quote from: hutch-- on September 03, 2022, 04:57:49 PM
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)
     



   
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: FORTRANS 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.
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: Biterider 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
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: hutch-- 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.
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: zedd151 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
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: NoCforMe 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?
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: hutch-- 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.
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: HSE on September 05, 2022, 06:06:19 AM
Hi Hutch!

Quote from: hutch-- on September 05, 2022, 05:29:49 AM
"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

Quote from: hutch-- on September 05, 2022, 05:47:41 AM
stacked order of precedence does not fit that discipline.

:biggrin: No shunting-yard
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: daydreamer 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
Title: Re: Coding comparison using the Po-Shen Loh's new quadratic formula
Post by: hutch-- 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: