【问题标题】:Maple: Why I can not plot my function which is definrd by proc?Maple:为什么我不能绘制由 proc 定义的函数?
【发布时间】:2011-10-23 15:24:55
【问题描述】:

所以我创建了一个返回值的过程。 (对于 (2.1) 及以上的数字,sqrt 模拟是正确的)。我可以为任何给定的数字评估它,但我无法绘制它。为什么以及如何解决?

代码(转换为一维数学输入):

> 
restart:
 with(plottools):
val := 248;
sqr := proc (sqrtFrom, iterations) answer := 0; ampl := 0; number := sqrtFrom; for k to iterations do answer := 10*answer; number := sqrtFrom*10^ampl; for i from 0 while i < number do answer := answer+1; i := answer^2 end do; answer := answer-1; difr := -1; while difr < 0 do ampl := ampl+1; difr := sqrtFrom*10^ampl-100*answer^2 end do end do; return evalf(answer/10^(iterations-1)) end proc;
> 
evalf(sqrt(val));
sqr(val, 10);
plot(sqr(x, 10), x = 3 .. 5);
> 

【问题讨论】:

    标签: plot maple proc-object


    【解决方案1】:

    您需要 eval 引号。试试

    plot('sqr'(x,10), x = 3..5 ); 你得到的错误是因为 sqr 被以 x 作为参数过早地调用,它不能这样做。

    或者,如果 sqr 获得非数字参数(这就是 sqrt 的工作原理),您可以修改 sqr 本身以返回未计算值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-06
      • 2021-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多