存储在字符数组的函数的导数求

编程入门 行业动态 更新时间:2024-10-25 02:29:30
本文介绍了存储在字符数组的函数的导数求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要做的就是读取包含公式的文件是什么。我需要每个方程的导数,然后在不同的.txt文件写那些衍生方程。我读过的所有方程式入字符数组的数组,现在我不知道该怎么办一旦我存储他们到数组。我真的不需要帮助编写公式到另一个文件;我知道我可以明白这一点。

What I need to do is read a file which contains equations. I need to take the derivative of each equation and then write those derivative equations in a different .txt file. I've read all the equations into an array of character arrays and now I don't know what to do once I've stored them into the array. I really don't need help writing the equations into another file; I know I can figure that out.

我需要什么帮助上找到一种方法,采取职能的衍生物。的类型将要读方程是不那么复杂;他们将是不需要的链式法则或商法则多项式。会有,但是,的的SiNx 的 COS X 和谭X 。这将被读一些示例方程。

What I need help on is finding a way to taking the derivative of the functions. The type of equations that are going to be read are not that complicated; they're going to be polynomials that don't need the chain rule or quotient rule. There will be, however, sin x, cos x and tan x. Some sample equations that would be read are.

-2x^2+2x-3 -2x+sinx-3 -x+sin2x-tanx

的三角函数不会有括号和可变永远是X。我只需要在正确的方向一推,请。

The trig functions will not have parenthesis and the variable will always be "x". I just need a push in the right direction, please.

推荐答案

什么是你真正要求一个parser.解析器基本上是一套规则来阅读这些方程和改变/读取(解析)他们每个人。我想尝试遍历文件的每一行,并区别开来考虑你有一个特定的字符集(即^意味着权力,x是参数等。);

What you're really asking for is a parser. A parser is basically a set of rules to read those equations and change/read (parse) each of them. I'd try to iterate over each line of the file, and differentiate it considering you have a specific character set (i.e ^ means power, x is the parameter, etc.);

例如,一些伪code:

For example, some pseudo code:

Open the file. While there's lines to read: Read a line - Seperate it by the operands (+,-,/,*) For each part: Find the power of x, Reduce it by one, ...(derivating rules) // no way around, you have to implement each function if you want this to work as others mentioned in the comments. Reconnect the parts into a string, Add it to a list. Print each element of the list.

如果您需要帮助的翻译成C,自讨苦吃;我将愉快地帮助你。

If you need help translating that into C, just ask for it; I'll happily help you.

更多推荐

存储在字符数组的函数的导数求

本文发布于:2023-11-29 17:33:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647105.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:导数   数组   函数   字符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!