Clear Filters
Clear Filters

How to multiply symbolic with numeric?

6 views (last 30 days)
Hi all'
assume that
w=randn(2,2)
a=sym('a',[2 2])
I need to get the answer of multiblication of (a .* w) with smae size [ 2 2] since, I multiplied them like (a .* w) i got this answer
ans =
[ -(4545034027795199*a1_1)/18014398509481984, -(8311781718565711*a1_2)/18014398509481984]
[ -(1390961227654289*a2_1)/1125899906842624, (5388115603050723*a2_2)/18014398509481984]
However, the random values of w is
w =
-0.2523 -0.4614
-1.2354 0.2991
a =
[ a1_1, a1_2]
[ a2_1, a2_2]
I don't belive this correct results however, I need the results like this [ -0.2523 * a1_1, -0.4614* a1_2
-1.2354 * a2_1, 0.2991 * a2_2]
thanks indeed

Accepted Answer

Steven Lord
Steven Lord on 21 Dec 2020
Call vpa on the result.
  3 Comments

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 21 Dec 2020
w = round(sym(randn(2,2),'d'),4)
You are, by the way, not correct about what the value of w is. The actual values for w extend to about 15 significant decimal places, and you are getting confused because you have the default format in effect. I recommend that you use
format long g
and change your preferences to use that.
However, you defined your required output in terms of four decimal places, so I included a call to force four decimal places.
Note: symbolic floating point numbers give the strong impression that they are base 10 internally, but closer to the truth is that they use a base 2^30 representation, which is close enough to base 10^10 representation that it takes real effort to prove the difference.
  13 Comments
Walter Roberson
Walter Roberson on 23 Dec 2020
Taking one derivative of one entry of dL4 took my system about 18 minutes. You have over 65000 derivatives to take at the bottom of your code, each on a value that is more complicated than dL4 is. You would expect a minimum of 20 minutes per derivative, times 65000 derivivates, gives about 130000 minutes -> over 900 days.
Each derivative looks like it is going to be over 2 gigabytes to write out -> 130 petabytes .
Suppose that I whipped up something to run on distributed AWS and (somehow!!) managed to create that 130+ petabyte file tomorrow: what would you do with it?
Ali Najem
Ali Najem on 23 Dec 2020
It's just an idea for a project, anyway your explanation is clear and I have understood all things thank you so much sir really appreciate your time to help.
Maybe I will try another idea,
my regards.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!