# [LON-CAPA-users] Extracting the numerical value from a solve() Maxima command

Seema Ali sali at vsb.bc.ca
Fri Jan 27 18:14:37 EST 2012

```Hi,

This was my attempt to get Maxima to solve the following equation:
\$base1^\$power1maxima = \$base2^\$power2maxima
where \$power1maxima and \$power2maxima are linear equations and
\$base1 and \$base2 are constant values.

Below is a snippet of part of my code:

\$solution = &cas('maxima',"float(solve((\$power1maxima)*log(\$base1) = (\$power2maxima)*log(\$base2),x))");
\$solution =~ /(-?\d+(?:\.\d+)?)/;

Here are a couple of examples of some values:

Example 1:
An equation it is trying to solve: (2 * x)*log(7) = (-7 * x - 7)*log(9)
\$solution is [x = -.7980624185332027]

Example 2:
An equation it is trying to solve: (2x)log(4)=(?5x?8)log(3)
\$solution is [x=?1063303930517583]

The answer for Example 2 should be -1.063303930517583.  If I double click on the values on the page I get the decimal point, otherwise if I highlight them which is what I did for Example 2, the decimal is missing, which is a separate issue.

Example 2 also generates this error:
ERROR: Computer's answer is incorrect ("-1.063303930517583"). It is likely that the tolerance range [-1.06340393051758, -1.06320393051758] needs to be adjusted.
This error occurred while processing response 1_7 in part 0

My tolerance range is 5%.

I think it is my attempt at a regular expression is probably causing this problem.

How do I extract the numerical value from a solve command in Maxima?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20120127/7aab719e/attachment.html>
```