Home  >  Article  >  Backend Development  >  How to implement the Pythagorean Theorem in PHP

How to implement the Pythagorean Theorem in PHP

藏色散人
藏色散人Original
2021-07-09 09:30:371910browse

php method to implement the Pythagorean Theorem: first create a PHP sample file; then define two variables; then find the sum of squares through "($x * $x) ($y * $y);"; Finally, use "sqrz($z);" to find the square root.

How to implement the Pythagorean Theorem in PHP

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How does php implement the Pythagorean Theorem?

PHP: Simple Mathematics Pythagorean Theorem

Using PHP to calculate the Pythagorean Theorem

Let me explain here. I am new to PHP and it is also my first language. Please Please take care of us all!

PHP

<?php
    $x = 3; //定义一边
    $y = 4; //定义二边
    $z = ($x * $x) + ($y * $y); //求平方和
    $num = sqrz($z); //求平方根
    echo &#39;结果为:&#39;  . $num; //输出结果
?>

Please give me some advice!

Related introduction:

The Pythagorean theorem is a basic geometric theorem, which means that the sum of the squares of the two right-angled sides of a right triangle is equal to the square of the hypotenuse. In ancient China, the right triangle was called Pythagorean, and the smaller of the right-angled sides was the hook, the other long right-angled side was the strand, and the hypotenuse was the chord. Therefore, this theorem was called the Pythagorean theorem, and some people also called it the Shanggao theorem.

There are about 500 ways to prove the Pythagorean Theorem, which is one of the theorems with the most proof methods among mathematical theorems. The Pythagorean Theorem is one of the important mathematical theorems discovered and proved by mankind in the early days. It is one of the most important tools for solving geometric problems using algebraic thinking, and it is also one of the links between numbers and shapes.

In China, Shang Gao during the Zhou Dynasty proposed a special case of the Pythagorean theorem of "hook three strands, four strings and five". In the West, the first person to propose and prove this theorem was the Pythagoreans in ancient Greece in the 6th century BC. He used deduction to prove that the square of the hypotenuse of a right triangle is equal to the sum of the squares of the two right-angled sides.

How to implement the Pythagorean Theorem in PHP

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to implement the Pythagorean Theorem in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn