Current location - Training Enrollment Network - Mathematics courses - How to Mathematize Problems in Programming
How to Mathematize Problems in Programming
1.

Mathematical formula:

The decimal number a is represented by the binary number a. .. A2 A 1 A0, where An=0,1; n=0, 1,2,3,4 ...

If 4 means 100, then

a0*2^0+a 1*2^ 1+a2*2^2 .。 +An*2^n= A

Because An is either zero or 1, every time you divide the equation by 2, you will get a number+1 (or +0) divisible by 2.

Divide by 2 and take the remainder on the left, and you get.

A0 A 1 A2. and write it in reverse. A2 A 1 A0 is his binary sequence.

The purpose of division is to eliminate 2 n and get an, where n=0, 1, 2, 3. .

The above An * 2 n represents An multiplied by 2 to the n power.

Think in decimal, such as 123456, and divide him by 10.

The first result is 12345, and the rest is 6.

The second result is 1234, and the rest is 5.

Press down in turn until the order of 6, 5, 4, 3, 2, 1 is reversed.

2. How to simplify the mathematical processing in manual programming?

As we all know, there are two programming methods for CNC machine tools: manual programming and automatic programming.

Manual programming is still widely used in point machining and plane contour machining with simple shape. A key and tedious link in manual programming is the mathematical processing of graphics, that is, it is usually necessary to calculate the coordinates of each base point or node of machining contour.

The traditional calculation method is to establish a mathematical equation and solve the equation to get the coordinates of key points. This process is time-consuming and error-prone for programmers.

With the popularization of AutoCAD application, in the process of manual programming, we can use AutoCAD commands such as INQUARY and CALCULATE to replace complex mathematical operations and find out the coordinates of each point quickly and accurately. Here are a few examples to introduce the specific operation methods.

For example, in order to write the NC machining program of the part as shown in figure 1, it is necessary to find the coordinate values of the base points (A, B, C, D, E, F and G as shown in figure 2) in the outline of the part. It is difficult and tedious to deal with it mathematically. The following describes how to use AutoCAD2000 to obtain the coordinate values of each base point.

Figure 1 NC machining program of parts Step 1: Drawing parts with AutoCAD2000. Figure 2 Part Drawing Step 2: Move the origin of user coordinate system (UCS) of AutoCAD to the programming origin (O) of the part.

The operation method is as follows: drop-down menu tool → move UCS→ click the left mouse button to pick up the programming origin O; Or, drop-down menu tool → new UCS→ origin → left mouse button to pick up programming origin O. Step 3: drop-down menu tool → query →ID point → left mouse button to pick up point A. At this time, the coordinate values of point A in the programming coordinate system will be displayed on the comMAND line (mand), that is, the data needed for programming will be obtained.

The coordinate values of other points (b, c, d, e, f, g) and the coordinate values of the arc center can be obtained in the same way. Or, drop down menu tools → Query → List → Left mouse button to pick up points A, B, C, D, E, F and G respectively, and the coordinate values of each point will be displayed.

Similarly, for layered cutting, wire cutting, circular cutting and tool radius compensation, you can use the OFFSET command in AutoCAD to offset the outline of the part appropriately to generate the required tool machining trajectory, and then use the above method to find the coordinate values of each programming point, which improves the efficiency and accuracy of manual programming. In addition, the geometry calculator of AutoCAD is sometimes useful in the mathematical processing of manual programming.

Geometric calculators, like ordinary calculators, can perform operations of addition, subtraction, multiplication, division and trigonometric functions, and the calculation results can also be directly used as the parameters of commands. Different from ordinary calculators, AutoCAD geometry calculator can also do geometric operations.

It can not only directly calculate the coordinate values of each coordinate point, but also capture the coordinate points on the screen to participate in the operation by using the Osnap mode of AutoCAD, and automatically calculate the geometric coordinate points. For some points that are not directly drawn in the drawing, we need their coordinate values, so we can use AutoCAD geometric calculator to calculate them.

Type CAL and mand: at the command prompt to start AutoCAD geometry calculator. CAL is also a transparent command, and you can start the geometry calculator at any time under other commands.

In addition, you can also use the CAL command in AutoLISP programs. For example, we require the coordinate values of two bisectors between two known points A and B, and the operation process is as follows: mand: cal ↙ > > expression:plt(end,end, 1/3)↙& gt; & gt select the entity for endpoint capture: (capture point a) > > select the entity for endpoint capture: (capture point b). that is, the coordinate values of the point from point a 1/3 line segment (AB) are displayed on the command line.

Similarly, as long as the above expression: is changed to Plt(End, End, 1/3), the coordinate values of points with a distance of 2/3 line segment (AB) can be obtained. In addition, you can also use AutoCAD AutoLISP language to design and compile CNC programs with AutoCAD graphic data, so I won't go into details here.

In short, in modern machinery manufacturing, CNC machine tools are more and more widely used, and the current automatic programming software is expensive. It is of practical significance to use AutoCAD graphic data for NC programming. (End).

3. Mathematical problems about the program

The stupidest way is to exhaust.

Try one by one with a loop.

There are many programming languages. I don't know what language you want to write the program in.

void main(){ for(D = 0; D & lt= H; D++) If d+(h-d)/4 = = hCout <; & ltD & lt& lt““”& lt& lth-D; } with braces! ! This is a program written in C language. What programming language do you want to write in? I only know C language, matlab and a little assembly. Please rewrite it according to the chart I gave you.

You have to program in vb. I rewritten this. I haven't studied vb. There may be a mistake in it. Tell me when you find a mistake.

Dimension d, H d=0

H=? H should be a number, right? D while doing

If D+(H-D)/4=H, then

Print d

endif

ring

4. How to transform the mathematical problems in the paper into c++ codes?

This seems to produce an ideal surface. A different, different result.

You need to know how to discretize surfaces with Bernstein-Bessel polynomials.

Firstly, the cycle calculation point is determined and the Bessel coefficient is calculated.

With the coefficient, it can be calculated bit by bit in the definition domain-similar to spatial interpolation calculation.

After you have a numerical calculation method, describe your calculation in c/c++ language, which is called code.

Commonly used in finite element method, the function value of a point in a triangle is expressed by the function values of three vertices of the triangle.

The calculation method of numerical calculation is to determine the calculation point and calculate its area coordinates, with the area coordinates as the weight.

Weighted average.

It's complicated here. But the basic concept is similar, and the constraint boundary is your surface boundary. Ideal surface, this paper gives the parameter equation.

5. How to learn the mathematical basis of programming?

Since you like programming, you should learn a language seriously. If you study Microsoft, you should start with VB. VB is a good introductory language, intuitive and simple, and it is a very good introductory language.

At least two books should be prepared. A book cannot contain all the contents of VB. When reading a book, you can cross-read, and what is not mentioned in one book can be seen in another book, which is very beneficial to learning and can also ensure the integrity of the knowledge you have learned. Learning programming is a long process. Don't worry. It is necessary to combine theory with practice. Routine books are also important. Reading the source code is also very helpful for learning. After you learn this VB language, it's easy to learn other languages. You can try C language and learn in the order of C-C++-VC, which is helpful for the coherence of knowledge. I also hope you can learn well.

Or learn Delphi, the introduction is simple, similar to VB, but more powerful than VB, you can do the introduction, you can be stronger and bigger. How to learn programming 1 Defining the purpose of learning learning programming is very useful for most IT professionals. Learning programming and being a programmer, from a personal point of view, can solve the problems encountered in the use of software, improve the existing software, add important weight to find your ideal job and help you get a good position on the job search road; From the national point of view, an excellent programmer will always be the object of contention if he can make due contribution to China's software industry.

Learning programming can also exercise our thinking and make our logical thinking more rigorous; If you can continue to enjoy the fun of innovation, you will always have the opportunity to be at the forefront of high technology, because programming itself is a creative work. The era of knowledge economy has brought us unlimited opportunities. If you really want to master computer technology and make a difference in the IT industry, having certain programming ability is a basic condition and requirement.

2. Laying a good foundation for programming can be summarized as: (1) Mathematical foundation From the history of computer development and application, the mathematical model and architecture of computers were put forward by mathematicians, and the earliest computers were also designed for numerical calculation. Therefore, to learn computers well, you must have a certain mathematical foundation, and a scholar's high school level is almost the same.

(2) Cultivation of Logical Thinking Ability Programming should have certain logical thinking ability, and the cultivation of "logical thinking ability" should be practiced for a long time. To be an excellent programmer, the most important thing is to master programming ideas.

To do this, we must gradually accumulate in repeated practice, observation, analysis, comparison and summary. Therefore, in the process of learning programming, we don't have to wait until we fully understand everything before we start practicing. As long as you know the general situation, you must dare to experience it yourself.

Everyone has a first time. Some problems can only be understood through practice, and only through practice can we turn the knowledge in teachers and books into our own. Masters are so successful.

(3) Choose the right entry language to face various languages, and in what order should we learn? Programming tools are nothing more than the following categories: 1) Tools for developing local application software include: Visual Basic, Delphi, VC++ (C++ Builder) and so on. Database development tools include: Visual Foxpro, Oracle Developer, Power Builder, etc. Java and other cross-platform development tools.

3) Network development is a client development tool, such as Java Script is a server development tool, such as PHP, ASP, JSP, ISAPI, NSAPI, CGI, etc. In the above different environments, VB method is easy to understand, the interface design can be configured, and it is easy to learn and use.

It is more suitable for scholars to choose VB as the entry direction. 3. Pay attention to understand some important concepts. What a programming book sees is nothing more than variables, functions, conditional statements, loop statements and other concepts. However, in order to truly apply programming, we must deeply understand these concepts and apply them on the basis of understanding. Don't simply learn grammar and structure, but thoroughly understand the application examples of these grammars and structures, so as to draw inferences from others.

4. Mastering programming ideas Learning a language or developing tools, grammatical structure and function call are secondary, and the most important thing is to learn its ideas. For example, learning VC requires learning the internal mechanism of Windows and what threads are.

; To learn, you must know VTALBE, class factory, interface and idl.

The key is to learn an idea, with which we can learn by analogy.

5. Practice more and communicate more. Mastering programming ideas must be practiced and experienced in the actual work of programming. In the initial stage of programming, you should always design your own program. Don't stick to a fixed way of thinking when designing, but think of several solutions when encountering problems.

This requires more communication. Everyone has different ways of thinking, different angles, and each has its own brilliance. Through communication, he can constantly absorb the strengths of others, enrich his programming practice and help him improve his level. Hands-on programming is the embodiment of the application of creative thinking and a good way to cultivate logical thinking.

6. It is not difficult to develop good programming habits, but it is important to keep learning after getting started, which is quite long. In the meantime, we should pay attention to developing some good programming habits.

The programming style greatly affects the program quality. A good programming style can make the program structure clear and reasonable and make the program code easy to maintain.

For example, the indentation arrangement of code, the consistency of variable command rules, and the comments of code. 7. Online learning programming. You can learn many different programming ideas, methods, experiences and skills online, and there are a lot of tools, works and related counseling materials available for download.

For example, the website "Programming Classroom" (/) provides rich and practical programming technical articles, selected controls, source code downloads, computer exams, recommendations of related software and programming books, and so on. 8. It is in line with the "theory" to strengthen the re-learning of computer theoretical knowledge.