图形计算器:如何找到图的适当部分,以显示 [英] Graphing calculator: how to find the appropriate part of the graph to show

查看:194
本文介绍了图形计算器:如何找到图的适当部分,以显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个图形计算器(你知道,人们在那里你在一个公式输入,让我们说X ^ 2,你会得到该函数的图表)。我遇到的问题是,如何偏移和缩放图的视图,以显示该函数的有趣部分

I am working on a graphing calculator (you know, one where you type in a formula, let's say x^2 and you get the graph of that function). The problem I am having is how to offset and scale the view of graph as to show the interesting section of the function.

我已经用尽了所有的简单的想法,我有。让我告诉一些示例: - 的sin(x)=>有趣的部分是y之间= [-1,1]和偏移(0,0) - X ^ 2 =>吸引部为y = [0,100]和偏移之间是(0,0)。 (100已经拾取任意) - 100X ^ 2 - 10000 => Y = [-10000,100 *]和偏移量(-10000,0)

I have exhausted all the 'simple' ideas I have had. Let me show some example: - sin(x) => interesting section is between y = [-1,1] and offset (0,0) - x^2 => interesting section is between y = [0, 100] and offset is (0,0). (100 has been picked arbitrarily) - 100x^2 - 10000 => y = [-10000, 100*] and offset is (-10000, 0)

我想我可以指定一个'范围'和'抵消'为每种类型的功能,并创建一些数学加/乘/等这些范围一起以同样的方式的结果将被计算。然而,这需要创造一些数学和很好地隐藏逻辑上的缺陷是太高的潜力。

I figured I could assign a 'range' and 'offset' for each type of function and create some math to add/multiply/etc these range together the same way a result would be calculated. However, that requires 'creating' some math and the potential for well hidden logical flaws is way too high.

必须有一个非太艰难的方式做到这一点,但我无法找到它。是否有一些具体的条件来搜索?任何指针算法?

There must be a non-too-difficult way to do this, but I just can't find it. Are there some specific terms to search for? Any pointers to an algorithm?

推荐答案

这是多么有趣的问题。我从来没有想过这一点,但我会通过寻找启动:

What an interesting problem. I've never thought about this, but I'd start by finding:

  1. 最近的原点的方程的两个根(您可以使用牛顿迭代算法)。
  2. 的最大值和最小值。为此,你需要找到的地方,该函数的导数为0,你可以做数值微分,发现,大致,其中衍生穿越0,或斑点,如果你感觉雄心勃勃的你可以使用自动分化。一旦你找到了0交叉而衍生的,回去和评估那些斑点原方程。
  3. 该函数在每个这些x轴的点的值。
  1. The two roots of the equation nearest the origin (you can use the Newton-Raphson algorithm).
  2. The maxima and minima. For this you need to find the the places where the derivative of the function is 0. You could do numerical differentiation and find, roughly, the spots where the derivative crosses 0, or if you're feeling ambitious you could use automatic differentiation. Once you've found the 0-crossings of the derivative, go back and evaluate the original equation at those spots.
  3. The value of the function at each of these x-axis points.

然后把相隔最远点在每个轴上,加10%给他们,并把它们作为边框的坐标。

Then take the furthest apart points on each axis, add 10% to them, and use them as the bounding box coordinates.

有明显的边缘情况:该功能可以没有,一个,或无限多根。功能可能没有最大值或最小值。我真的不知道如何才能检测到这些情况,但你可能想建立在限制步骤(1)和(2),如发现前N根或前N个极值,从0另一个限制数出可能会确保你的游览在一个轴上不会小于N倍另一轴偏移了。

There are obvious edge cases: the function may have no, one, or infinitely many roots. The function may have no maximum or minimum. I'm not really sure how you can detect these cases, but you might want to build in limits to steps (1) and (2), like find the first N roots or the first N extrema, counting out from 0. Another limit might be making sure your excursion on one axis is never more than N times the excursion on the other axis.

这篇关于图形计算器:如何找到图的适当部分,以显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆