HP Forums
Bug or badly suboptimal result for derivative - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Bug or badly suboptimal result for derivative (/thread-5357.html)



Bug or badly suboptimal result for derivative - quinyu - 12-18-2015 03:18 PM

The CAS, when asked to derive the expression sin(x-cos x) returns a gigantic expression (I am not going to copy it here), containing imaginary units and otherwise close to unreadable.

The derivative could be properly determined according to the following steps (chain rule):
f(u)=sin(u) => f'(u)=cos(u)
f'(g(x))=cos(x-cos(x))
g(x)=x-cos(x) => g'(x)=1+sin(x), therefore
dy/dx=f'(g(x))g'(x)=(cos(x-cos(x)))*(1+sin(x))

I am having software 2015.6.17 (8151); HW ver C; CAS ver 1.1.2-11; OS v0.037.526.


RE: Bug or badly suboptimal result for derivative - CR Haeger - 12-18-2015 03:39 PM

(12-18-2015 03:18 PM)quinyu Wrote:  The CAS, when asked to derive the expression sin(x-cos x) returns a gigantic expression (I am not going to copy it here), containing imaginary units and otherwise close to unreadable.

The derivative could be properly determined according to the following steps (chain rule):
f(u)=sin(u) => f'(u)=cos(u)
f'(g(x))=cos(x-cos(x))
g(x)=x-cos(x) => g'(x)=1+sin(x), therefore
dy/dx=f'(g(x))g'(x)=(cos(x-cos(x)))*(1+sin(x))

I am having software 2015.6.17 (8151); HW ver C; CAS ver 1.1.2-11; OS v0.037.526.

Works okay for me with CAS and Radians set. Get interesting results with Degrees set.

[attachment=2980]


RE: Bug or badly suboptimal result for derivative - Maro - 12-18-2015 03:49 PM

which CAS settings do you use?

when using "Simplify: Minimum" (page 1 settings) I get the compact result as expected. However, when using "Simplify: Maximum" I get a very (!) large expression too. I would expect it the other way around ... really strange ...

Edit: HP 50g: gives the expected (sin(x)+1)*cos(x-cos(x))


RE: Bug or badly suboptimal result for derivative - quinyu - 12-18-2015 04:02 PM

I'm also set to radians. Also, Exact, Use Root, no Princ, no Comp, no i, simplify=maximum. I'd expect it to work at least as good as simplify=minimum...

By the way, the HP 50g finds the proper derivative. So does the TI-nSpire CAS, the TI-89 Titanium, the TI-92, Mathematica 10.0, Maple 18, MATLAB R2015a (in MuPAD as well as in the main prog). Casio ClassPad II emu 2.0000.4000 does well with it too. So something is happening that's pretty specific to the prime.


RE: Bug or badly suboptimal result for derivative - roadrunner - 12-18-2015 08:24 PM

Try doing this:

[attachment=2984]

With these settings:

[attachment=2985]

Do you get something different?

-road


RE: Bug or badly suboptimal result for derivative - quinyu - 12-18-2015 09:23 PM

Settings I set as required, but I get a red X error for f:=(u) -> sin(u) already. How to resolve?


RE: Bug or badly suboptimal result for derivative - roadrunner - 12-19-2015 12:10 PM

That's weird. It only gives me the red X error when I do that assignment in Home. In CAS it works ok.

Sometimes I get strange random CAS variables that mess things up. I don't know what I do to get them but maybe you have some too. Check your CAS variables and reset any that look strange, also make sure you don't have f, g, u, x, etc. predefined as something strange.

-road


RE: Bug or badly suboptimal result for derivative - quinyu - 12-19-2015 01:46 PM

Uhm, maybe I am wrong at some very basic level... is that a colon and an equal sign, after each other, or is that the symbolic depiction of some other (likely assignment) function? Because I have typed a : then an = in the input.


RE: Bug or badly suboptimal result for derivative - roadrunner - 12-20-2015 12:37 PM

A colon and an equal sign := is correct. Something else must be wrong. If you have an emulator you can try copy and pasting this:

f(u):=sin(u)

or this:

f:=(u)->sin(u)

They should both give the same result.

-road


RE: Bug or badly suboptimal result for derivative - quinyu - 12-20-2015 02:05 PM

Okay, now it works; no clue why it did not previously. Either way, even though I can now make the calculator to follow what I would do in that given situation (which is good for checking the procedure), I am still unable to get the calculator do it on its own. Are there any (hidden) switches to diff so as to influence the preference to the possible strategical steps in the evaluation tree?


RE: Bug or badly suboptimal result for derivative - roadrunner - 12-21-2015 03:18 PM

There are no hidden switches that I am aware of. I'm glad you got it working.

-road