# bug #64655: [Octave Forge] (Symbolic) A problem with evaluating symbolic expression

 Submitter: Ahmed Salah Hammad Ahmed Submitted: Mon 11 Sep 2023 03:20:05 PM UTC Category: Octave Package Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: None Assigned to: None Originator Name: Open/Closed:  * Open Release:  * other Operating System:  * GNU/Linux Fixed Release: None Planned Release: None
* Mandatory Fields

Add a New Comment Rich Markup

## Discussion

Mon 11 Sep 2023 05:29:37 PM UTC, comment #2:

"exp" is a build-in octave function. A variable with the same name would "shadow" this function which can lead to some problems down the line.  Don't do that. Try to come up with a unique name like
"asha_exp" or "exp01".

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Mon 11 Sep 2023 05:21:43 PM UTC, comment #1:

try  this

syms x y z
digits(100)

a1=vpa('1.435647686e28')
exp = a1 * (vpa('1e-19')*x + vpa('1e-22')*y + z*vpa('1e-15'))

Doug Stewart <dastew>
Mon 11 Sep 2023 03:20:05 PM UTC, original submission:

Whenever there's an expression that looks exactly like this and with such large numbers as coefficients:

syms x y z
exp = 1.435647686e28 * (1e-19*x + 1e-22*y + z*1e-15)
[Output]:
9223372036854775807⋅z
x + y + ─────────────────────
1000000000000000
vpa(ans)
[Output]:
ans = (sym) x + y + 9223.37203686⋅z

which is obviously wrong.. and the problem persists whenever an expression is evaluated, for example:

f = @(x,y,z) 1.435647686e28 * (1e-19*x + 1e-22*y + z*1e-15)
[Output]:
f =
@(x, y, z) 1.435647686e28 * (1e-19 * x + 1e-22 * y + z * 1e-15)
syms x y z
f(x,y,z)
[Output]:
9223372036854775807⋅z
x + y + ─────────────────────
1000000000000000

And even when sending the whole expression to the built in function 'eval' and started debugging a little, the expression keeps ok until it is evaluated at the function fh, as appearing in the screenshot attached

And.., the same code works on matlab well..

I tried the same thing using octave v:7.1.1 and v:9.0.0 on a PC with Linux Ubuntu 20.04

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

Attached Files

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by dasergatskov (Posted a comment)
• -email is unavailable- added by dastew (Posted a comment)
•

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only group members can vote.

## History

Follows 1 latest change.

Date Changed by Updated Field Previous Value => Replaced by