博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
插图 引用 同一行两个插图_数学身份的优雅LED插图
阅读量:2521 次
发布时间:2019-05-11

本文共 3001 字,大约阅读时间需要 10 分钟。

插图 引用 同一行两个插图

by Chris Lam

克里斯·林(Chris Lam)

数学身份的优雅LED插图 (An elegant LED illustration of a mathematical identity)

I am a big fan of science toys. I have been looking for one that combines the elegance of math and programming for a while. However, there was not much success in the search. So, I decided to make one myself.

我是科学玩具的忠实粉丝。 我一直在寻找一种结合了数学和编程优雅的软件。 但是,搜索没有太大的成功。 所以,我决定自己做一个。

Here is a demo. The flashing LEDs are used to illustrate a mathematical identity visually.

这是一个演示。 闪烁的LED用于可视地说明数学身份。

数学 (Math)

The mathematical identity is the following. The left side of the equation is an arithmetic sum from 1 to n-1 and the right side of the equation is “”, the number of unique ways to choose 2 items from n items.

数学上的恒等式如下。 等式的左侧是从1到n-1的算术和,等式的右侧是“ ”,这是从n个项目中选择2个项目的唯一方式的数量。

It is not the identity itself that is elegant, but the visual proof itself. Let’s look at the diagram below. There are n=4 green dots in the illustration.

优雅本身不是身份本身,而是视觉证明本身。 让我们看下面的图。 插图中有n = 4个绿色的点。

For every two green dots on the bottom row, there is always a unique red dot in the triangle above that corresponds to them. That red dot is the tip of an equilateral triangle with the base specified by the green dots.

对于底行的每两个绿点,在上方的三角形中始终存在一个与之对应的唯一红点。 该红点是等边三角形的尖端,其底点由绿点指定。

Therefore, the number of ways to choose 2 green dots out of n green dots is equal to the sum of the red dots, 1 +2 + 3 + … + (n-1).

因此,从n个绿色点中选择2个绿色点的方法数量等于红色点的总和1 +2 + 3 +…+( n -1)。

In this case, it is 1 + 2 + (4 –1) = 6.

在这种情况下,它是1 + 2 +(4 –1)= 6。

This observation was originally made by Loren C. Larson in .

此观察最初由Loren C. Larson在 。

程式设计 (Programming)

While it is easy to trace the red dot from the green dots visually, it is more fun and challenging to specify the relationship in code.

虽然很容易在视觉上从绿点中追踪红点,但是在代码中指定关系更加有趣和具有挑战性。

Let us assume that we know the indices of the green dots (say, i and j). The programming challenge is to specify the corresponding index of the red dot that forms the equilateral triangle with the green dots.

让我们假设我们知道绿点的索引(例如,i和j)。 编程上的挑战是指定与绿点形成等边三角形的红点的相应索引。

It looks difficult at first glance.

乍看起来似乎很困难。

But the problem can be simplified a lot when we tweak the way that we label the red dots. We can label the red dots from bottom-up instead of top-down.

但是,当我们调整标记红点的方式时,可以大大简化该问题。 我们可以从下至上而不是从上至下标记红点。

With that indexing scheme, we can then specify the index of the red dots by the following formula.

使用该索引方案,然后可以通过以下公式指定红点的索引。

Here is the complete code used to flash the LEDs using Arduino.

这是用于使用Arduino闪烁LED的完整代码。

电子产品 (Electronics)

I solder the LEDs on a board and connect the LEDs to Arduino output pins through 1k resistors. It is very important to use the resistors because they protect the LEDs.

我将LED焊接在板上,然后通过1k电阻将LED连接到Arduino输出引脚。 使用电阻非常重要,因为它们可以保护LED。

The connection is as follows.

连接如下。

And when you put them together and load the software to Arduino, it will start flashing like below.

当您将它们放在一起并将软件加载到Arduino时,它将开始闪烁,如下所示。

Hope you enjoy this gadget!

希望您喜欢这个小工具!

翻译自:

插图 引用 同一行两个插图

转载地址:http://ucewd.baihongyu.com/

你可能感兴趣的文章
HDU2112 HDU Today 最短路+字符串哈希
查看>>
JPanel重绘
查看>>
图片放大器——wpf
查看>>
SCALA STEP BY STEP
查看>>
cocos2d-x学习笔记
查看>>
MySql中的变量定义
查看>>
Ruby数组的操作
查看>>
hdu1181暴搜
查看>>
解码字符串 Decode String
查看>>
json学习笔记
查看>>
工具:linux 性能监控工具-nmon
查看>>
fatal error C1853
查看>>
Ural 1001 - Reverse Root
查看>>
玩转webpack之webpack的entry output
查看>>
java 操作mongodb查询条件的常用设置
查看>>
黑马程序员_java基础笔记(02)...java语言基础组成
查看>>
关于缓存击穿
查看>>
对innodb 拷贝文件实现数据库的方式(转)
查看>>
python知识点 2014-07-09
查看>>
FloatingActionButton的一点学习感悟
查看>>