*From*: newbie nullzwei <newbie-02 gmx de>*To*: Gnumeric Forum <gnumeric-list gnome org>*Subject*: Re: evaluation path for x^y ?*Date*: Sat, 2 Jul 2022 16:30:23 +0200

all ok, me bad, think I found it, was a misunderstanding of the branching / switch logic in src/expr.c/bin_arith/GNM_EXPR_OP_EXP. searched for but couldn't find a discussion / decision if below would be meaningful for gnumeric ... think gnumeric's 'three argument notation' for 'power' is more clear, but we c/should additional implement evaluation as in LO Calc ( and Excel? ), LO Calc: '=(-8)^(1/3)' -> '-2', they implemented it a few years ago reg. "It leads to incompatibility with MS Excel and thus, to difficulties in migration.". gnumeric: '=(-8)^(1/3)' -> '#NUM!' I tried the following: in 'power': 1. check if '1 / y' is integer, 2. check if z is 1, 3. check if '1 / y' is odd integer, if all three yes: calculate and return '- pow( - x, y )', similar in GNM_EXPR_EXP, first step don't sort out to ERR if above conditions 1. and 3. match, second calculate and return '- pow( - va, vb )', that's not 'complete', e.g. for power it could be better to evaluate 1 / y even when z <> 1 ?? and possibly it's good to evaluate negative fractional exponents too? or even evaluate things like '=(-8)^(**2**/3)' ( 'square of third root from minus eight', or 'third root from minus eight squared' )? it's just a short test if it works in general, and if it harms other calculations, gnumeric test-suite seems clean. Best Regards, b. ( for those who like to think about meaningfulness: in mathematics roots are not unary, already sqrt( 4 ) has two solutions { 2, -2 }, spreadsheets tend to prefer the simplest one which matches the first thought of 'normal people'. the problem of roots from negative is solved by complex numbers in math, for 'odd integer roots' there should be one root with only a real part, that would match 'simple minded users' expectations, thinking about complex values as result would probably exceed the capa of some such users ... --- hello @all, for private fun, Calc / Excel compatibility and easier cross-system-testing I'd like to implement evaluation of '= (-8)^(1/3)' -> '-2'. I managed it for 'power' ( by patching goffice and plugins/fn-math/functions, but despite 'EXPR_OP_EXP' seems piped through gnm_power it still produces #NUM!. can anyone describe the code path for '^' or assume where I might be wrong? TIA for any help. P.S. I do not want to start a discussion if odd roots from negative are 'good', allowed or mathematical correct ... the web is full of such ...

[Date Prev][Date Next] [Thread Prev][Thread Next] [Thread Index] [Date Index] [Author Index]