## 7781 Reputation

18 years, 19 days

## Odd problem with Physics[Vectors]...

Maple 2019

I can't figure out the source of the problem.  Any ideas?

 > restart;
 > with(Physics[Vectors]):
 > Physics:-Version();

 > 3.0*_i + 4.0*_j;

 > 3.0*_i + 0.0*_j;

Error, (in Physics:-Vectors:-+) wrong sum of a vector with the scalar 0.

How do we handle this when it happens within a computation burried inside a proc?

## Why does seq behave this way?...

Maple

In this worksheet I solve a system of differential-algebraic equations (DAEs) and then invoke a proc to evaluate the solution.  The trivial proc, called tryme, is reduced from a larger proc which I have cut down to focus on the error message.

I can't explain where the error originates.  Can someone shed light?  I don't insist on the output=operator option.  I tried other output options but always arrived at the same error message.

 > restart;
 > de1 := diff(x(t),t,t) = lambda(t)*x(t);

 > de2 := diff(y(t),t,t) = 1 + lambda(t)*y(t);

 > eq := x(t)^2 + y(t)^2 = 1;

 > ic := x(0)=1, y(0)=0, D(x)(0)=0, D(y)(0)=0;

 > dsol := dsolve({de1,de2,eq,ic}, numeric, output=operator);

Let's extract the x component of the solution.

Due to the output=operator option, the result is a procedure.

 > my_x := eval(x, dsol);

 > plot(my_x(t), t=0..10);

This evaluates the procedure my_x at time T

 > tryme := proc(T::numeric)   my_x(T); end proc:

The proc tryme works as intended:

 > my_x(1) = tryme(1);

Calling tryme through a sequence works fine:

 > seq(tryme(s), s=1..3);

But the name t  is treated as special.

 > seq(tryme(t), t=1..3);

Error, (in my_x) invalid input: diff received 1, which is not valid for its 2nd argument

What is the source of this error?

How can one work around it other than by avoiding the name t ?

## How to overlay an image on a 3D surface?...

Maple

I want to make a 3D image of a US one cent coin (a penny).  To produce one face of the penny I thought of doing

plot3d(0, y=-sqrt(1-x^2)..sqrt(1-x^2), x=-1..1, image="penny.png");

but this distorts the circular image into something that's not quite circular:

What is a better way of doing that?

Here is the image penny.png that I used:

## Problem with animating a numeric dsolve...

Maple

I don't understand why Maple does not like my code:

 > restart;
 > with(plots):
 > dsol := dsolve({diff(y(t),t) = -y(t), y(0)=1}, numeric):
 > frame := proc(s)   odeplot(dsol, [t,y(t)], t=0..s); end proc:
 > animate(frame, [t], t=0..3);

Error, (in plots/animate) invalid range

I know how to get around it (as shown in the attached worksheet) but I am curious to know why the above approach does not work.

## How to calculate flux in the heat equati...

Maple

I solve a boundary value problem for a linear system of first order PDEs
in the unknowns  and   Ultimately, I am interested in the graph
of the function  but numerical artifacts distort that graph badly by
imposing spurious oscillation.

Is there a way to maneuver the calculations to obtain the graph of
without the oscillation?

 > restart;
 > pde1 := diff(u(x,t),t)=diff(v(x,t),x);

 > pde2 := diff(u(x,t),x)=v(x,t);

 > ibc := u(x,0)=1, u(0,t)=0, u(1,t)=0;

 > dsol := pdsolve({pde1,pde2}, {ibc}, numeric, spacestep=0.01, timestep=0.01);

 > dsol:-value(output=listprocedure): my_u := eval(u(x,t), %): my_v := eval(v(x,t), %%):
 > plot3d(my_u(x,t), x=0..1, t=0..0.5);

 > plot3d(my_v(x,t), x=0..1, t=0..0.5);

The oscillations are numerical artifacts.  Can they be avoided?

 > plot(my_v(0,t), t=0..0.5);

A side comment: By eliminating between the two PDEs we see that
satisfies the standard heat equation, thus is the flux.  The expression
expresses the heat flux at the boundary, and that's what I am after.