# [GiNaC-list] arithmetic error on concat two expressions

Kraus Philipp philipp.kraus at flashpixx.de
Sat Aug 7 15:33:20 CEST 2010

```Thanks, I see it, but if I create a derivatrion "diff" the sign is
important:
If I run formula.diff(a, 1):

[0.5*(t-ax^3)^2]' => -(t-a*x^3)*x^3
[0.5*(ax^3-t)^2]' => (a*x^3-t)*x^3

On my code I parse the formula (0.5)*(t -(formula)^2 and substitute
formula with
another formula. I do not understand why the minus sign is not
interpreted correctly.

I think GiNaC does create a pattern matching and not evaluate the
correct expression.
In my opinion the first expression is the correct one, GiNaC creates
the second. Why?
How can I tell GiNaC that it interpret the expression arithmetically
correct?

Thanks

Phil

Am 06.08.2010 um 22:41 schrieb Doug:

> (-1)^2 == 1^2
> therefore
> (-expr)^2 == expr^2
> therefore
> (t-exp(x))^2 == (-(t-exp(x))^2 == (exp(x) - t)^2
>
> Do you see it now?
>
>
> I'm now a little bit confused, cause I'm working for a long time
> with this problem and I don't see my "thinking error".
> If I have an expression eg exp(x), so (t-exp(x))^2 is not the same
> (exp(x)-t)^2. Sorry I don't see it
>
> Thanks
>
> Phil
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list
>
> _______________________________________________
> GiNaC-list mailing list
> GiNaC-list at ginac.de
> https://www.cebix.net/mailman/listinfo/ginac-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cebix.net/pipermail/ginac-list/attachments/20100807/44c74997/attachment.htm>
```