An Expert Is actually By My Side

Chapter 100: Contestant No. 101 hands in his paper in advance?

Views:

Compared with Academician Zhan Yongshu's surprise, Hao Yun did not think of it as particularly complicated when he was thinking about this problem. He simply came up with this method while scratching his head.

The program first guesses a value close to 1/sqrt(number), and then uses Newton's iteration formula to perform an iterative operation.

From an algorithmic logic point of view, in fact, the code he rewrote is not much different from the code of the previous Q_Sqrt function. The Q_Sqrt function defined by Glacier Engine in the math.c file actually adopts this idea.

The only difference is probably the mysterious number - 0x5f375a86.

According to the principle of Newton's iterative algorithm, the closer the guess value is to the final result, the fewer the number of iterations. The mysterious number 0x5f375a86 is used to calculate the guess value.

After several attempts, Hao Yun unexpectedly discovered that if the number "0x5f375a86" is used, the obtained y will be very close to 1/sqrt(n), so that when the Newton iterative algorithm is finally executed, only 2 generations are needed. Achieve the precision he needs!

As for how this number was derived

Hao Yun couldn't explain it either.

After all, he just followed his mathematical intuition and felt that the number selected in the original program was not useful enough, so he tried to change it to a more useful number.

He tried several times at first, but found that the changed numbers were not as useful as the original ones. Until he suddenly had an idea and tried this 0x5f375a86, and found that only two iterations were needed to complete the entire calculation process.

To be honest, he himself was surprised.

possible…

Does this have something to do with his mastery of mathematical attributes

All in all, after using the special number 0x5f375a86, judging from the number of operation steps alone, the operation efficiency of the entire function will be twice as fast as the Q_Sqrt function defined in the original math.c file!

As for what effect this result will have...

To be honest, Hao Yun didn't have an accurate concept.

After all, his understanding of this glacier engine is far from the level of people in the industry.

Although he has made games before, he has only made 2048. Temple Escape uses a development software that has the same origin as Glacier Engine, but that game was basically completed by Li Zongzheng alone. Hao Yun did not participate in the development process at all, even if he participated 80% Will study the source code of the engine.

The game development tools in this world have evolved to a fool-proof level. Except for those large-scale productions, the vast majority of small and medium-sized games can be realized solely by relying on development tools and second-level programming levels.

"... Speaking of which, how much has the efficiency of the test engine been improved? Isn't there a scoring software or a game for testing on this computer?"

Hao Yun searched carefully on the computer, but could not find any tool software that could be used to score the engine, nor could he find a game that could test the engine's performance.

In fact, the organizers did not prepare such a thing.

After all, from the beginning, they never considered that anyone could actually complete this proposition.

"I'll go, are you doing knitting?"

After searching for a while, he still couldn't find the detection tool. Hao Yun looked at the screen dumbfounded, completely at a loss.

You can’t just develop a game on the spot to run scores, right

Although it is not impossible, there is no material at hand, and the computer cannot be connected to the Internet. You can't start from the most basic materials, right

After some struggle, Hao Yun finally gave up.

never mind.

Anyway, I can't think of a better optimization method...

Thinking of this, Hao Yun sighed, reached out and clicked the submit option in the exam program, and then took his hands off the keyboard.

The exam only has a maximum time limit of three days, and there is no minimum submission time. You can leave the exam at any time after submitting your answers.

Because no points will be awarded even if you hand in the paper in advance, most people will choose to stay up until dinner time to hand in the paper and go out to eat with friends who came to compete together.

Hao Yun had planned this at first, but there was nothing in his cubicle. He had nothing to do except sit and wait, so he had no choice but to come out of his cubicle.

When leaving the examination room, the security guy was still standing at the security checkpoint.

Hao Yun glanced at him, and he stared at Hao Yun for a while.

"Go to the bathroom? You're going in the wrong direction."

"No, I finished the exam."

"Test, are you finished?"

"Well," Hao Yun nodded and pointed to the exit of the gymnasium, "Can I go out?"

Finally recovering from his daze, the security guy nodded dumbly and untied the isolation tape blocking the entrance.

The Hope Cup two years ago was also played at Xia Dong Normal University, and he was also standing here to maintain order. If he remembered correctly, the first candidate to submit his paper was at five o'clock in the afternoon.

But now, it's not even an hour before the exam officially starts at nine o'clock...

Is this really a blank paper

After all, he is also a strong finalist from tens of thousands of works, so he won't hand in a blank test, right? !

In fact, it was not just the security guards standing at the entrance of the examination room who were surprised.

The examination committee members standing at the backstage of the examination room were far more surprised than everyone here.

Especially Professor Zhang Cunhao.

After reading the code rewritten by Hao Yun, everyone was dumbfounded.

Professor Zhang Cunhao, who stared at the dense calculations on the draft paper and calculated it countless times in disbelief, finally couldn't help but uttered a curse word.

"Damn it! How did this guy... come up with this number?"

this…

This is incredible!

Just changing one guess number increased the computing efficiency of the entire function by a full two times? !

Standing next to Professor Zhang Cunhao, Feng Zhengqing, the manager of Longwei Group's software development department, quietly pulled him in and asked in a low voice, "How much operating efficiency can be improved if this is used on the Glacier Engine?"

"A conservative estimate of 20%. There are still a lot of related operations for the inverse square reciprocal in the 3D engine... "

"Why are there so many?" Manager Feng was slightly moved.

As a layman, he didn't know so many things, nor did he understand what Newton's iterative algorithm was. He just thought it was incredible!

Although the Glacier Engine is not a core research and development project of Longwei Group, there are definitely many computer experts in the project team. However, so many people have not discovered this improvement method, but it was discovered by a student

No one else would be able to believe it!

Professor Zhang Cunhao was thinking hard in front of the full draft paper, although he gradually felt that this thing was beyond the research field he was familiar with.

Standing next to him was an old professor from the Capital National Defense University. After being silent for a long time, the old professor also let out a heartfelt sigh.

"Incredible... I didn't expect that this guy would find a breakthrough in the most unlikely place. I always thought that the functions in the math.c file were perfect enough, and could be used directly like tools such as addition, subtraction, multiplication and division. No. To think that there is such a magical way to push the boundaries of perfection one step further."

"This guy is a talent!"

I don't know what was going on in his mind, but a hint of confusion suddenly appeared in Professor Zhang Cunhao's silent expression.

After struggling for a long time, he looked at his teacher, Academician Zhan Yongshu.

"But with all due respect, is this answer really okay?"

Academician Zhan Yongshu glanced at him.

"Aren't you still convinced?"

"I'm not dissatisfied, I just feel... a little bit frustrated," Professor Zhang Cunhao held it in for a long time before speaking out what was in his heart, "This is not a solution in a procedural sense at all, and he didn't even modify a single line of code at all. Anyone can see it... This is just mathematics!"

Yes, this is just math!

That contestant just modified a random number, which happened to make the underlying function that calculates the "inverse square reciprocal" perform a few fewer Newton iterations, and then achieved the optimization of the engine by "adding up a little makes a lot"

After all, why is it this number? !

After all, he was not a mathematician. Zhang Cunhao almost collapsed thinking about it, but he couldn't think of anything.

Looking at the crazy students, Academician Zhan Yongshu suddenly smiled.

"Who says it isn't?"

He didn't expect how this number was calculated, and he had no clue at all.

Completely relying on intuition

Similar situations are not unknown. Some mathematical constants were actually guessed based on experience at the beginning, and it was not until more than ten years or even centuries later that the mathematical principles behind them were proved.

Thinking of this and looking at the candidate leaving the examination room, Academician Zhan Yongshu couldn't help but sigh softly in his heart.

possible…

This is genius.