Code:

...
{pt = new node; pt->tn=0; pt->v=0; pt->op=ch;
pt->arg1=NULL; pt->arg2=NULL; next();
...

I'm not surprised you're finding this program difficult to debug. Are you planning to enter it in the next IOCCC competition or something?

Use one statement per line, and use sensible variable names (i.e. meaningful). Then you can step through it with the debugger and see exactly where it goes wrong. And use correct formatting too, although I appreciate that posting code without code blocks loses the formatting. Repost correctly formatted code and I'll have a go.

BTW, the derivative of 2x+3-1 is just 2. In general, d/dx x^n = nx^(n-1)

Here's an interesting puzzle for you if you're into calculus. d/dx x^2 = 2x. But d/dx (x+x+x...) (with x x's, so if x=5 then this is d/dx (x+x+x+x+x) ) which is 1+1+1...(x times) = x. Why the difference?

Both equations are absolutely correct; when faced with this contradiction, people will often say something like "well d/dx x^2 isn't 2x", or "well d/dx (x+x+x) isn't 1+1+1", but neither of those objections is valid.