<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,</p>
<p>any opinion on the subject below? I don't really want to code a
patch that never gets accepted later...<br>
</p>
<div class="moz-forward-container"><br>
<br>
-------- Weitergeleitete Nachricht --------
<table class="moz-email-headers-table" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Betreff:
</th>
<td>[GiNaC-devel] evalf() on cube roots</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Datum: </th>
<td>Wed, 31 Oct 2018 18:02:50 +0100</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Von: </th>
<td>Jan Rheinländer <a class="moz-txt-link-rfc2396E" href="mailto:jrheinlaender@gmx.de"><jrheinlaender@gmx.de></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">An: </th>
<td>GiNaC development list <a class="moz-txt-link-rfc2396E" href="mailto:ginac-devel@ginac.de"><ginac-devel@ginac.de></a></td>
</tr>
</tbody>
</table>
<br>
<br>
Picking up this old thread...<br>
<br>
I would like to submit a patch that allows choosing the convention
for<br>
negative cube roots between the solution on the principal branch
and the<br>
real-valued solution.<br>
<br>
That is, in the cln library, file
complex/transcendental/cl_C_expt_C.cc<br>
I would like to handle the following case separately:<br>
<br>
y rational and y ratio m/n<br>
x rational and x < 0<br>
n odd<br>
<br>
What about introducing a flag called (e.g.)<br>
cln::cl_odd_roots_of_rationals_real (similar to<br>
cln::cl_inhibit_floating_point_underflow)?<br>
<br>
If the flag is false (default), the above case evaluates to
exp(log(x) *<br>
y) as before<br>
<br>
If the flag is true, it evaluates to (-1)^m * (-x)^(m/n)<br>
<br>
Would such a patch be acceptable?<br>
<br>
Greetings,<br>
<br>
Jan Rheinländer<br>
<br>
<br>
Am 02.08.2015 um 21:55 schrieb Richard B. Kreckel:<br>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">On 08/02/2015 08:59 PM, Jan Rheinländer wrote:
<blockquote type="cite"><pre class="moz-quote-pre" wrap=""><blockquote type="cite"><pre class="moz-quote-pre" wrap="">There isn't. GiNaC, like almost all other systems, returns the solution
on the principal branch, compatible with exp(log(-1)/3).
</pre></blockquote>I suppose there is some excellent mathematical reason for this...
</pre></blockquote>Actually, there isn't. Branch cuts are a matter of convention.
Nothing more but also nothing less.
<blockquote type="cite"><pre class="moz-quote-pre" wrap="">but for
me it means that I can't use GiNaC to verify Cardano's formula for a
cubic function:
<blockquote type="cite"><pre class="moz-quote-pre" wrap="">x = (-1 - sqrt(2))^(1/3) + (-1 + sqrt(2))^(1/3);
</pre></blockquote>(-1-sqrt(2))^(1/3)+(-1+sqrt(2))^(1/3)
<blockquote type="cite"><pre class="moz-quote-pre" wrap="">evalf(x^3 + 3 * x + 2);
</pre></blockquote>3.3544445609126528848+8.9073474964875349776*I
Surely there must be a way to verify such a formula in GiNaC???
</pre></blockquote>It should be straightforward to replace such rational expressions by the
form you want them to be in before calling evalf(), using techniques
such as these: <a class="moz-txt-link-rfc2396E" href="http://www.ginac.de/FAQ.html#advanced"><http://www.ginac.de/FAQ.html#advanced></a>
Cheers
-richy.
</pre>
</blockquote>
<br>
</div>
</body>
</html>