The following warnings occurred:
Warning [2] Undefined array key 252243 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252244 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252269 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252281 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252295 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252326 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252328 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252332 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252419 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252244 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252281 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252332 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 252419 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





HP 34s solve f'(x)=0



#10

I wanted to find the minimum of x^1/2.

I tried Fill sqrt y^x. RTN. Using solve the on board f'(x) for .1 to 1, I get a domain error. On the HP 35s, the Dieter program works like a champ. What am I doing wrong?


#11

I mean x^sqrt(x)

#12

The problem here is f'(x) samples from the function at a number of points around the given x value. By default the step size is 0.1 which means you end up with -.1-.1, which the 34S cannot deal with.

Define the [delta]X global label to set the step size yourself. See the manual entry for f'(x) for details. The [delta]X label isn't case sensitive.


- Pauli


#13

...or you could put a test in your program for negative / zero values and return "1" when they are detected. This will slow things down slightly, but the WP-34S is fast!

Nigel (UK)

#14

What puzzles me is that I use dx=.029....this seems to give better results on some problems than the default of .1 or some small dx such as 1E-06.

Still, using dx=.029, and using a tight interval for solve (1.2 to 1.4) for this function where f'(x) is real for x>0, and should equal 0 for x~1.353, why should this produce the domain error?

I clearly don't know how f'(x) is approximated on the 34s and/or how this works using solve to find f'(x)=0


#15

Quote:
...using a tight interval for solve (1.2 to 1.4) for this function where f'(x) is real for x>0, and should equal 0 for x~1.353

For f(x) = xsqrt(x) the first derivative is 1/2 xsqrt(x)-1/2 (2 + ln x).

Which is zero for x = e-2 = 0,135335.

And that's what my 35s program returns as well:
  Y001 LBL Y
Y002 RCL X
Y003 RCL X
Y004 0,5
Y005 y^x ' use x^0,5 instead of sqrt(x)
Y006 y^x
Y007 RTN
 
0,1 [ENTER] 1 [XEQ] E [ENTER]
=> SOLVING
X = 0,1353
{XEQ] F [ENTER]
=> F = 0,4791

Dieter


#16

I gave your program credit in my 1st post...indeed it worked great. I modified the program slightly so that I can then execute f(x) at that point, and have both values show simultaneously on the HP 35s 2 line display.

Still puzzled by the 34s since my dx is small (.029) and f'(x) is real all the way down to zero


#17

The 34S uses a ten point numerical derivative if it can. This means it will go five times .029 = .145 either side of the value the solver supplies. This is more than enough to bring the evaluation point negative on its own, however the solver will also attempt to bracket the root pushing it even further negative.

You could try setting flag D to allow not number and infinite results. The derivative code should fall back to lower order numerical derivatives if the function returns NaNs. I'm not sure what the solver will do, but there is some attempt to deal with things in there.

The source code for the solver and the derivative routines are in the trunk/xrom directory, if you want to investigate the internal behaviour further.


- Pauli

#18

Quote:
I gave your program credit in my 1st post...indeed it worked great.

Thank you very much. However, I basically wanted to point out that the local minimum is not located at x = 1,353 or somewhere between 1,3 and 1,4, as you wrote. Actually it is at x = 0,1353.

Quote:
Still puzzled by the 34s since my dx is small (.029) and f'(x) is real all the way down to zero

The 34s f'(x) command evaluates the user function at numerous points around x. Pauli mentioned an interval of x +/- 5 dx. With dx as large as 0,03 this means you will get significantly below zero.

I tried your function xsqrt(x) in the following way on the 34s. Two points are essential:

  1. Provide a decent value for dx. Values as small as x/100000 are fine here. I did it this way:
       LBL [delta]X
    X=0?
    INC X ' for x=0, continue with x=1
    SDR 05 ' divide by 100000
    RSD 01 ' round to one significant digit
    RTN
  2. The f'(x) command returns an approximation (!) of the first derivative. How accurate may this estimate be? Six digits? Eight? Ten? More? We simply do not know. So we cannot expect a result of exactly zero at the local minimum or maximum. There is not much sense in having the solver going through half a dozen more iterations in order to find the 10th, 12th or 16th digit of a solution that is not that exact anyway. So it's a good idea to stop the solver as soon as the derivative drops below, say, 1E-9 or 1E-10. A simple round command will do that. The following code for the derivative rounds all results below 5E-10 to zero.
       LBL "FX"
    ENTER
    SQRT
    y^x
    RTN
     
    LBL "DER"
    f'(x) "FX"
    RDP 09 ' round to nine places
    X<>0? ' if not equal to zero,
    X<> L ' restore unrounded result
    RTN
This way everything works on the 34s as well:
   0,1 ENTER 1   SLV "DER"
=> 0,13533528322
This agrees in 10 digits with the true result.

Addendum: unlike simple implementations, the 34s multi-point derivative seems to handle large dx values very well. In the above code, replace SDR 05 with SDR 02, and RDP 09 may become RDP 12. For the same initial guesses, the solver should now return a result with 14 valid decimals.

Dieter

Edited: 8 Oct 2013, 4:20 p.m.


Possibly Related Threads…
Thread Author Replies Views Last Post
  XCas / Prime "solve" question Nigel J Dowrick 4 1,944 11-08-2013, 04:01 AM
Last Post: Nigel J Dowrick
  Using the Prime to solve for eigenvalues Michael de Estrada 28 8,321 10-27-2013, 07:21 AM
Last Post: Tarcisi C
  HP Prime Define: Use with solve, etc. Helge Gabert 0 981 10-23-2013, 06:24 PM
Last Post: Helge Gabert
  Good puzzle for kids to solve on 35s? snaggs 11 3,276 09-18-2013, 10:40 PM
Last Post: David Hayden
  September SOLVE Newsletter Robert Prosperi 4 1,782 09-07-2013, 01:12 AM
Last Post: Mic
  [HP Prime CAS] Solve Commands (Bugs and Request) CompSystems 10 3,735 08-08-2013, 12:34 PM
Last Post: Gilles Carpentier
  41 SOLVE & INTEG Bank-switched Implementation. Ángel Martin 0 887 06-21-2013, 11:31 AM
Last Post: Ángel Martin
  HP-17bII+ Solve Compatibility Issues Robert Prosperi 7 2,811 04-22-2013, 10:11 PM
Last Post: Gerson W. Barbosa
  WP 34s Solve Richard Berler 3 1,453 04-05-2013, 10:21 AM
Last Post: Richard Berler
  Math Challenge I could not solve Meindert Kuipers 22 6,038 01-05-2013, 04:43 PM
Last Post: Thomas Klemm

Forum Jump: