Re: discretized Laplacian or linear inverse problem with extremely

• To: mathgroup at smc.vnet.net
• Subject: [mg110154] Re: discretized Laplacian or linear inverse problem with extremely
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Fri, 4 Jun 2010 08:03:02 -0400 (EDT)
• References: <hu7tmv\$jl3\$1@smc.vnet.net>

```On Jun 3, 4:47 am, Igor <i.e.koz... at gmail.com> wrote:
> Hello!
>
> There are:
> A n*n matrix
> x n*1 matrix==column
> b n*1 matrix==column
> and the well known equation
> A.x==b
>
> I know columns x and b
> I want Mathematica to derive matrix A
>
> Of course, generally, this is a complicated problem, but
> in my case all values of matrix A are small (less than 20
> in absolute value) integers, because I am interested in a
> very special case.(I am looking for the matrix of discretized
> Laplacian in D={1,2,3,4} dimensions)
>
> As an example of my problem
> for (D=2) n=2 we have:
> x= {
>  {f[1, 1]},
>  {f[2, 1]},
>  {f[1, 2]},
>  {f[2, 2]}}
>
> b=
> {
>  {-4 f[1, 1] + f[1, 2] + f[2, 1]},
>  {f[1, 1] - 4 f[2, 1] + f[2, 2]},
>  {f[1, 1] - 4 f[1, 2] + f[2, 2]},
>  {f[1, 2] + f[2, 1] - 4 f[2, 2]}}
>
> and the solution (the matrix A) is
> -4  1  1  0
>  1 -4  0  1
>  1  0 -4  1
>  0  1  1 -4
>
> So, I would like Mathematica to do similar
> derivation of matrix A for me.
>
> I have the following questions:
>
> 1. Is there any method in Mathematica to find A from
> A.x==b if I know that this problem is well defined,
> I know x, b and that A elements have only integer values?
>
> 2. An obvious (or obviously mad :-) ) solution of the problem
> would be to perform an exhaustive search. I mean to
> ran n*n loops for all elements of matrix A from -20 to 20
> till A.x==b. But, I don't know how to perform this in
> Mathematica (as the number of loops is n*n and thus
> depend on n, that I want to vary).
>
> 3. If the matrix A of the discretized Laplacian is
> written somewhere for cases D==3 and D==4,
> please, send me a link.
>
> Thank you very much for your attention!
> All suggestions are welcome!

Could use SolveAlways, for a start.

amat = Array[a, {Length[x],Length[b]}];
vars = Flatten[amat];
exprs = Flatten[amat.x-b];
params = Variables[{x,b}];

amat /. SolveAlways[exprs==0, params]
Out= {{{-4, 1, 1, 0}, {1, -4, 0, 1}, {1, 0, -4, 1}, {0, 1, 1,
-4}}}

When it is underdetermined you might need to use e.g. Reduce to get
integer solutions.

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Export
• Next by Date: Re: discretized Laplacian or linear inverse problem with extremely simple
• Previous by thread: Puzzlement about DumpSave (and/or DownValues)
• Next by thread: Re: discretized Laplacian or linear inverse problem with extremely simple
{"ft_lang_label":"__label__en","ft_lang_prob":0.82175803,"math_prob":0.9346494,"size":2402,"snap":"2021-21-2021-25","text_gpt3_token_len":839,"char_repetition_ratio":0.10175146,"word_repetition_ratio":0.029227557,"special_character_ratio":0.3925895,"punctuation_ratio":0.19237435,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99425536,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-06-18T04:57:22Z\",\"WARC-Record-ID\":\"<urn:uuid:72b09ad3-b57e-450e-97eb-c42d4360ca81>\",\"Content-Length\":\"46275\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:108eca6d-04e4-4244-87cb-a8783f6ea69f>\",\"WARC-Concurrent-To\":\"<urn:uuid:cc675f4d-06e8-4545-a345-0d469fc28be2>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"https://forums.wolfram.com/mathgroup/archive/2010/Jun/msg00054.html\",\"WARC-Payload-Digest\":\"sha1:ZFR4DHXTRERXPDGBVCW4ZUEKFZSXLGST\",\"WARC-Block-Digest\":\"sha1:MM52E4ZMU2FWD4CQ3QSDOLBJRT66YWTV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-25/CC-MAIN-2021-25_segments_1623487635724.52_warc_CC-MAIN-20210618043356-20210618073356-00494.warc.gz\"}"}